Merge branch '147-support-grease-pencil-modifiers' into 'develop'
feat: added initial gpencil modifer support See merge request slumber/multi-user!81
This commit is contained in:
@@ -271,13 +271,35 @@ class BlObject(BlDatablock):
|
||||
return data
|
||||
|
||||
# MODIFIERS
|
||||
if hasattr(instance, 'modifiers'):
|
||||
modifiers = getattr(instance,'modifiers', None )
|
||||
if modifiers:
|
||||
dumper.include_filter = None
|
||||
dumper.depth = 1
|
||||
data["modifiers"] = {}
|
||||
for index, modifier in enumerate(instance.modifiers):
|
||||
for index, modifier in enumerate(modifiers):
|
||||
data["modifiers"][modifier.name] = dumper.dump(modifier)
|
||||
|
||||
gp_modifiers = getattr(instance, 'grease_pencil_modifiers', None)
|
||||
|
||||
if gp_modifiers:
|
||||
dumper.include_filter = None
|
||||
dumper.depth = 1
|
||||
gp_modifiers_data = data["grease_pencil_modifiers"] = {}
|
||||
|
||||
for index, modifier in enumerate(gp_modifiers):
|
||||
gp_mod_data = gp_modifiers_data[modifier.name] = dict()
|
||||
gp_mod_data.update(dumper.dump(modifier))
|
||||
|
||||
if hasattr(modifier, 'use_custom_curve') \
|
||||
and modifier.use_custom_curve:
|
||||
curve_dumper = Dumper()
|
||||
curve_dumper.depth = 5
|
||||
curve_dumper.include_filter = [
|
||||
'curves',
|
||||
'points',
|
||||
'location']
|
||||
gp_mod_data['curve'] = curve_dumper.dump(modifier.curve)
|
||||
|
||||
# CONSTRAINTS
|
||||
if hasattr(instance, 'constraints'):
|
||||
dumper.depth = 3
|
||||
|
||||
@@ -506,12 +506,14 @@ class Loader:
|
||||
T.ColorRampElement: (CONSTRUCTOR_NEW, ["position"]),
|
||||
T.ParticleSettingsTextureSlot: (CONSTRUCTOR_ADD, []),
|
||||
T.Modifier: (CONSTRUCTOR_NEW, ["name", "type"]),
|
||||
T.GpencilModifier: (CONSTRUCTOR_NEW, ["name", "type"]),
|
||||
T.Constraint: (CONSTRUCTOR_NEW, ["type"]),
|
||||
}
|
||||
|
||||
destructors = {
|
||||
T.ColorRampElement: DESTRUCTOR_REMOVE,
|
||||
T.Modifier: DESTRUCTOR_CLEAR,
|
||||
T.GpencilModifier: DESTRUCTOR_CLEAR,
|
||||
T.Constraint: CONSTRUCTOR_NEW,
|
||||
}
|
||||
element_type = element.bl_rna_property.fixed_type
|
||||
@@ -574,6 +576,7 @@ class Loader:
|
||||
dst_curve.points[int(point_idx)].location = pos
|
||||
else:
|
||||
dst_curve.points.new(pos[0], pos[1])
|
||||
curves.update()
|
||||
|
||||
def _load_pointer(self, instance, dump):
|
||||
rna_property_type = instance.bl_rna_property.fixed_type
|
||||
|
||||
@@ -23,7 +23,14 @@ MOFIFIERS_TYPES = [
|
||||
'CORRECTIVE_SMOOTH', 'LAPLACIANSMOOTH', 'SURFACE_DEFORM',
|
||||
'WARP', 'WAVE', 'CLOTH', 'COLLISION', 'DYNAMIC_PAINT',
|
||||
'EXPLODE', 'FLUID', 'OCEAN', 'PARTICLE_INSTANCE',
|
||||
'SOFT_BODY', 'SURFACE']
|
||||
'SOFT_BODY', 'SURFACE']
|
||||
|
||||
GP_MODIFIERS_TYPE = [
|
||||
'GP_ARRAY', 'GP_BUILD', 'GP_MIRROR', 'GP_MULTIPLY',
|
||||
'GP_SIMPLIFY', 'GP_SUBDIV', 'GP_ARMATURE',
|
||||
'GP_HOOK', 'GP_LATTICE', 'GP_NOISE', 'GP_OFFSET',
|
||||
'GP_SMOOTH', 'GP_THICK', 'GP_TIME', 'GP_COLOR',
|
||||
'GP_OPACITY', 'GP_TEXTURE', 'GP_TINT']
|
||||
|
||||
CONSTRAINTS_TYPES = [
|
||||
'CAMERA_SOLVER', 'FOLLOW_TRACK', 'OBJECT_SOLVER', 'COPY_LOCATION',
|
||||
@@ -33,17 +40,21 @@ CONSTRAINTS_TYPES = [
|
||||
'LOCKED_TRACK', 'STRETCH_TO', 'TRACK_TO', 'ACTION',
|
||||
'ARMATURE', 'CHILD_OF', 'FLOOR', 'FOLLOW_PATH', 'PIVOT', 'SHRINKWRAP']
|
||||
|
||||
#temporary disabled 'SPLINE_IK' until its fixed
|
||||
# temporary disabled 'SPLINE_IK' until its fixed
|
||||
|
||||
|
||||
def test_object(clear_blend):
|
||||
bpy.ops.mesh.primitive_cube_add(
|
||||
enter_editmode=False, align='WORLD', location=(0, 0, 0))
|
||||
|
||||
datablock = bpy.data.objects[0]
|
||||
|
||||
|
||||
# Add modifiers
|
||||
for mod_type in MOFIFIERS_TYPES:
|
||||
datablock.modifiers.new(mod_type,mod_type)
|
||||
datablock.modifiers.new(mod_type, mod_type)
|
||||
|
||||
for mod_type in GP_MODIFIERS_TYPE:
|
||||
datablock.grease_pencil_modifiers.new(mod_type,mod_type)
|
||||
|
||||
# Add constraints
|
||||
for const_type in CONSTRAINTS_TYPES:
|
||||
@@ -54,7 +65,6 @@ def test_object(clear_blend):
|
||||
datablock.shape_key_add(name='shape')
|
||||
datablock.shape_key_add(name='shape2')
|
||||
|
||||
|
||||
implementation = BlObject()
|
||||
expected = implementation._dump(datablock)
|
||||
bpy.data.objects.remove(datablock)
|
||||
|
||||
Reference in New Issue
Block a user