refactor: user metadata

This commit is contained in:
Swann Martinez 2020-01-22 15:15:44 +01:00
parent e253ccd52d
commit e22b036cc9
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
4 changed files with 20 additions and 13 deletions

View File

@ -192,8 +192,8 @@ class Draw(Delayable):
class DrawClient(Draw):
def execute(self):
session = getattr(operators, 'client')
renderer = getattr(presence, 'renderer')
session = getattr(operators, 'client', None)
renderer = getattr(presence, 'renderer', None)
if session and renderer:
settings = bpy.context.window_manager.session
users = session.online_users
@ -216,8 +216,10 @@ class ClientUpdate(Timer):
def execute(self):
settings = bpy.context.window_manager.session
session_info = bpy.context.window_manager.session
session = getattr(operators, 'client')
if session:
session = getattr(operators, 'client', None)
renderer = getattr(presence, 'renderer', None)
if session and renderer:
local_user = operators.client.online_users.get(
session_info.username)
if not local_user:
@ -240,6 +242,7 @@ class ClientUpdate(Timer):
elif current_view_corners != local_user_metadata['view_corners']:
logger.info('update user metadata')
local_user_metadata['view_corners'] = current_view_corners
local_user_metadata['view_matrix'] = presence.get_view_matrix()
session.update_user_metadata(local_user_metadata)
# sync online users
@ -249,9 +252,11 @@ class ClientUpdate(Timer):
for index, user in enumerate(ui_users):
if user.username not in session_users.keys():
ui_users.remove(index)
bpy.context.window_manager.session.presence_show_user = False
bpy.context.window_manager.session.presence_show_user = True
renderer.flush_selection()
renderer.flush_users()
break
for user in session_users:

@ -1 +1 @@
Subproject commit d8537c31c06cca5e6033740c3b50864760b60bfb
Subproject commit 2060bb6efb7ff56cad69a8645afe40706dd24682

View File

@ -271,10 +271,12 @@ class SessionSnapUserOperator(bpy.types.Operator):
area, region, rv3d = presence.view3d_find()
global client
target_client = client.get(uuid=self.target_client)
if target_client:
rv3d.view_matrix = mathutils.Matrix(
target_client.data['view_matrix'])
if client:
target_ref = client.online_users.get(self.target_client)
if target_ref:
rv3d.view_matrix = mathutils.Matrix(
target_ref['metadata']['view_matrix'])
else:
return {"CANCELLED"}

View File

@ -201,7 +201,7 @@ class SESSION_PT_user(bpy.types.Panel):
user_operations.operator(
"session.snapview",
text="",
icon='VIEW_CAMERA').target_client = online_users[selected_user].name
icon='VIEW_CAMERA').target_client = active_user.username
class SESSION_UL_users(bpy.types.UIList):