refactoring: user metadata progress

This commit is contained in:
Swann 2020-01-21 23:24:44 +01:00
parent 011eba8cc9
commit 73a2bb56e2
No known key found for this signature in database
GPG Key ID: B880407E0F5F413E
3 changed files with 52 additions and 26 deletions

View File

@ -151,7 +151,8 @@ class DynamicRightSelectTimer(Timer):
# Fix deselection until right managment refactoring (with Roles concepts)
if len(current_selection) == 0 and self._right_strategy == RP_COMMON:
owned_keys = repo.list(filter_owner=settings.username)
owned_keys = repo.list(
filter_owner=settings.username)
for key in owned_keys:
node = repo.get(uuid=key)
if not isinstance(node, BlUser):
@ -182,21 +183,20 @@ class Draw(Delayable):
class DrawClient(Draw):
def execute(self):
repo = operators.client
if repo and presence.renderer:
session = operators.client
if session and presence.renderer:
settings = bpy.context.window_manager.session
client_list = [key for key in repo.list(filter=BlUser) if
key != settings.user_uuid]
users = session.online_users
for cli in client_list:
cli_ref = repo.get(uuid=cli)
if cli_ref.data.get('name'):
if settings.presence_show_selected:
presence.renderer.draw_client_selection(
cli_ref.data['name'], cli_ref.data['color'], cli_ref.data['selected_objects'])
for user in users.values():
metadata = user.get('metadata')
# if settings.presence_show_selected:
# presence.renderer.draw_client_selection(
# cli_ref.data['name'], cli_ref.data['color'], cli_ref.data['selected_objects'])
if settings.presence_show_user:
presence.renderer.draw_client_camera(
cli_ref.data['name'], cli_ref.data['location'], cli_ref.data['color'])
user['id'], metadata['view_corners'], metadata['color'])
class ClientUpdate(Timer):
@ -206,9 +206,26 @@ class ClientUpdate(Timer):
super().__init__(timout)
def execute(self):
settings = bpy.context.window_manager.session
session_info = bpy.context.window_manager.session
session = operators.client
if self._client_uuid and operators.client:
client = operators.client.get(uuid=self._client_uuid)
local_user = operators.client.online_users[session_info.username]
metadata = {
'view_corners': presence.get_view_corners(),
'view_matrix': presence.get_view_matrix(),
'color': (settings.client_color.r,
settings.client_color.g,
settings.client_color.b,
1),
'selected_objects':utils.get_selected_objects(bpy.context.scene)
}
session.update_user_metadata(metadata)
logger.info("{}".format(local_user))
if client:
client.pointer.update_location()

@ -1 +1 @@
Subproject commit f70b4f67a6685c4c060ef29036ba3b111590e913
Subproject commit d5a24da5fcbd2d697f9384a4638486c50d62db08

View File

@ -69,7 +69,7 @@ def get_default_bbox(obj, radius):
return [(point.x, point.y, point.z)
for point in bbox_corners]
def get_client_cam_points():
def get_view_corners():
area, region, rv3d = view3d_find()
v1 = [0, 0, 0]
@ -113,6 +113,15 @@ def get_bb_coords_from_obj(object, parent=None):
return [(point.x, point.y, point.z)
for point in bbox_corners]
def get_view_matrix():
area, region, rv3d = view3d_find()
if area and region and rv3d:
matrix_dumper = utils.dump_anything.Dumper()
return matrix_dumper.dump(rv3d.view_matrix)
class User():
def __init__(self, username=None, color=(0, 0, 0, 1)):
self.is_dirty = False
@ -124,11 +133,11 @@ class User():
self.view_matrix = None
def update_location(self):
current_coords = get_client_cam_points()
current_coords = get_view_corners()
area, region, rv3d = view3d_find()
if area and region and rv3d:
current_coords = list(get_client_cam_points())
current_coords = list(get_view_corners())
if current_coords and self.location != current_coords:
self.location = current_coords