feat: basic library handling
This commit is contained in:
@ -12,15 +12,19 @@ class BlDatablock(ReplicatedDatablock):
|
||||
pointer = kwargs.get('pointer', None)
|
||||
buffer = self.buffer
|
||||
|
||||
if (pointer and hasattr(pointer, 'library') and
|
||||
pointer.library) or \
|
||||
(buffer and 'library' in buffer):
|
||||
# TODO: use is_library_indirect
|
||||
self.is_library = (pointer and hasattr(pointer, 'library') and
|
||||
pointer.library) or \
|
||||
(buffer and 'library' in buffer)
|
||||
# :
|
||||
if self.is_library:
|
||||
self.load = self.load_library
|
||||
self.dump = self.dump_library
|
||||
self.construct = self.construct_library
|
||||
self.diff = self.diff_library
|
||||
self.resolve_dependencies = self.resolve_dependencies_library
|
||||
self.apply = self.library_apply
|
||||
|
||||
# self.construct = self.construct_library
|
||||
# self.resolve_dependencies = self.resolve_dependencies_library
|
||||
# self.apply = self.library_apply
|
||||
|
||||
if self.pointer and hasattr(self.pointer, 'uuid'):
|
||||
self.pointer.uuid = self.uuid
|
||||
@ -36,11 +40,13 @@ class BlDatablock(ReplicatedDatablock):
|
||||
return self.pointer.name != self.buffer['name']
|
||||
|
||||
def construct_library(self, data):
|
||||
with bpy.data.libraries.load(filepath=bpy.data.libraries[self.buffer['library']].filepath, link=True) as (sourceData, targetData):
|
||||
# targetData[self.name] = sourceData
|
||||
print("asd")
|
||||
return None
|
||||
|
||||
def load_library(self, data, target):
|
||||
pass
|
||||
|
||||
print("asdasdas")
|
||||
|
||||
def dump_library(self, pointer=None):
|
||||
return utils.dump_datablock(pointer, 1)
|
||||
|
@ -90,6 +90,8 @@ class BlMaterial(BlDatablock):
|
||||
for node in self.pointer.node_tree.nodes:
|
||||
if node.type == 'TEX_IMAGE':
|
||||
deps.append(node.image)
|
||||
if self.is_library:
|
||||
deps.append(self.pointer.library)
|
||||
|
||||
return deps
|
||||
|
||||
|
@ -175,5 +175,5 @@ bl_class = bpy.types.Mesh
|
||||
bl_rep_class = BlMesh
|
||||
bl_delay_refresh = 10
|
||||
bl_delay_apply = 10
|
||||
bl_automatic_push = False
|
||||
bl_automatic_push = True
|
||||
bl_icon = 'MESH_DATA'
|
||||
|
@ -9,6 +9,12 @@ class BlObject(BlDatablock):
|
||||
def construct(self, data):
|
||||
pointer = None
|
||||
|
||||
if self.is_library:
|
||||
with bpy.data.libraries.load(filepath=bpy.data.libraries[self.buffer['library']].filepath, link=True) as (sourceData, targetData):
|
||||
targetData.objects = [name for name in sourceData.objects if name == self.buffer['name']]
|
||||
|
||||
return targetData.objects[self.buffer['name']]
|
||||
|
||||
# Object specific constructor...
|
||||
if data["data"] in bpy.data.meshes.keys():
|
||||
pointer = bpy.data.meshes[data["data"]]
|
||||
@ -51,6 +57,9 @@ class BlObject(BlDatablock):
|
||||
def dump(self, pointer=None):
|
||||
assert(pointer)
|
||||
data = utils.dump_datablock(pointer, 1)
|
||||
|
||||
if self.is_library:
|
||||
return data
|
||||
|
||||
if hasattr(pointer, 'modifiers'):
|
||||
utils.dump_datablock_attibutes(
|
||||
@ -72,6 +81,9 @@ class BlObject(BlDatablock):
|
||||
|
||||
deps.append(self.pointer.data)
|
||||
|
||||
if self.is_library:
|
||||
deps.append(self.pointer.library)
|
||||
|
||||
return deps
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user