fix(rcf): hide select on selected objects
This commit is contained in:
@ -470,42 +470,43 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
index = 0
|
index = 0
|
||||||
index_object = 0
|
index_object = 0
|
||||||
for key, values in client.property_map.items():
|
for key, values in client.property_map.items():
|
||||||
if values.mtype == "object":
|
if values.body is not None:
|
||||||
if values.id != client.id:
|
if values.mtype == "object":
|
||||||
indices = (
|
if values.id != client.id:
|
||||||
(0, 1), (1, 2), (2, 3), (0, 3),
|
indices = (
|
||||||
(4, 5), (5, 6), (6, 7), (4, 7),
|
(0, 1), (1, 2), (2, 3), (0, 3),
|
||||||
(0, 4), (1, 5), (2, 6), (3, 7)
|
(4, 5), (5, 6), (6, 7), (4, 7),
|
||||||
)
|
(0, 4), (1, 5), (2, 6), (3, 7)
|
||||||
|
)
|
||||||
|
|
||||||
ob = bpy.data.objects[values.body]
|
ob = bpy.data.objects[values.body]
|
||||||
|
|
||||||
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
||||||
|
|
||||||
coords= [(point.x,point.y,point.z) for point in bbox_corners]
|
coords= [(point.x,point.y,point.z) for point in bbox_corners]
|
||||||
|
|
||||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
batch = batch_for_shader(
|
batch = batch_for_shader(
|
||||||
shader, 'LINES', {"pos": coords}, indices=indices)
|
shader, 'LINES', {"pos": coords}, indices=indices)
|
||||||
|
|
||||||
self.draw_items.append(
|
self.draw_items.append(
|
||||||
(shader, batch, (None,None), COLOR_TABLE[index_object]))
|
(shader, batch, (None,None), COLOR_TABLE[index_object]))
|
||||||
|
|
||||||
index_object+=1
|
index_object+=1
|
||||||
|
|
||||||
if values.mtype == "client":
|
if values.mtype == "client":
|
||||||
if values.id != client.id:
|
if values.id != client.id:
|
||||||
indices = (
|
indices = (
|
||||||
(1, 3), (2, 1), (3, 0), (2, 0)
|
(1, 3), (2, 1), (3, 0), (2, 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
batch = batch_for_shader(
|
batch = batch_for_shader(
|
||||||
shader, 'LINES', {"pos": values.body}, indices=indices)
|
shader, 'LINES', {"pos": values.body}, indices=indices)
|
||||||
|
|
||||||
self.draw_items.append(
|
self.draw_items.append(
|
||||||
(shader, batch, (values.body[1], values.id.decode()), COLOR_TABLE[index]))
|
(shader, batch, (values.body[1], values.id.decode()), COLOR_TABLE[index]))
|
||||||
index+=1
|
index+=1
|
||||||
|
|
||||||
|
|
||||||
def draw3d_callback(self):
|
def draw3d_callback(self):
|
||||||
@ -528,6 +529,17 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
def is_object_selected(self,obj):
|
||||||
|
#TODO: function to find occurence
|
||||||
|
global client
|
||||||
|
|
||||||
|
for k,v in client.property_map.items():
|
||||||
|
if v.mtype == 'object':
|
||||||
|
if client.id != v.id:
|
||||||
|
if obj.name in v.body:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def modal(self, context, event):
|
def modal(self, context, event):
|
||||||
if context.area:
|
if context.area:
|
||||||
@ -550,27 +562,24 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
|
|
||||||
client.push_update(key, 'client', current_coords)
|
client.push_update(key, 'client', current_coords)
|
||||||
|
|
||||||
# Active object bounding box
|
# Hide selected objects
|
||||||
if len(context.selected_objects) > 0:
|
for object in context.scene.objects:
|
||||||
for object in context.scene.objects:
|
if self.is_object_selected(object):
|
||||||
# TODO: fix
|
object.hide_select = True
|
||||||
try:
|
else:
|
||||||
#TODO: function to find occurence
|
object.hide_select = False
|
||||||
for k,v in client.property_map.items():
|
|
||||||
if v.mtype == 'object':
|
|
||||||
if client.id.decode() not in k:
|
|
||||||
if object.name in v.body:
|
|
||||||
object.hide_select = True
|
|
||||||
break
|
|
||||||
|
|
||||||
object.hide_select = False
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
# 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 :
|
if session.active_object is not context.selected_objects[0] or session.active_object.is_evaluated :
|
||||||
session.active_object = context.selected_objects[0]
|
session.active_object = context.selected_objects[0]
|
||||||
key = "net/objects/{}".format(client.id.decode())
|
key = "net/objects/{}".format(client.id.decode())
|
||||||
client.push_update(key, 'object', session.active_object.name)
|
client.push_update(key, 'object', session.active_object.name)
|
||||||
|
elif len(context.selected_objects) == 0 and session.active_object:
|
||||||
|
session.active_object = None
|
||||||
|
key = "net/objects/{}".format(client.id.decode())
|
||||||
|
client.push_update(key, 'object', None)
|
||||||
|
|
||||||
# Draw clients
|
# Draw clients
|
||||||
if len(client.property_map) > 0:
|
if len(client.property_map) > 0:
|
||||||
|
@ -120,7 +120,7 @@ class SessionPropertiesPanel(bpy.types.Panel):
|
|||||||
item_box = area_msg.box()
|
item_box = area_msg.box()
|
||||||
detail_item_box = item_box.row()
|
detail_item_box = item_box.row()
|
||||||
# detail_item_box = item_box.row()
|
# detail_item_box = item_box.row()
|
||||||
detail_item_box.label(text="{} ({}) ".format(key, values.mtype, values.id.decode()))
|
detail_item_box.label(text="{} ({}) {} ".format(key, values.mtype, values.id.decode()))
|
||||||
detail_item_box.operator("session.remove_prop",text="",icon="X").property_path = key
|
detail_item_box.operator("session.remove_prop",text="",icon="X").property_path = key
|
||||||
else:
|
else:
|
||||||
area_msg.label(text="Empty")
|
area_msg.label(text="Empty")
|
||||||
|
Reference in New Issue
Block a user