From 0bad6895da8f74c14bc01d1b37c8cc2b58f48546 Mon Sep 17 00:00:00 2001 From: Swann Date: Fri, 30 Oct 2020 16:58:18 +0100 Subject: [PATCH] feat: ground work for sequence support --- multi_user/bl_types/bl_collection.py | 18 +++++---- multi_user/bl_types/bl_scene.py | 17 +++++---- multi_user/bl_types/bl_strip.py | 57 ++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 multi_user/bl_types/bl_strip.py diff --git a/multi_user/bl_types/bl_collection.py b/multi_user/bl_types/bl_collection.py index 542f49f..12b4948 100644 --- a/multi_user/bl_types/bl_collection.py +++ b/multi_user/bl_types/bl_collection.py @@ -71,6 +71,15 @@ def load_collection_childrens(dumped_childrens, collection): if child_collection.uuid not in dumped_childrens: collection.children.unlink(child_collection) +def resolve_collection_dependencies(collection): + deps = [] + + for child in collection.children: + deps.append(child) + for object in collection.objects: + deps.append(object) + + return deps class BlCollection(BlDatablock): bl_id = "collections" @@ -124,11 +133,4 @@ class BlCollection(BlDatablock): return data def _resolve_deps_implementation(self): - deps = [] - - for child in self.instance.children: - deps.append(child) - for object in self.instance.objects: - deps.append(object) - - return deps + return resolve_collection_dependencies(self.instance) diff --git a/multi_user/bl_types/bl_scene.py b/multi_user/bl_types/bl_scene.py index 5597493..0d29755 100644 --- a/multi_user/bl_types/bl_scene.py +++ b/multi_user/bl_types/bl_scene.py @@ -21,7 +21,11 @@ import mathutils from .dump_anything import Loader, Dumper from .bl_datablock import BlDatablock -from .bl_collection import dump_collection_children, dump_collection_objects, load_collection_childrens, load_collection_objects +from .bl_collection import (dump_collection_children, + dump_collection_objects, + load_collection_childrens, + load_collection_objects, + resolve_collection_dependencies) from replication.constants import (DIFF_JSON, MODIFIED) from deepdiff import DeepDiff import logging @@ -382,13 +386,8 @@ class BlScene(BlDatablock): def _resolve_deps_implementation(self): deps = [] - # child collections - for child in self.instance.collection.children: - deps.append(child) - - # childs objects - for object in self.instance.collection.objects: - deps.append(object) + # Master Collection + deps.extend(resolve_collection_dependencies(self.instance.collection)) # world if self.instance.world: @@ -398,6 +397,8 @@ class BlScene(BlDatablock): if self.instance.grease_pencil: deps.append(self.instance.grease_pencil) + # Sequences + return deps def diff(self): diff --git a/multi_user/bl_types/bl_strip.py b/multi_user/bl_types/bl_strip.py new file mode 100644 index 0000000..4bad270 --- /dev/null +++ b/multi_user/bl_types/bl_strip.py @@ -0,0 +1,57 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ##### END GPL LICENSE BLOCK ##### + + +import bpy +import mathutils + +from .dump_anything import Loader, Dumper +from .bl_datablock import BlDatablock + + +class BlSequence(BlDatablock): + bl_id = "sequence" + bl_class = bpy.types.Sequence + bl_delay_refresh = 1 + bl_delay_apply = 1 + bl_automatic_push = True + bl_check_common = False + bl_icon = 'SEQUENCE' + + def _construct(self, data): + return bpy.data.cameras.new(data["name"]) + + def _load_implementation(self, data, target): + loader = Loader() + loader.load(target, data) + + def _dump_implementation(self, data, instance=None): + assert(instance) + + dumper = Dumper() + dumper.depth = 1 + data.update(dumper.dump(instance)) + + return data + + def _resolve_deps_implementation(self): + deps = [] + for background in self.instance.background_images: + if background.image: + deps.append(background.image) + + return deps