From 36b556156938a40b765ce5d1a000262c131e6bb5 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Mon, 30 Sep 2019 16:12:19 +0200 Subject: [PATCH] fix: presence selection error --- bl_types/bl_user.py | 2 ++ operators.py | 2 +- presence.py | 41 ++++++++++++++++++++--------------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/bl_types/bl_user.py b/bl_types/bl_user.py index b1bafab..de1bebb 100644 --- a/bl_types/bl_user.py +++ b/bl_types/bl_user.py @@ -44,6 +44,8 @@ class BlUser(BlDatablock): def diff(self): + if not self.pointer: + return False if self.pointer.is_dirty: self.pointer.is_dirty = False return True diff --git a/operators.py b/operators.py index 8e29b22..cdb96fd 100644 --- a/operators.py +++ b/operators.py @@ -126,7 +126,7 @@ class SessionStartOperator(bpy.types.Operator): settings.client_color.b, 1), ) - settings.user_uuid = client.add(usr) + settings.user_uuid = client.add(usr,owner=settings.username) client.commit(settings.user_uuid) delayables.append(delayable.ClientUpdate( diff --git a/presence.py b/presence.py index 848c889..97ed7d0 100644 --- a/presence.py +++ b/presence.py @@ -187,12 +187,10 @@ class DrawFactory(object): self.d2d_items.clear() def draw_client_selection(self, client_uuid, client_color, client_selection): - local_username = bpy.context.window_manager.session.username - - self.flush_selection() - - if client_selection: + local_user = bpy.context.window_manager.session.user_uuid + if client_selection and local_user != client_uuid: + self.flush_selection() for select_ob in client_selection: drawable_key = "{}_select_{}".format(client_uuid, select_ob) indices = ( @@ -220,27 +218,28 @@ class DrawFactory(object): def draw_client_camera(self, client_uuid, client_location, client_color): if client_location: - local_username = bpy.context.window_manager.session.username + local_user = bpy.context.window_manager.session.user_uuid - try: - indices = ( - (1, 3), (2, 1), (3, 0), - (2, 0), (4, 5), (1, 6), - (2, 6), (3, 6), (0, 6) - ) + if local_user != client_uuid: + try: + indices = ( + (1, 3), (2, 1), (3, 0), + (2, 0), (4, 5), (1, 6), + (2, 6), (3, 6), (0, 6) + ) - shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') - position = [tuple(coord) for coord in client_location] - color = client_color + shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + position = [tuple(coord) for coord in client_location] + color = client_color - batch = batch_for_shader( - shader, 'LINES', {"pos": position}, indices=indices) + batch = batch_for_shader( + shader, 'LINES', {"pos": position}, indices=indices) - self.d3d_items[client_uuid] = (shader, batch, color) - self.d2d_items[client_uuid] = (position[1], client_uuid, color) + self.d3d_items[client_uuid] = (shader, batch, color) + self.d2d_items[client_uuid] = (position[1], client_uuid, color) - except Exception as e: - logger.error("Draw client exception {}".format(e)) + except Exception as e: + logger.error("Draw client exception {}".format(e)) def draw3d_callback(self): bgl.glLineWidth(1.5)