feat(rcf): bring back selected object lock

This commit is contained in:
Swann Martinez 2019-04-18 16:10:55 +02:00
parent 91611f01e2
commit 331b8794da
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
3 changed files with 70 additions and 48 deletions

View File

@ -108,7 +108,8 @@ class HUD(object):
name = client[0].split('/')[1]
local_username = bpy.context.scene.session_settings.username
if name != local_username and client[1]['active_objects']:
if name != local_username:
if client[1]['active_objects']:
for select_ob in client[1]['active_objects']:
indices = (
(0, 1), (1, 2), (2, 3), (0, 3),
@ -135,7 +136,8 @@ class HUD(object):
self.d3d_items["{}/{}".format(client[0],
select_ob)] = (shader, batch, color)
else:
self.d3d_items.clear()
def draw_clients(self):
clients = self.client.get("Client")

View File

@ -78,14 +78,15 @@ def load_client(client=None, data=None):
# localy_selected = get_selected_objects(C.scene)
# Draw client
client_data = data
# Load selected object
if data['active_objects']:
for obj in C.scene.objects:
if obj.name in data['active_objects']:
if client_data['active_objects'] and obj.name in client_data['active_objects']:
D.objects[obj.name].hide_select = True
else:
D.objects[obj.name].hide_select = False
pass
def load_mesh(target=None, data=None, create=False):

View File

@ -84,31 +84,48 @@ def update_selected_object(context):
global client_instance
session = bpy.context.scene.session_settings
username = bpy.context.scene.session_settings.username
client_key = "Client/{}".format(username)
client_data = client_instance.get(client_key)
# Active object bounding box
if len(context.selected_objects) > 0:
if session.active_object is not context.selected_objects[0] or session.active_object.is_evaluated:
session.active_object = context.selected_objects[0]
key = "net/objects/{}".format(client_instance.id.decode())
data = {}
data['color'] = [session.client_instance_color.r,
session.client_instance_color.g, session.client_instance_color.b]
data['object'] = session.active_object.name
client_instance.push_update(
key, 'client_instanceObject', data)
return True
elif len(context.selected_objects) == 0 and session.active_object:
session.active_object = None
data = {}
data['color'] = [session.client_instance_color.r,
session.client_instance_color.g, session.client_instance_color.b]
data['object'] = None
key = "net/objects/{}".format(client_instance.id.decode())
client_instance.push_update(key, 'client_instanceObject', data)
return True
for obj in context.selected_objects:
if obj.name not in client_data[0][1]['active_objects']:
client_data[0][1]['active_objects'] = helpers.get_selected_objects(context.scene)
return False
client_instance.set(client_key,client_data[0][1])
break
elif client_data[0][1]['active_objects']:
client_data[0][1]['active_objects'] = []
client_instance.set(client_key,client_data[0][1])
# if session.active_object is not context.selected_objects[0] or session.active_object.is_evaluated:
# session.active_object = context.selected_objects[0]
# key = "net/objects/{}".format(client_instance.id.decode())
# data = {}
# data['color'] = [session.client_instance_color.r,
# session.client_instance_color.g, session.client_instance_color.b]
# data['object'] = session.active_object.name
# client_instance.push_update(
# key, 'client_instanceObject', data)
# return True
# elif len(context.selected_objects) == 0 and session.active_object:
# session.active_object = None
# data = {}
# data['color'] = [session.client_instance_color.r,
# session.client_instance_color.g, session.client_instance_color.b]
# data['object'] = None
# key = "net/objects/{}".format(client_instance.id.decode())
# client_instance.push_update(key, 'client_instanceObject', data)
# return True
# return False
def init_datablocks():
@ -447,6 +464,8 @@ def depsgraph_update(scene):
if client_instance and client_instance.agent.is_alive():
updates = bpy.context.depsgraph.updates
update_selected_object(bpy.context)
if is_dirty(updates):
for update in ordered(updates):
if update[2] == "Master Collection":