refactor: use np_load
This commit is contained in:
parent
b1464c9e14
commit
cc5ceafea9
@ -47,7 +47,10 @@ SHAPEKEY_BLOCK_ATTR = [
|
||||
'slider_max',
|
||||
]
|
||||
|
||||
|
||||
CURVE_POINT = [
|
||||
'location',
|
||||
'handle_type_2',
|
||||
]
|
||||
if bpy.app.version >= (2,93,0):
|
||||
SUPPORTED_GEOMETRY_NODE_PARAMETERS = (int, str, float)
|
||||
else:
|
||||
@ -419,13 +422,7 @@ def dump_modifiers(modifiers: bpy.types.bpy_prop_collection)->dict:
|
||||
elif modifier.type == 'UV_PROJECT':
|
||||
dumped_modifier['projectors'] =[p.object.name for p in modifier.projectors if p and p.object]
|
||||
elif modifier.type == 'BEVEL' and modifier.profile_type == 'CUSTOM':
|
||||
curve_dumper = Dumper()
|
||||
curve_dumper.depth = 5
|
||||
curve_dumper.include_filter = [
|
||||
'curves',
|
||||
'points',
|
||||
'location']
|
||||
dumped_modifier['custom_profile'] = curve_dumper.dump(modifier.custom_profile)
|
||||
dumped_modifier['custom_profile'] = np_dump_collection(modifier.custom_profile.points, CURVE_POINT)
|
||||
dumped_modifiers.append(dumped_modifier)
|
||||
return dumped_modifiers
|
||||
|
||||
@ -497,6 +494,28 @@ def load_modifiers(dumped_modifiers: list, modifiers: bpy.types.bpy_prop_collect
|
||||
loaded_modifier.projectors[projector_index].object = target_object
|
||||
else:
|
||||
logging.error("Could't load projector target object {projector_object}")
|
||||
elif loaded_modifier.type == 'BEVEL':
|
||||
src_cust_profile = dumped_modifier.get('custom_profile')
|
||||
if src_cust_profile:
|
||||
dst_points = loaded_modifier.custom_profile.points
|
||||
|
||||
# TODO: refactor to be diff-compatible
|
||||
for p in dst_points:
|
||||
try:
|
||||
dst_points.remove(dst_points[0])
|
||||
except Exception:
|
||||
break
|
||||
|
||||
for i in range(len(src_cust_profile['handle_type_2'])-len(dst_points)):
|
||||
dst_points.add(0,0)
|
||||
|
||||
loaded_modifier.custom_profile.points.update()
|
||||
logging.info(len(loaded_modifier.custom_profile.points))
|
||||
|
||||
np_load_collection(src_cust_profile, dst_points, CURVE_POINT)
|
||||
|
||||
loaded_modifier.custom_profile.points.update()
|
||||
|
||||
|
||||
|
||||
def load_modifiers_custom_data(dumped_modifiers: dict, modifiers: bpy.types.bpy_prop_collection):
|
||||
|
@ -582,25 +582,6 @@ class Loader:
|
||||
dst_curve.points.new(pos[0], pos[1])
|
||||
curves.update()
|
||||
|
||||
def _load_curve_profile(self, element, dump):
|
||||
curve = element.read()
|
||||
|
||||
# cleanup existing curve
|
||||
for idx in range(len(curve.points), 0, -1):
|
||||
try:
|
||||
curve.points.remove(curve.points[0])
|
||||
except Exception:
|
||||
break
|
||||
|
||||
default_point_count = len(curve.points)
|
||||
for i in range(len(dump['points'])-default_point_count):
|
||||
curve.points.add(0,0)
|
||||
|
||||
for point_idx, point in reversed(dump['points'].items()):
|
||||
# if point_idx < default_point_count:
|
||||
curve.points[int(point_idx)].location = point['location']
|
||||
|
||||
curve.update()
|
||||
|
||||
def _load_pointer(self, instance, dump):
|
||||
rna_property_type = instance.bl_rna_property.fixed_type
|
||||
@ -677,8 +658,6 @@ class Loader:
|
||||
(_load_filter_type(mathutils.Euler, use_bl_rna=False), self._load_euler),
|
||||
(_load_filter_type(T.CurveMapping, use_bl_rna=False),
|
||||
self._load_curve_mapping),
|
||||
(_load_filter_type(T.CurveProfile, use_bl_rna=False),
|
||||
self._load_curve_profile),
|
||||
(_load_filter_type(T.FloatProperty), self._load_identity),
|
||||
(_load_filter_type(T.StringProperty), self._load_identity),
|
||||
(_load_filter_type(T.EnumProperty), self._load_identity),
|
||||
|
Loading…
Reference in New Issue
Block a user