fix: gpencil material loading error
Now loading gpencil materials from uuid
This commit is contained in:
parent
e6996316be
commit
64a25f94a3
@ -29,6 +29,7 @@ from .bl_datablock import resolve_datablock_from_uuid
|
|||||||
from .bl_action import dump_animation_data, load_animation_data, resolve_animation_dependencies
|
from .bl_action import dump_animation_data, load_animation_data, resolve_animation_dependencies
|
||||||
from ..utils import get_preferences
|
from ..utils import get_preferences
|
||||||
from ..timers import is_annotating
|
from ..timers import is_annotating
|
||||||
|
from .bl_material import load_materials_slots, dump_materials_slots
|
||||||
|
|
||||||
STROKE_POINT = [
|
STROKE_POINT = [
|
||||||
'co',
|
'co',
|
||||||
@ -229,10 +230,10 @@ class BlGpencil(ReplicatedDatablock):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(data: dict, datablock: object):
|
def load(data: dict, datablock: object):
|
||||||
datablock.materials.clear()
|
# MATERIAL SLOTS
|
||||||
if "materials" in data.keys():
|
src_materials = data.get('materials', None)
|
||||||
for mat in data['materials']:
|
if src_materials:
|
||||||
datablock.materials.append(bpy.data.materials[mat])
|
load_materials_slots(src_materials, datablock.materials)
|
||||||
|
|
||||||
loader = Loader()
|
loader = Loader()
|
||||||
loader.load(datablock, data)
|
loader.load(datablock, data)
|
||||||
@ -260,7 +261,6 @@ class BlGpencil(ReplicatedDatablock):
|
|||||||
dumper = Dumper()
|
dumper = Dumper()
|
||||||
dumper.depth = 2
|
dumper.depth = 2
|
||||||
dumper.include_filter = [
|
dumper.include_filter = [
|
||||||
'materials',
|
|
||||||
'name',
|
'name',
|
||||||
'zdepth_offset',
|
'zdepth_offset',
|
||||||
'stroke_thickness_space',
|
'stroke_thickness_space',
|
||||||
@ -268,7 +268,7 @@ class BlGpencil(ReplicatedDatablock):
|
|||||||
'stroke_depth_order'
|
'stroke_depth_order'
|
||||||
]
|
]
|
||||||
data = dumper.dump(datablock)
|
data = dumper.dump(datablock)
|
||||||
|
data['materials'] = dump_materials_slots(datablock.materials)
|
||||||
data['layers'] = {}
|
data['layers'] = {}
|
||||||
|
|
||||||
for layer in datablock.layers:
|
for layer in datablock.layers:
|
||||||
|
@ -387,11 +387,10 @@ def load_materials_slots(src_materials: list, dst_materials: bpy.types.bpy_prop_
|
|||||||
|
|
||||||
for mat_uuid, mat_name in src_materials:
|
for mat_uuid, mat_name in src_materials:
|
||||||
mat_ref = None
|
mat_ref = None
|
||||||
if mat_uuid is not None:
|
if mat_uuid:
|
||||||
mat_ref = get_datablock_from_uuid(mat_uuid, None)
|
mat_ref = get_datablock_from_uuid(mat_uuid, None)
|
||||||
else:
|
else:
|
||||||
mat_ref = bpy.data.materials[mat_name]
|
mat_ref = bpy.data.materials[mat_name]
|
||||||
|
|
||||||
dst_materials.append(mat_ref)
|
dst_materials.append(mat_ref)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user