feat: ground work for sequence support

This commit is contained in:
Swann 2020-10-30 16:58:18 +01:00
parent 66e55a7eec
commit 0bad6895da
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
3 changed files with 76 additions and 16 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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 <https://www.gnu.org/licenses/>.
#
# ##### 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