fix: new mode display

This commit is contained in:
Fabian 2021-06-30 15:34:03 +02:00
parent 440a4cc1cd
commit a8f96581c5
3 changed files with 31 additions and 30 deletions

View File

@ -273,6 +273,13 @@ class SessionPrefs(bpy.types.AddonPreferences):
step=1,
subtype='PERCENTAGE',
)
presence_mode_distance: bpy.props.FloatProperty(
name="Distance mode visibilty",
description="Adjust the distance visibilty of user's mode",
min=0.1,
max=1000,
default=100,
)
conf_session_identity_expanded: bpy.props.BoolProperty(
name="Identity",
description="Identity",
@ -446,10 +453,11 @@ class SessionPrefs(bpy.types.AddonPreferences):
col = box.column(align=True)
col.prop(self, "presence_hud_scale", expand=True)
col.prop(self, "presence_hud_hpos", expand=True)
col.prop(self, "presence_hud_vpos", expand=True)
col.prop(self, "presence_mode_distance", expand=True)
if self.category == 'UPDATE':
from . import addon_updater_ops
addon_updater_ops.update_settings_ui(self, context)
@ -541,7 +549,7 @@ class SessionProps(bpy.types.PropertyGroup):
presence_show_mode: bpy.props.BoolProperty(
name="Show users current mode",
description='Enable user mode overlay ',
default=True,
default=False,
)
presence_show_far_user: bpy.props.BoolProperty(
name="Show users on different scenes",

View File

@ -417,6 +417,7 @@ class UserModeWidget(Widget):
username):
self.username = username
self.settings = bpy.context.window_manager.session
self.preferences = get_preferences()
@property
def data(self):
@ -441,49 +442,32 @@ class UserModeWidget(Widget):
self.settings.presence_show_mode and \
self.settings.enable_presence
def draw(self):
user_selection = self.data.get('selected_objects')
B = [1000,0]
A = [1000,0]
C = [1000,0]
location = self.data.get('view_corners')
positions = [tuple(coord) for coord in location]
viewport_coord = positions[6]
for select_obj in user_selection:
obj = find_from_attr("uuid", select_obj, bpy.data.objects)
if not obj:
return
else :
vertex_pos, vertex_indices = bbox_from_obj(obj)
mode_current = self.data.get('mode_current')
color = self.data.get('color')
origin_coord = project_to_screen(obj.location)
# A upper left corner
# B lower right corner
for vertex in range(len(vertex_pos)) :
coords = project_to_screen(vertex_pos[vertex])
if coords[0] < A[0]:
A[0] = coords[0]
if coords[1] > A[1]:
A[1] = coords[1]
if coords[0] > B[0]:
B[0] = coords[0]
if coords[1] < B[1]:
B[1] = coords[1]
distance_viewport_object = math.sqrt((viewport_coord[0]-obj.location[0])**2+(viewport_coord[1]-obj.location[1])**2+(viewport_coord[2]-obj.location[2])**2)
if distance_viewport_object > self.preferences.presence_mode_distance :
return
distance = math.sqrt((A[0]-B[0])**2 + (A[1]-B[1])**2)
if distance > 950 and coords :
if origin_coord :
blf.position(0, origin_coord[0]+8, origin_coord[1]-15, 0)
blf.size(0, 16, 72)
blf.color(0, color[0], color[1], color[2], color[3])
blf.draw(0, mode_current)
class SessionStatusWidget(Widget):
draw_type = 'POST_PIXEL'

View File

@ -469,6 +469,10 @@ class SESSION_PT_presence(bpy.types.Panel):
row.prop(settings, "presence_show_far_user", text="",icon_only=True, icon='SCENE_DATA')
col = layout.column()
if settings.presence_show_mode :
row = col.column()
row.prop(pref, "presence_mode_distance", expand=True)
col.prop(settings, "presence_show_session_status")
if settings.presence_show_session_status :
row = col.column()
@ -642,6 +646,10 @@ class VIEW3D_PT_overlay_session(bpy.types.Panel):
row.prop(settings, "presence_show_far_user", text="",icon_only=True, icon='SCENE_DATA')
col = layout.column()
if settings.presence_show_mode :
row = col.column()
row.prop(pref, "presence_mode_distance", expand=True)
col.prop(settings, "presence_show_session_status")
if settings.presence_show_session_status :
row = col.column()
@ -652,6 +660,7 @@ class VIEW3D_PT_overlay_session(bpy.types.Panel):
row.prop(pref, "presence_hud_hpos", expand=True)
row.prop(pref, "presence_hud_vpos", expand=True)
classes = (
SESSION_UL_users,
SESSION_PT_settings,