feat: nested collection selection hihlight

This commit is contained in:
Swann Martinez
2019-10-14 17:44:19 +02:00
parent f84b441321
commit add01961f2

View File

@ -92,6 +92,13 @@ def get_client_2d(coords):
else: else:
return (0, 0) return (0, 0)
def get_bb_coords_from_obj(object, parent=None):
base = object.matrix_world if parent is None else parent.matrix_world
bbox_corners = [base @ mathutils.Vector(
corner) for corner in object.bound_box]
return [(point.x, point.y, point.z)
for point in bbox_corners]
class User(): class User():
def __init__(self, username=None, color=(0, 0, 0, 1)): def __init__(self, username=None, color=(0, 0, 0, 1)):
@ -206,17 +213,34 @@ class DrawFactory(object):
if not ob: if not ob:
return return
bbox_corners = [ob.matrix_world @ mathutils.Vector( item_to_draw = []
corner) for corner in ob.bound_box] if ob.type == 'EMPTY':
# Child case
coords = [(point.x, point.y, point.z) # Collection instance case
for point in bbox_corners] if ob.instance_collection:
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') for obj in ob.instance_collection.objects:
color = client_color if obj.type == 'MESH':
batch = batch_for_shader( self.append_3d_item(
shader, 'LINES', {"pos": coords}, indices=indices) drawable_key,
client_color,
get_bb_coords_from_obj(obj, parent=ob),
indices)
self.d3d_items[drawable_key] = (shader, batch, color) if ob.type == 'MESH':
self.append_3d_item(
drawable_key,
client_color,
get_bb_coords_from_obj(ob),
indices)
def append_3d_item(self,key,color, coords, indices):
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
color = color
batch = batch_for_shader(
shader, 'LINES', {"pos": coords}, indices=indices)
self.d3d_items[key] = (shader, batch, color)
def draw_client_camera(self, client_uuid, client_location, client_color): def draw_client_camera(self, client_uuid, client_location, client_color):
if client_location: if client_location: