From 4dd932fc56967d3a998b5d800129a5a139f6a33d Mon Sep 17 00:00:00 2001 From: Swann Date: Wed, 21 Oct 2020 17:23:59 +0200 Subject: [PATCH] fix: empty and light display broken --- multi_user/presence.py | 47 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/multi_user/presence.py b/multi_user/presence.py index b885013..9f6523f 100644 --- a/multi_user/presence.py +++ b/multi_user/presence.py @@ -300,41 +300,38 @@ class UserSelectionWidget(Widget): ob = find_from_attr("uuid", select_ob, bpy.data.objects) if not ob: return - - position = None - if ob.type == 'EMPTY': - # TODO: Child case - # Collection instance case - indices = ( - (0, 1), (1, 2), (2, 3), (0, 3), - (4, 5), (5, 6), (6, 7), (4, 7), - (0, 4), (1, 5), (2, 6), (3, 7)) - if ob.instance_collection: - for obj in ob.instance_collection.objects: - if obj.type == 'MESH' and hasattr(obj, 'bound_box'): - positions = get_bb_coords_from_obj(obj, instance=ob) - break + vertex_pos = bbox_from_obj(ob, 1.0) + vertex_indices = ((0, 1), (0, 2), (1, 3), (2, 3), + (4, 5), (4, 6), (5, 7), (6, 7), + (0, 4), (1, 5), (2, 6), (3, 7)) + + if ob.instance_collection: + for obj in ob.instance_collection.objects: + if obj.type == 'MESH' and hasattr(obj, 'bound_box'): + vertex_pos = get_bb_coords_from_obj(obj, instance=ob) + break + elif ob.type == 'EMPTY': + vertex_pos = bbox_from_obj(ob, ob.empty_display_size) + elif ob.type == 'LIGHT': + vertex_pos = bbox_from_obj(ob, ob.data.shadow_soft_size) + elif ob.type == 'LIGHT_PROBE': + vertex_pos = bbox_from_obj(ob, ob.data.influence_distance) + elif ob.type == 'CAMERA': + vertex_pos = bbox_from_obj(ob, ob.data.display_size) elif hasattr(ob, 'bound_box'): - indices = ( + vertex_indices = ( (0, 1), (1, 2), (2, 3), (0, 3), (4, 5), (5, 6), (6, 7), (4, 7), (0, 4), (1, 5), (2, 6), (3, 7)) - positions = get_bb_coords_from_obj(ob) - if positions is None: - indices = ( - (0, 1), (0, 2), (1, 3), (2, 3), - (4, 5), (4, 6), (5, 7), (6, 7), - (0, 4), (1, 5), (2, 6), (3, 7)) - - positions = bbox_from_obj(ob, ob.scale.x) + vertex_pos = get_bb_coords_from_obj(ob) shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader( shader, 'LINES', - {"pos": positions}, - indices=indices) + {"pos": vertex_pos}, + indices=vertex_indices) shader.bind() shader.uniform_float("color", self.data.get('color'))