diff --git a/multi_user/libs/replication b/multi_user/libs/replication index f4bbe3b..de24d35 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit f4bbe3b897c98ed7749a99dad12a1789d1fa1cb6 +Subproject commit de24d35afeef583802eca1fe002b3efc171a7ffe diff --git a/multi_user/presence.py b/multi_user/presence.py index eb04970..3c13e1d 100644 --- a/multi_user/presence.py +++ b/multi_user/presence.py @@ -56,6 +56,18 @@ def get_target_far(region, rv3d, coord, distance): return [target.x, target.y, target.z] +def get_default_bbox(obj, radius): + coords = [ + (-radius, -radius, -radius), (+radius, -radius, -radius), + (-radius, +radius, -radius), (+radius, +radius, -radius), + (-radius, -radius, +radius), (+radius, -radius, +radius), + (-radius, +radius, +radius), (+radius, +radius, +radius)] + + base = obj.matrix_world + bbox_corners = [base @ mathutils.Vector(corner) for corner in coords] + + return [(point.x, point.y, point.z) + for point in bbox_corners] def get_client_cam_points(): area, region, rv3d = view3d_find() @@ -181,7 +193,7 @@ class DrawFactory(object): self.d3d_items.clear() self.d2d_items.clear() - def flush_selection(self, user): + def flush_selection(self, user=None): key_to_remove = [] select_key = "{}_select".format(user) if user else "select" for k in self.d3d_items.keys(): @@ -211,36 +223,46 @@ class DrawFactory(object): for select_ob in client_selection: drawable_key = "{}_select_{}".format(client_uuid, select_ob) - 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) - ) - ob = utils.find_from_attr("uuid",select_ob,bpy.data.objects) + + ob = utils.find_from_attr("uuid", select_ob, bpy.data.objects) if not ob: return - item_to_draw = [] if ob.type == 'EMPTY': - # Child case - + # TODO: Child case # Collection instance case if ob.instance_collection: for obj in ob.instance_collection.objects: if obj.type == 'MESH': - self.append_3d_item( + self.append_3d_item( drawable_key, client_color, get_bb_coords_from_obj(obj, parent=ob), indices) - if ob.type == 'MESH': + if ob.type in ['MESH','META']: + 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)) + self.append_3d_item( drawable_key, client_color, get_bb_coords_from_obj(ob), indices) - + else: + 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)) + + self.append_3d_item( + drawable_key, + client_color, + get_default_bbox(ob, ob.scale.x), + indices) + def append_3d_item(self,key,color, coords, indices): shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') color = color @@ -277,6 +299,9 @@ class DrawFactory(object): def draw3d_callback(self): bgl.glLineWidth(1.5) bgl.glEnable(bgl.GL_DEPTH_TEST) + bgl.glEnable(bgl.GL_BLEND) + bgl.glEnable(bgl.GL_LINE_SMOOTH) + try: for shader, batch, color in self.d3d_items.values(): shader.bind()