Refactoring

This commit is contained in:
Simone Barbieri 2020-06-10 10:26:28 +01:00
parent 08ca6dda9b
commit 1531057a24
4 changed files with 16 additions and 28 deletions

View file

@ -29,7 +29,6 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader):
icon = "code-fork"
color = "orange"
@staticmethod
def _remove(self, objects, lib_container):
for obj in objects:
@ -41,7 +40,6 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader):
bpy.data.collections.remove(bpy.data.collections[lib_container])
@staticmethod
def _process(self, libpath, lib_container, container_name):
relative = bpy.context.preferences.filepaths.use_relative_paths
@ -131,7 +129,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader):
container_metadata["lib_container"] = lib_container
objects_list = self._process(
self, libpath, lib_container, container_name)
libpath, lib_container, container_name)
# Save the list of objects in the metadata container
container_metadata["objects"] = objects_list
@ -205,14 +203,10 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader):
objects = collection_metadata["objects"]
lib_container = collection_metadata["lib_container"]
# Get the armature of the rig
armatures = [obj for obj in objects if obj.type == 'ARMATURE']
assert(len(armatures) == 1)
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
objects_list = self._process(
self, str(libpath), lib_container, collection.name)
str(libpath), lib_container, collection.name)
# Save the list of objects in the metadata container
collection_metadata["objects"] = objects_list
@ -249,7 +243,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader):
objects = collection_metadata["objects"]
lib_container = collection_metadata["lib_container"]
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
bpy.data.collections.remove(collection)

View file

@ -29,7 +29,6 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader):
icon = "code-fork"
color = "orange"
@staticmethod
def _remove(self, objects, lib_container):
for obj in objects:
@ -46,7 +45,6 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader):
bpy.data.collections.remove(bpy.data.collections[lib_container])
@staticmethod
def _process(self, libpath, lib_container, container_name, actions):
relative = bpy.context.preferences.filepaths.use_relative_paths
@ -136,7 +134,7 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader):
container_metadata["lib_container"] = lib_container
objects_list = self._process(
self, libpath, lib_container, container_name, {})
libpath, lib_container, container_name, {})
# Save the list of objects in the metadata container
container_metadata["objects"] = objects_list
@ -218,10 +216,10 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader):
actions[obj.name] = obj.animation_data.action
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
objects_list = self._process(
self, str(libpath), lib_container, collection.name, actions)
str(libpath), lib_container, collection.name, actions)
# Save the list of objects in the metadata container
collection_metadata["objects"] = objects_list
@ -258,7 +256,7 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader):
objects = collection_metadata["objects"]
lib_container = collection_metadata["lib_container"]
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
bpy.data.collections.remove(collection)

View file

@ -30,7 +30,6 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader):
icon = "code-fork"
color = "orange"
@staticmethod
def _remove(self, objects, lib_container):
for obj in objects:
@ -39,7 +38,6 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader):
bpy.data.collections.remove(bpy.data.collections[lib_container])
@staticmethod
def _process(self, libpath, lib_container, container_name):
relative = bpy.context.preferences.filepaths.use_relative_paths
@ -118,7 +116,7 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader):
container_metadata["lib_container"] = lib_container
objects_list = self._process(
self, libpath, lib_container, container_name)
libpath, lib_container, container_name)
# Save the list of objects in the metadata container
container_metadata["objects"] = objects_list
@ -189,10 +187,10 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader):
logger.info("Library already loaded, not updating...")
return
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
objects_list = self._process(
self, str(libpath), lib_container, collection.name)
str(libpath), lib_container, collection.name)
# Save the list of objects in the metadata container
collection_metadata["objects"] = objects_list
@ -226,7 +224,7 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader):
objects = collection_metadata["objects"]
lib_container = collection_metadata["lib_container"]
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
bpy.data.collections.remove(collection)

View file

@ -30,7 +30,6 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader):
icon = "code-fork"
color = "orange"
@staticmethod
def _remove(self, objects, lib_container):
for obj in objects:
@ -45,7 +44,6 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader):
bpy.data.collections.remove(bpy.data.collections[lib_container])
@staticmethod
def _process(self, libpath, lib_container, container_name, action):
relative = bpy.context.preferences.filepaths.use_relative_paths
@ -131,7 +129,7 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader):
container_metadata["lib_container"] = lib_container
objects_list = self._process(
self, libpath, lib_container, container_name, None)
libpath, lib_container, container_name, None)
# Save the list of objects in the metadata container
container_metadata["objects"] = objects_list
@ -210,10 +208,10 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader):
action = armatures[0].animation_data.action
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
objects_list = self._process(
self, str(libpath), lib_container, collection.name, action)
str(libpath), lib_container, collection.name, action)
# Save the list of objects in the metadata container
collection_metadata["objects"] = objects_list
@ -250,7 +248,7 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader):
objects = collection_metadata["objects"]
lib_container = collection_metadata["lib_container"]
self._remove(self, objects, lib_container)
self._remove(objects, lib_container)
bpy.data.collections.remove(collection)