From b1464c9e14bd53e82e0cf4c5e1b5192e4fc0f611 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Wed, 9 Feb 2022 16:50:03 +0100 Subject: [PATCH] feat: bevel custom profile support --- multi_user/bl_types/bl_object.py | 9 ++++++++- multi_user/bl_types/dump_anything.py | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/multi_user/bl_types/bl_object.py b/multi_user/bl_types/bl_object.py index ebc85e1..9dd23f0 100644 --- a/multi_user/bl_types/bl_object.py +++ b/multi_user/bl_types/bl_object.py @@ -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 diff --git a/multi_user/bl_types/dump_anything.py b/multi_user/bl_types/dump_anything.py index 48a167d..2022ce0 100644 --- a/multi_user/bl_types/dump_anything.py +++ b/multi_user/bl_types/dump_anything.py @@ -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),