From 5c92c04518b5dc7c57c3b3a9e81b45879af2e080 Mon Sep 17 00:00:00 2001 From: Peter Kim Date: Sat, 30 Apr 2022 16:23:43 +0900 Subject: XR: Add object extras, object types visibility session options This allows object extras such as image-empties to be shown in the VR viewport/headset display. Being able to see reference images in VR can be useful for architectural walkthroughs and 3D modeling applications. Since users may not want to see all object extras (lights, cameras, etc.), per-object-type visibility settings are also added as session options. By slightly refactoring the definition of the 3D View object types visibility panel (note: no functional changes), the VR Scene Inspection add-on can show a similar panel without duplicating code. When VR selection is possible in the future, the object type select options can also be enabled. Reviewed By: Severin Differential Revision: https://developer.blender.org/D14220 --- release/scripts/startup/bl_ui/space_view3d.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'release/scripts') diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 9aebb4427d2..4f1d001b2f3 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -5684,13 +5684,14 @@ class VIEW3D_PT_object_type_visibility(Panel): bl_label = "View Object Types" bl_ui_units_x = 7 - def draw(self, context): + # Allows derived classes to pass view data other than context.space_data. + # This is used by the official VR add-on, which passes XrSessionSettings + # since VR has a 3D view that only exists for the duration of the VR session. + def draw_ex(self, context, view, show_select): layout = self.layout layout.use_property_split = True layout.use_property_decorate = False - view = context.space_data - layout.label(text="Object Types Visibility") layout.separator() col = layout.column() @@ -5728,19 +5729,25 @@ class VIEW3D_PT_object_type_visibility(Panel): continue attr_v = "show_object_viewport_" + attr - attr_s = "show_object_select_" + attr - icon_v = 'HIDE_OFF' if getattr(view, attr_v) else 'HIDE_ON' - icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' row = col.row(align=True) row.alignment = 'RIGHT' row.label(text=attr_name) row.prop(view, attr_v, text="", icon=icon_v, emboss=False) - rowsub = row.row(align=True) - rowsub.active = getattr(view, attr_v) - rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False) + + if show_select: + attr_s = "show_object_select_" + attr + icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' + + rowsub = row.row(align=True) + rowsub.active = getattr(view, attr_v) + rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False) + + def draw(self, context): + view = context.space_data + self.draw_ex(context, view, True) class VIEW3D_PT_shading(Panel): -- cgit v1.2.3