feat: color support for serialisation

This commit is contained in:
Swann Martinez
2019-07-12 11:38:23 +02:00
parent cc12defa51
commit 1bfc460a12
8 changed files with 26 additions and 9 deletions

View File

@ -28,7 +28,7 @@ DEPENDENCIES = {
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
logger.setLevel(logging.ERROR)
# UTILITY FUNCTIONS
def client_list_callback(scene, context):

View File

@ -23,7 +23,8 @@ DUMP_AGENTS_NUMBER = 1
lock = threading.Lock()
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
logger.setLevel(logging.ERROR)
instance = None

View File

@ -6,6 +6,7 @@ import logging
import collections
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config")
CONFIG = os.path.join(CONFIG_DIR, "app.yaml")

View File

@ -15,7 +15,8 @@ BPY_TYPES = {'Image': 'images', 'Texture': 'textures', 'Material': 'materials',
'Scene': 'scenes', 'Light': 'lights', 'SunLight': 'lights', 'SpotLight': 'lights', 'AreaLight': 'lights', 'PointLight': 'lights', 'Camera': 'cameras', 'Action': 'actions', 'Armature': 'armatures'}
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
logger.setLevel(logging.ERROR)
# UTILITY FUNCTIONS
@ -152,7 +153,6 @@ def load_client(client=None, data=None):
if client and data:
if net_settings.enable_presence:
draw.renderer.draw_client(data)
draw.renderer.draw_client_selected_objects(data)
@ -597,8 +597,6 @@ def load_light(target=None, data=None, create=False, type=None):
target.id = data['id']
# Tmp color fix
# setattr(target,"color",data['color']['owner'])
except Exception as e:
logger.error("light loading error: {}".format(e))

View File

@ -20,6 +20,8 @@ def _is_dictionnary(v):
def _dump_filter_type(t):
return lambda x: isinstance(x, t)
def _dump_filter_type_by_name(t_name):
return lambda x: t_name == x.__class__.__name__
def _dump_filter_array(array):
# only primitive type array
@ -55,6 +57,8 @@ def _load_filter_array(array):
return False
return True
def _load_filter_color(color):
return color.__class__.__name__ == 'Color'
def _load_filter_default(default):
if default.read() is None:
@ -81,7 +85,9 @@ class Dumper:
def _dump_any(self, any, depth):
for filter_function, dump_function in self.type_subset:
if filter_function(any):
# print(any)
return dump_function[not (depth >= self.depth)](any, depth + 1)
def _build_inline_dump_functions(self):
@ -92,6 +98,7 @@ class Dumper:
self._dump_matrix = (self._dump_matrix_as_leaf, self._dump_matrix_as_leaf)
self._dump_vector = (self._dump_vector_as_leaf, self._dump_vector_as_leaf)
self._dump_default = (self._dump_default_as_leaf, self._dump_default_as_branch)
self._dump_color = (self._dump_color_as_leaf, self._dump_color_as_leaf)
def _build_match_elements(self):
self._match_type_bool = (_dump_filter_type(bool), self._dump_identity)
@ -103,6 +110,7 @@ class Dumper:
self._match_type_array = (_dump_filter_array, self._dump_array)
self._match_type_matrix = (_dump_filter_type(mathutils.Matrix), self._dump_matrix)
self._match_type_vector = (_dump_filter_type(mathutils.Vector), self._dump_vector)
self._match_type_color = (_dump_filter_type_by_name("Color"), self._dump_color)
self._match_default = (_dump_filter_default, self._dump_default)
def _dump_collection_as_branch(self, collection, depth):
@ -128,6 +136,10 @@ class Dumper:
def _dump_vector_as_leaf(self, vector, depth):
return list(vector)
def _dump_color_as_leaf(self, color, depth):
print(color)
return list(color)
def _dump_default_as_branch(self, default, depth):
def is_valid_property(p):
try:
@ -162,6 +174,8 @@ class Dumper:
self._match_type_array,
self._match_type_matrix,
self._match_type_vector,
self._match_type_color,
self._match_type_color,
self._match_default
]
@ -324,7 +338,8 @@ class Loader:
(_load_filter_type(T.PointerProperty), self._load_pointer),
(_load_filter_array, self._load_array),
(_load_filter_type(T.CollectionProperty), self._load_collection),
(_load_filter_default, self._load_default)
(_load_filter_default, self._load_default),
(_load_filter_color, self._load_identity),
]

View File

@ -9,7 +9,8 @@ except:
import zmq
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
logger.setLevel(logging.ERROR)
class Message(object):
"""

View File

@ -19,6 +19,7 @@ from . import environment, client, draw, helpers, ui
from .libs import umsgpack
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
# client_instance = None

View File

@ -8,7 +8,7 @@ import zmq
import message
logger = logging.getLogger("Server")
logging.basicConfig(level=logging.DEBUG)
logger.setLevel(logging.ERROR)
SUPPORTED_TYPES = [
'Client',