Compare commits
3 Commits
215-annota
...
220-batch-
Author | SHA1 | Date | |
---|---|---|---|
467e98906e | |||
64a25f94a3 | |||
e6996316be |
@ -29,6 +29,7 @@ from .bl_datablock import resolve_datablock_from_uuid
|
||||
from .bl_action import dump_animation_data, load_animation_data, resolve_animation_dependencies
|
||||
from ..utils import get_preferences
|
||||
from ..timers import is_annotating
|
||||
from .bl_material import load_materials_slots, dump_materials_slots
|
||||
|
||||
STROKE_POINT = [
|
||||
'co',
|
||||
@ -229,10 +230,10 @@ class BlGpencil(ReplicatedDatablock):
|
||||
|
||||
@staticmethod
|
||||
def load(data: dict, datablock: object):
|
||||
datablock.materials.clear()
|
||||
if "materials" in data.keys():
|
||||
for mat in data['materials']:
|
||||
datablock.materials.append(bpy.data.materials[mat])
|
||||
# MATERIAL SLOTS
|
||||
src_materials = data.get('materials', None)
|
||||
if src_materials:
|
||||
load_materials_slots(src_materials, datablock.materials)
|
||||
|
||||
loader = Loader()
|
||||
loader.load(datablock, data)
|
||||
@ -260,7 +261,6 @@ class BlGpencil(ReplicatedDatablock):
|
||||
dumper = Dumper()
|
||||
dumper.depth = 2
|
||||
dumper.include_filter = [
|
||||
'materials',
|
||||
'name',
|
||||
'zdepth_offset',
|
||||
'stroke_thickness_space',
|
||||
@ -268,7 +268,7 @@ class BlGpencil(ReplicatedDatablock):
|
||||
'stroke_depth_order'
|
||||
]
|
||||
data = dumper.dump(datablock)
|
||||
|
||||
data['materials'] = dump_materials_slots(datablock.materials)
|
||||
data['layers'] = {}
|
||||
|
||||
for layer in datablock.layers:
|
||||
|
@ -387,11 +387,10 @@ def load_materials_slots(src_materials: list, dst_materials: bpy.types.bpy_prop_
|
||||
|
||||
for mat_uuid, mat_name in src_materials:
|
||||
mat_ref = None
|
||||
if mat_uuid is not None:
|
||||
if mat_uuid:
|
||||
mat_ref = get_datablock_from_uuid(mat_uuid, None)
|
||||
else:
|
||||
mat_ref = bpy.data.materials[mat_name]
|
||||
|
||||
dst_materials.append(mat_ref)
|
||||
|
||||
|
||||
|
Submodule multi_user/libs/replication updated: ff88725991...fb70cc135b
@ -179,7 +179,7 @@ class AnnotationUpdates(Timer):
|
||||
class DynamicRightSelectTimer(Timer):
|
||||
def __init__(self, timeout=.1):
|
||||
super().__init__(timeout)
|
||||
self._last_selection = []
|
||||
self._last_selection = set()
|
||||
self._user = None
|
||||
|
||||
def execute(self):
|
||||
@ -191,52 +191,46 @@ class DynamicRightSelectTimer(Timer):
|
||||
self._user = session.online_users.get(settings.username)
|
||||
|
||||
if self._user:
|
||||
current_selection = utils.get_selected_objects(
|
||||
current_selection = set(utils.get_selected_objects(
|
||||
bpy.context.scene,
|
||||
bpy.data.window_managers['WinMan'].windows[0].view_layer
|
||||
)
|
||||
))
|
||||
if current_selection != self._last_selection:
|
||||
obj_common = [
|
||||
o for o in self._last_selection if o not in current_selection]
|
||||
obj_ours = [
|
||||
o for o in current_selection if o not in self._last_selection]
|
||||
to_lock = list(current_selection.difference(self._last_selection))
|
||||
to_release = list(self._last_selection.difference(current_selection))
|
||||
instances_to_lock = list()
|
||||
|
||||
# change old selection right to common
|
||||
for obj in obj_common:
|
||||
node = session.repository.graph.get(obj)
|
||||
for node_id in to_lock:
|
||||
node = session.repository.graph.get(node_id)
|
||||
instance_mode = node.data.get('instance_type')
|
||||
if instance_mode and instance_mode == 'COLLECTION':
|
||||
to_lock.remove(node_id)
|
||||
instances_to_lock.append(node_id)
|
||||
if instances_to_lock:
|
||||
try:
|
||||
porcelain.lock(session.repository,
|
||||
instances_to_lock,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=False)
|
||||
except NonAuthorizedOperationError as e:
|
||||
logging.warning(e)
|
||||
|
||||
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
||||
recursive = True
|
||||
if node.data and 'instance_type' in node.data.keys():
|
||||
recursive = node.data['instance_type'] != 'COLLECTION'
|
||||
try:
|
||||
porcelain.unlock(session.repository,
|
||||
node.uuid,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=recursive)
|
||||
except NonAuthorizedOperationError:
|
||||
logging.warning(
|
||||
f"Not authorized to change {node} owner")
|
||||
|
||||
# change new selection to our
|
||||
for obj in obj_ours:
|
||||
node = session.repository.graph.get(obj)
|
||||
|
||||
if node and node.owner == RP_COMMON:
|
||||
recursive = True
|
||||
if node.data and 'instance_type' in node.data.keys():
|
||||
recursive = node.data['instance_type'] != 'COLLECTION'
|
||||
|
||||
try:
|
||||
porcelain.lock(session.repository,
|
||||
node.uuid,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=recursive)
|
||||
except NonAuthorizedOperationError:
|
||||
logging.warning(
|
||||
f"Not authorized to change {node} owner")
|
||||
else:
|
||||
return
|
||||
if to_release:
|
||||
try:
|
||||
porcelain.unlock(session.repository,
|
||||
to_release,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=True)
|
||||
except NonAuthorizedOperationError as e:
|
||||
logging.warning(e)
|
||||
if to_lock:
|
||||
try:
|
||||
porcelain.lock(session.repository,
|
||||
to_lock,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=True)
|
||||
except NonAuthorizedOperationError as e:
|
||||
logging.warning(e)
|
||||
|
||||
self._last_selection = current_selection
|
||||
|
||||
@ -250,17 +244,16 @@ class DynamicRightSelectTimer(Timer):
|
||||
# Fix deselection until right managment refactoring (with Roles concepts)
|
||||
if len(current_selection) == 0 :
|
||||
owned_keys = [k for k, v in session.repository.graph.items() if v.owner==settings.username]
|
||||
for key in owned_keys:
|
||||
node = session.repository.graph.get(key)
|
||||
if owned_keys:
|
||||
try:
|
||||
porcelain.unlock(session.repository,
|
||||
key,
|
||||
owned_keys,
|
||||
ignore_warnings=True,
|
||||
affect_dependencies=True)
|
||||
except NonAuthorizedOperationError:
|
||||
logging.warning(
|
||||
f"Not authorized to change {key} owner")
|
||||
except NonAuthorizedOperationError as e:
|
||||
logging.warning(e)
|
||||
|
||||
# Objects selectability
|
||||
for obj in bpy.data.objects:
|
||||
object_uuid = getattr(obj, 'uuid', None)
|
||||
if object_uuid:
|
||||
|
Reference in New Issue
Block a user