feat: bevel custom profile support
This commit is contained in:
parent
2495b5b0e7
commit
b1464c9e14
@ -418,7 +418,14 @@ def dump_modifiers(modifiers: bpy.types.bpy_prop_collection)->dict:
|
||||
dumped_modifier['settings'] = dumper.dump(modifier.settings)
|
||||
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_modifiers.append(dumped_modifier)
|
||||
return dumped_modifiers
|
||||
|
||||
|
@ -581,6 +581,26 @@ class Loader:
|
||||
else:
|
||||
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
|
||||
@ -657,6 +677,8 @@ 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…
x
Reference in New Issue
Block a user