feat: add replication to the submodules

This commit is contained in:
Swann 2021-03-25 14:55:53 +01:00
parent 328c651cea
commit e3af69a9c8
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
21 changed files with 103 additions and 98 deletions

3
.gitmodules vendored
View File

@ -0,0 +1,3 @@
[submodule "multi_user/libs/replication"]
path = multi_user/libs/replication
url = https://gitlab.com/slumber/replication

View File

@ -42,11 +42,7 @@ from bpy.app.handlers import persistent
from . import environment
DEPENDENCIES = {
("replication", '0.1.26'),
}
LIBS = os.path.dirname(os.path.abspath(__file__))+"/libs/replication"
module_error_msg = "Insufficient rights to install the multi-user \
dependencies, aunch blender with administrator rights."
@ -57,14 +53,14 @@ def register():
datefmt='%H:%M:%S',
level=logging.INFO)
if LIBS in sys.path:
logging.debug('Third party module already added')
else:
logging.info('Adding local modules dir to the path')
sys.path.insert(0, LIBS)
try:
if bpy.app.version[1] >= 91:
python_binary_path = sys.executable
else:
python_binary_path = bpy.app.binary_path_python
environment.setup(DEPENDENCIES, python_binary_path)
from . import presence
from . import operators
from . import ui
@ -78,7 +74,7 @@ def register():
ui.register()
except ModuleNotFoundError as e:
raise Exception(module_error_msg)
logging.error(module_error_msg)
logging.error(e)
bpy.types.WindowManager.session = bpy.props.PointerProperty(
type=preferences.SessionProps)

View File

@ -105,9 +105,10 @@ class BlCamera(BlDatablock):
]
return dumper.dump(instance)
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
for background in self.instance.background_images:
for background in datablock.background_images:
if background.image:
deps.append(background.image)

View File

@ -134,5 +134,6 @@ class BlCollection(BlDatablock):
return data
def _resolve_deps_implementation(self):
return resolve_collection_dependencies(self.instance)
@staticmethod
def _resolve_deps_implementation(datablock):
return resolve_collection_dependencies(datablock)

View File

@ -222,10 +222,10 @@ class BlCurve(BlDatablock):
return data
def _resolve_deps_implementation(self):
# TODO: resolve material
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
curve = self.instance
curve = datablock
if isinstance(curve, T.TextCurve):
deps.extend([
@ -234,7 +234,7 @@ class BlCurve(BlDatablock):
curve.font_bold_italic,
curve.font_italic])
for material in self.instance.materials:
for material in curve.materials:
if material:
deps.append(material)

View File

@ -201,18 +201,18 @@ class BlDatablock(ReplicatedDatablock):
def _load_implementation(self, data, target):
raise NotImplementedError
def resolve_deps(self):
def resolve_deps(self, datablock):
dependencies = []
if has_action(self.instance):
dependencies.append(self.instance.animation_data.action)
if has_action(datablock):
dependencies.append(datablock.animation_data.action)
if not self.is_library:
dependencies.extend(self._resolve_deps_implementation())
dependencies.extend(self._resolve_deps_implementation(datablock))
logging.debug(f"{self.instance} dependencies: {dependencies}")
return dependencies
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
return []

View File

@ -62,11 +62,12 @@ class BlFont(BlDatablock):
def diff(self):
return False
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
if self.instance.filepath and self.instance.filepath != '<builtin>':
ensure_unpacked(self.instance)
if datablock.filepath and datablock.filepath != '<builtin>':
ensure_unpacked(datablock)
deps.append(Path(bpy.path.abspath(self.instance.filepath)))
deps.append(Path(bpy.path.abspath(datablock.filepath)))
return deps

View File

@ -290,10 +290,11 @@ class BlGpencil(BlDatablock):
data["eval_frame"] = bpy.context.scene.frame_current
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
for material in self.instance.materials:
for material in datablock.materials:
deps.append(material)
return deps

View File

@ -101,23 +101,24 @@ class BlImage(BlDatablock):
else:
return False
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
if self.instance.packed_file:
filename = Path(bpy.path.abspath(self.instance.filepath)).name
self.instance.filepath_raw = get_filepath(filename)
self.instance.save()
if datablock.packed_file:
filename = Path(bpy.path.abspath(datablock.filepath)).name
datablock.filepath_raw = get_filepath(filename)
datablock.save()
# An image can't be unpacked to the modified path
# TODO: make a bug report
self.instance.unpack(method="REMOVE")
datablock.unpack(method="REMOVE")
elif self.instance.source == "GENERATED":
filename = f"{self.instance.name}.png"
self.instance.filepath = get_filepath(filename)
self.instance.save()
elif datablock.source == "GENERATED":
filename = f"{datablock.name}.png"
datablock.filepath = get_filepath(filename)
datablock.save()
if self.instance.filepath:
deps.append(Path(bpy.path.abspath(self.instance.filepath)))
if datablock.filepath:
deps.append(Path(bpy.path.abspath(datablock.filepath)))
return deps

View File

@ -469,13 +469,12 @@ class BlMaterial(BlDatablock):
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
# TODO: resolve node group deps
deps = []
if self.instance.use_nodes:
deps.extend(get_node_tree_dependencies(self.instance.node_tree))
if self.is_library:
deps.append(self.instance.library)
if datablock.use_nodes:
deps.extend(get_node_tree_dependencies(datablock.node_tree))
return deps

View File

@ -166,10 +166,11 @@ class BlMesh(BlDatablock):
data['materials'] = dump_materials_slots(instance.materials)
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
for material in self.instance.materials:
for material in datablock.materials:
if material:
deps.append(material)

View File

@ -41,5 +41,6 @@ class BlNodeGroup(BlDatablock):
def _dump_implementation(self, data, instance=None):
return dump_node_tree(instance)
def _resolve_deps_implementation(self):
return get_node_tree_dependencies(self.instance)
@staticmethod
def _resolve_deps_implementation(datablock):
return get_node_tree_dependencies(datablock)

View File

@ -565,25 +565,23 @@ class BlObject(BlDatablock):
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
# Avoid Empty case
if self.instance.data:
deps.append(self.instance.data)
if datablock.data:
deps.append(datablock.data)
if self.is_library:
deps.append(self.instance.library)
if datablock.parent :
deps.append(datablock.parent)
if self.instance.parent :
deps.append(self.instance.parent)
if self.instance.instance_type == 'COLLECTION':
if datablock.instance_type == 'COLLECTION':
# TODO: uuid based
deps.append(self.instance.instance_collection)
deps.append(datablock.instance_collection)
if self.instance.modifiers:
deps.extend(find_textures_dependencies(self.instance.modifiers))
deps.extend(find_geometry_nodes(self.instance.modifiers))
if datablock.modifiers:
deps.extend(find_textures_dependencies(datablock.modifiers))
deps.extend(find_geometry_nodes(datablock.modifiers))
return deps

View File

@ -513,22 +513,23 @@ class BlScene(BlDatablock):
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
# Master Collection
deps.extend(resolve_collection_dependencies(self.instance.collection))
deps.extend(resolve_collection_dependencies(datablock.collection))
# world
if self.instance.world:
deps.append(self.instance.world)
if datablock.world:
deps.append(datablock.world)
# annotations
if self.instance.grease_pencil:
deps.append(self.instance.grease_pencil)
if datablock.grease_pencil:
deps.append(datablock.grease_pencil)
# Sequences
vse = self.instance.sequence_editor
vse = datablock.sequence_editor
if vse:
for sequence in vse.sequences_all:
if sequence.type == 'MOVIE' and sequence.filepath:

View File

@ -57,11 +57,12 @@ class BlSound(BlDatablock):
'name': instance.name
}
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
if self.instance.filepath and self.instance.filepath != '<builtin>':
ensure_unpacked(self.instance)
if datablock.filepath and datablock.filepath != '<builtin>':
ensure_unpacked(datablock)
deps.append(Path(bpy.path.abspath(self.instance.filepath)))
deps.append(Path(bpy.path.abspath(datablock.filepath)))
return deps

View File

@ -60,11 +60,11 @@ class BlSpeaker(BlDatablock):
return dumper.dump(instance)
def _resolve_deps_implementation(self):
# TODO: resolve material
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
sound = self.instance.sound
sound = datablock.sound
if sound:
deps.append(sound)

View File

@ -61,11 +61,11 @@ class BlTexture(BlDatablock):
return data
def _resolve_deps_implementation(self):
# TODO: resolve material
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
image = getattr(self.instance,"image", None)
image = getattr(datablock,"image", None)
if image:
deps.append(image)

View File

@ -69,15 +69,15 @@ class BlVolume(BlDatablock):
return data
def _resolve_deps_implementation(self):
# TODO: resolve material
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
external_vdb = Path(bpy.path.abspath(self.instance.filepath))
external_vdb = Path(bpy.path.abspath(datablock.filepath))
if external_vdb.exists() and not external_vdb.is_dir():
deps.append(external_vdb)
for material in self.instance.materials:
for material in datablock.materials:
if material:
deps.append(material)

View File

@ -62,11 +62,11 @@ class BlWorld(BlDatablock):
return data
def _resolve_deps_implementation(self):
@staticmethod
def _resolve_deps_implementation(datablock):
deps = []
if self.instance.use_nodes:
deps.extend(get_node_tree_dependencies(self.instance.node_tree))
if self.is_library:
deps.append(self.instance.library)
if datablock.use_nodes:
deps.extend(get_node_tree_dependencies(datablock.node_tree))
return deps

@ -0,0 +1 @@
Subproject commit 63093ecf453a6e253c828ae15e5a3281cfcc2358

View File

@ -210,8 +210,7 @@ class SessionStartOperator(bpy.types.Operator):
bpy_protocol.register_type(
type_module_class.bl_class,
type_module_class,
check_common=type_module_class.bl_check_common)
type_module_class)
deleyables.append(timers.ApplyTimer(timeout=settings.depsgraph_update_rate))