feat: modifiers support

This commit is contained in:
Swann 2019-07-15 22:25:20 +02:00
parent 2ba1c33377
commit b8f164adaa
4 changed files with 26 additions and 9 deletions

View File

@ -81,7 +81,7 @@ def save_session_config(self,context):
config["replicated_types"][bloc.type_name] = bloc.is_replicated
# Generate ordered replicate types
environment.genereate_replicated_types(config["replicated_types"])
environment.genererate_replicated_types()
# Save out the configuration file
environment.save_config(config)

View File

@ -82,9 +82,11 @@ def get_replicated_types():
return tlist
def genereate_replicated_types(replicated_types):
def genererate_replicated_types():
rtypes.clear()
cfg = load_config()
replicated_types = cfg['replicated_types']
for t in ORDERED_TYPES:
if replicated_types[t]:
rtypes.append(t)

View File

@ -71,9 +71,6 @@ def get_selected_objects(scene):
# LOAD HELPERS
# def load_color(color_dict, target_color_attribute):
# target_color_attribute
def load_dict(src_dict, target):
try:
for item in src_dict:
@ -96,7 +93,7 @@ def load(key, value):
if target_type == 'Object':
load_object(target=target, data=value,
create=True)
if target_type == 'Image':
elif target_type == 'Image':
load_image(target=target, data=value)
elif target_type == 'Mesh':
load_mesh(target=target, data=value,
@ -337,6 +334,21 @@ def load_object(target=None, data=None, create=False):
client = bpy.context.window_manager.session.username
# Load modifiers
if hasattr(target,'modifiers'):
for local_modifier in target.modifiers:
if local_modifier.name not in data['modifiers']:
target.modifiers.remove(local_modifier)
for modifier in data['modifiers']:
target_modifier = target.modifiers.get(modifier)
if not target_modifier:
target_modifier = target.modifiers.new(data['modifiers'][modifier]['name'],data['modifiers'][modifier]['type'])
dump_anything.load(target_modifier, data['modifiers'][modifier])
if target.id == client or target.id == "Common":
target.hide_select = False
else:
@ -615,8 +627,6 @@ def load_default(target=None, data=None, create=False, type=None):
logger.error("default loading error {}".format(e))
# DUMP HELPERS
def dump(key):
target = resolve_bpy_path(key)
target_type = key.split('/')[0]
@ -667,6 +677,10 @@ def dump(key):
# "radius_interpolation", "resolution_v", "use_bezier_u", "use_bezier_v", "use_cyclic_u", "use_cyclic_v", "use_endpoint_u", "use_endpoint_v"], 3)
elif target_type == 'Object':
data = dump_datablock(target, 1)
if hasattr(target,'modifiers'):
dump_datablock_attibutes(
target, ['modifiers'], 3, data)
elif target_type == 'Collection':
data = dump_datablock(target, 4)
elif target_type == 'Scene':

View File

@ -90,6 +90,7 @@ def update_client_selected_object(context):
def init_datablocks():
environment.genererate_replicated_types()
for datatype in environment.rtypes:
if bpy.context.window_manager.session.supported_datablock[datatype].is_replicated:
logger.debug("INIT: {}".format(datatype))