From b1f5ca5660e5d038b19c98bbf92b7ea1570a6245 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Mon, 25 Nov 2019 16:18:26 +0100 Subject: [PATCH] refactor: change has_action, has_driver location to utils fix: wrong transform update behavior for animated object Related to #39, #18 --- multi_user/bl_types/bl_datablock.py | 18 +++--------------- multi_user/bl_types/bl_object.py | 2 +- multi_user/libs/replication | 2 +- multi_user/utils.py | 10 ++++++++++ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/multi_user/bl_types/bl_datablock.py b/multi_user/bl_types/bl_datablock.py index 1befc21..1000bbd 100644 --- a/multi_user/bl_types/bl_datablock.py +++ b/multi_user/bl_types/bl_datablock.py @@ -6,18 +6,6 @@ from ..libs.replication.replication.data import ReplicatedDatablock from ..libs.replication.replication.constants import UP -def has_action(target): - return (hasattr(target, 'animation_data') - and target.animation_data - and target.animation_data.action) - - -def has_driver(target): - return (hasattr(target, 'animation_data') - and target.animation_data - and target.animation_data.drivers) - - def dump_driver(driver): dumper = utils.dump_anything.Dumper() dumper.depth = 6 @@ -91,12 +79,12 @@ class BlDatablock(ReplicatedDatablock): def dump(self, pointer=None): data = {} - if has_action(pointer): + if utils.has_action(pointer): dumper = utils.dump_anything.Dumper() dumper.include_filter = ['action'] data['animation_data'] = dumper.dump(pointer.animation_data) - if has_driver(pointer): + if utils.has_driver(pointer): dumped_drivers = {'animation_data':{'drivers': []}} for driver in pointer.animation_data.drivers: dumped_drivers['animation_data']['drivers'].append(dump_driver(driver)) @@ -133,7 +121,7 @@ class BlDatablock(ReplicatedDatablock): def resolve_dependencies(self): dependencies = [] - if has_action(self.pointer): + if utils.has_action(self.pointer): dependencies.append(self.pointer.animation_data.action) return dependencies diff --git a/multi_user/bl_types/bl_object.py b/multi_user/bl_types/bl_object.py index 589f5aa..9d629d0 100644 --- a/multi_user/bl_types/bl_object.py +++ b/multi_user/bl_types/bl_object.py @@ -141,7 +141,7 @@ class BlObject(BlDatablock): "instance_collection", "instance_type" ] - if not pointer.animation_data: + if not utils.has_action(pointer): dumper.include_filter.append('matrix_world') data = dumper.dump(pointer) diff --git a/multi_user/libs/replication b/multi_user/libs/replication index de24d35..56cf86f 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit de24d35afeef583802eca1fe002b3efc171a7ffe +Subproject commit 56cf86f05d1bb5fab9c3491945bbd5f7f207325b diff --git a/multi_user/utils.py b/multi_user/utils.py index 740394d..232424c 100644 --- a/multi_user/utils.py +++ b/multi_user/utils.py @@ -16,6 +16,16 @@ from .libs import dump_anything logger = logging.getLogger(__name__) logger.setLevel(logging.ERROR) +def has_action(target): + return (hasattr(target, 'animation_data') + and target.animation_data + and target.animation_data.action) + + +def has_driver(target): + return (hasattr(target, 'animation_data') + and target.animation_data + and target.animation_data.drivers) def find_from_attr(attr_name, attr_value, list): for item in list: