From 5819a40a3013e9c71b3f3194027149cb25392774 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Wed, 2 Oct 2019 14:02:30 +0200 Subject: [PATCH] fix: selection update error --- multi_user/operators.py | 20 +------------------- multi_user/presence.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/multi_user/operators.py b/multi_user/operators.py index cdb96fd..e34dd58 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -131,6 +131,7 @@ class SessionStartOperator(bpy.types.Operator): delayables.append(delayable.ClientUpdate( client_uuid=settings.user_uuid)) + delayables.append(delayable.DrawClient()) delayables.append(delayable.DynamicRightSelectTimer()) @@ -304,19 +305,6 @@ class SessionCommit(bpy.types.Operator): return {"FINISHED"} -@persistent -def redresh_handler(dummy): - """force to refresh client renderer - """ - global client - - if client: - user = client.get(uuid=bpy.context.window_manager.session.user_uuid) - - if hasattr(user, "pointer"): - user.pointer.is_dirty = True - - classes = ( SessionStartOperator, SessionStopOperator, @@ -333,9 +321,6 @@ def register(): for cls in classes: register_class(cls) - bpy.app.handlers.depsgraph_update_post.append(redresh_handler) - - def unregister(): global client @@ -347,8 +332,5 @@ def unregister(): for cls in reversed(classes): unregister_class(cls) - bpy.app.handlers.depsgraph_update_post.remove(redresh_handler) - - if __name__ == "__main__": register() diff --git a/multi_user/presence.py b/multi_user/presence.py index 97ed7d0..ef5145b 100644 --- a/multi_user/presence.py +++ b/multi_user/presence.py @@ -100,14 +100,15 @@ class User(): self.color = color self.location = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] self.selected_objects = [] + self.last_select_objects = [] def update_location(self): current_coords = get_client_cam_points() area, region, rv3d = view3d_find() - current_coords = get_client_cam_points() - if current_coords: - self.location = list(current_coords) + current_coords = list(get_client_cam_points()) + if current_coords and self.location != current_coords: + self.location = current_coords def update_selected_objects(self, context): self.selected_objects = utils.get_selected_objects(context.scene) @@ -166,10 +167,12 @@ class DrawFactory(object): self.d3d_items.clear() self.d2d_items.clear() - def flush_selection(self): + def flush_selection(self, user): key_to_remove = [] + select_key = "{}_select".format(user) if user else "select" for k in self.d3d_items.keys(): - if "select" in k: + + if select_key in k: key_to_remove.append(k) for k in key_to_remove: @@ -189,8 +192,9 @@ class DrawFactory(object): def draw_client_selection(self, client_uuid, client_color, client_selection): local_user = bpy.context.window_manager.session.user_uuid - if client_selection and local_user != client_uuid: - self.flush_selection() + if local_user != client_uuid: + self.flush_selection(client_uuid) + for select_ob in client_selection: drawable_key = "{}_select_{}".format(client_uuid, select_ob) indices = (