feat: color support for serialisation
This commit is contained in:
@ -28,7 +28,7 @@ DEPENDENCIES = {
|
|||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.INFO)
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
# UTILITY FUNCTIONS
|
# UTILITY FUNCTIONS
|
||||||
def client_list_callback(scene, context):
|
def client_list_callback(scene, context):
|
||||||
|
@ -23,7 +23,8 @@ DUMP_AGENTS_NUMBER = 1
|
|||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
instance = None
|
instance = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import logging
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config")
|
CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config")
|
||||||
CONFIG = os.path.join(CONFIG_DIR, "app.yaml")
|
CONFIG = os.path.join(CONFIG_DIR, "app.yaml")
|
||||||
|
@ -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'}
|
'Scene': 'scenes', 'Light': 'lights', 'SunLight': 'lights', 'SpotLight': 'lights', 'AreaLight': 'lights', 'PointLight': 'lights', 'Camera': 'cameras', 'Action': 'actions', 'Armature': 'armatures'}
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
# UTILITY FUNCTIONS
|
# UTILITY FUNCTIONS
|
||||||
|
|
||||||
|
|
||||||
@ -152,7 +153,6 @@ def load_client(client=None, data=None):
|
|||||||
if client and data:
|
if client and data:
|
||||||
if net_settings.enable_presence:
|
if net_settings.enable_presence:
|
||||||
draw.renderer.draw_client(data)
|
draw.renderer.draw_client(data)
|
||||||
|
|
||||||
draw.renderer.draw_client_selected_objects(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']
|
target.id = data['id']
|
||||||
|
|
||||||
# Tmp color fix
|
|
||||||
# setattr(target,"color",data['color']['owner'])
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("light loading error: {}".format(e))
|
logger.error("light loading error: {}".format(e))
|
||||||
|
@ -20,6 +20,8 @@ def _is_dictionnary(v):
|
|||||||
def _dump_filter_type(t):
|
def _dump_filter_type(t):
|
||||||
return lambda x: isinstance(x, 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):
|
def _dump_filter_array(array):
|
||||||
# only primitive type array
|
# only primitive type array
|
||||||
@ -55,6 +57,8 @@ def _load_filter_array(array):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _load_filter_color(color):
|
||||||
|
return color.__class__.__name__ == 'Color'
|
||||||
|
|
||||||
def _load_filter_default(default):
|
def _load_filter_default(default):
|
||||||
if default.read() is None:
|
if default.read() is None:
|
||||||
@ -81,7 +85,9 @@ class Dumper:
|
|||||||
|
|
||||||
def _dump_any(self, any, depth):
|
def _dump_any(self, any, depth):
|
||||||
for filter_function, dump_function in self.type_subset:
|
for filter_function, dump_function in self.type_subset:
|
||||||
|
|
||||||
if filter_function(any):
|
if filter_function(any):
|
||||||
|
# print(any)
|
||||||
return dump_function[not (depth >= self.depth)](any, depth + 1)
|
return dump_function[not (depth >= self.depth)](any, depth + 1)
|
||||||
|
|
||||||
def _build_inline_dump_functions(self):
|
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_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_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_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):
|
def _build_match_elements(self):
|
||||||
self._match_type_bool = (_dump_filter_type(bool), self._dump_identity)
|
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_array = (_dump_filter_array, self._dump_array)
|
||||||
self._match_type_matrix = (_dump_filter_type(mathutils.Matrix), self._dump_matrix)
|
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_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)
|
self._match_default = (_dump_filter_default, self._dump_default)
|
||||||
|
|
||||||
def _dump_collection_as_branch(self, collection, depth):
|
def _dump_collection_as_branch(self, collection, depth):
|
||||||
@ -128,6 +136,10 @@ class Dumper:
|
|||||||
def _dump_vector_as_leaf(self, vector, depth):
|
def _dump_vector_as_leaf(self, vector, depth):
|
||||||
return list(vector)
|
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 _dump_default_as_branch(self, default, depth):
|
||||||
def is_valid_property(p):
|
def is_valid_property(p):
|
||||||
try:
|
try:
|
||||||
@ -162,6 +174,8 @@ class Dumper:
|
|||||||
self._match_type_array,
|
self._match_type_array,
|
||||||
self._match_type_matrix,
|
self._match_type_matrix,
|
||||||
self._match_type_vector,
|
self._match_type_vector,
|
||||||
|
self._match_type_color,
|
||||||
|
self._match_type_color,
|
||||||
self._match_default
|
self._match_default
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -324,7 +338,8 @@ class Loader:
|
|||||||
(_load_filter_type(T.PointerProperty), self._load_pointer),
|
(_load_filter_type(T.PointerProperty), self._load_pointer),
|
||||||
(_load_filter_array, self._load_array),
|
(_load_filter_array, self._load_array),
|
||||||
(_load_filter_type(T.CollectionProperty), self._load_collection),
|
(_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),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ except:
|
|||||||
import zmq
|
import zmq
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
|
||||||
class Message(object):
|
class Message(object):
|
||||||
"""
|
"""
|
||||||
|
@ -19,6 +19,7 @@ from . import environment, client, draw, helpers, ui
|
|||||||
from .libs import umsgpack
|
from .libs import umsgpack
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
# client_instance = None
|
# client_instance = None
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user