Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kim <pk15950@gmail.com>2022-04-30 10:23:43 +0300
committerPeter Kim <pk15950@gmail.com>2022-04-30 10:23:43 +0300
commit5c92c04518b5dc7c57c3b3a9e81b45879af2e080 (patch)
tree7c4f0dee8132ae57fc896989f8e7d5839460c9d1 /source/blender/makesrna
parent2fc6563a597ad8877fea5e580c87eb4e13e58961 (diff)
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
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_internal.h4
-rw-r--r--source/blender/makesrna/intern/rna_space.c77
-rw-r--r--source/blender/makesrna/intern/rna_space_api.c76
-rw-r--r--source/blender/makesrna/intern/rna_xr.c33
4 files changed, 123 insertions, 67 deletions
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index b941245bcfc..bf4eec433c4 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -318,6 +318,10 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr,
PointerRNA rna_object_shapekey_index_get(struct ID *id, int value);
int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
+void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag);
+int rna_object_type_visibility_icon_get_common(int object_type_exclude_viewport,
+ const int *object_type_exclude_select);
+
/* ViewLayer related functions defined in rna_scene.c but required in rna_layer.c */
void rna_def_freestyle_settings(struct BlenderRNA *brna);
struct PointerRNA rna_FreestyleLineSet_linestyle_get(struct PointerRNA *ptr);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 032ef86c172..1a9e7f5aad8 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1515,12 +1515,8 @@ static void rna_SpaceView3D_mirror_xr_session_update(Main *main,
static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr)
{
const View3D *v3d = (View3D *)ptr->data;
- /* Ignore selection values when view is off,
- * intent is to show if visible objects aren't selectable. */
- const int view_value = (v3d->object_type_exclude_viewport != 0);
- const int select_value = (v3d->object_type_exclude_select &
- ~v3d->object_type_exclude_viewport) != 0;
- return ICON_VIS_SEL_11 + (view_value << 1) + select_value;
+ return rna_object_type_visibility_icon_get_common(v3d->object_type_exclude_viewport,
+ &v3d->object_type_exclude_select);
}
static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr))
@@ -4997,68 +4993,15 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_mirror_xr_session_update");
- {
- struct {
- const char *name;
- int type_mask;
- const char *identifier[2];
- } info[] = {
- {"Mesh", (1 << OB_MESH), {"show_object_viewport_mesh", "show_object_select_mesh"}},
- {"Curve",
- (1 << OB_CURVES_LEGACY),
- {"show_object_viewport_curve", "show_object_select_curve"}},
- {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}},
- {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}},
- {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}},
- {"Hair Curves",
- (1 << OB_CURVES),
- {"show_object_viewport_curves", "show_object_select_curves"}},
- {"Point Cloud",
- (1 << OB_POINTCLOUD),
- {"show_object_viewport_pointcloud", "show_object_select_pointcloud"}},
- {"Volume", (1 << OB_VOLUME), {"show_object_viewport_volume", "show_object_select_volume"}},
- {"Armature",
- (1 << OB_ARMATURE),
- {"show_object_viewport_armature", "show_object_select_armature"}},
- {"Lattice",
- (1 << OB_LATTICE),
- {"show_object_viewport_lattice", "show_object_select_lattice"}},
- {"Empty", (1 << OB_EMPTY), {"show_object_viewport_empty", "show_object_select_empty"}},
- {"Grease Pencil",
- (1 << OB_GPENCIL),
- {"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"}},
- {"Camera", (1 << OB_CAMERA), {"show_object_viewport_camera", "show_object_select_camera"}},
- {"Light", (1 << OB_LAMP), {"show_object_viewport_light", "show_object_select_light"}},
- {"Speaker",
- (1 << OB_SPEAKER),
- {"show_object_viewport_speaker", "show_object_select_speaker"}},
- {"Light Probe",
- (1 << OB_LIGHTPROBE),
- {"show_object_viewport_light_probe", "show_object_select_light_probe"}},
- };
-
- const char *view_mask_member[2] = {
- "object_type_exclude_viewport",
- "object_type_exclude_select",
- };
- for (int mask_index = 0; mask_index < 2; mask_index++) {
- for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) {
- prop = RNA_def_property(
- srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(
- prop, NULL, view_mask_member[mask_index], info[type_index].type_mask);
- RNA_def_property_ui_text(prop, info[type_index].name, "");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
- }
- }
+ rna_def_object_type_visibility_flags_common(srna,
+ NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING);
- /* Helper for drawing the icon. */
- prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE);
- RNA_def_property_int_funcs(
- prop, "rna_SpaceView3D_icon_from_show_object_viewport_get", NULL, NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Visibility Icon", "");
- }
+ /* Helper for drawing the icon. */
+ prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(
+ prop, "rna_SpaceView3D_icon_from_show_object_viewport_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Visibility Icon", "");
/* Nested Structs */
prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
index 06bb2207b0a..b3896919275 100644
--- a/source/blender/makesrna/intern/rna_space_api.c
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -4,6 +4,8 @@
* \ingroup RNA
*/
+#include "DNA_object_types.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
@@ -17,6 +19,21 @@
# include "ED_screen.h"
# include "ED_text.h"
+int rna_object_type_visibility_icon_get_common(int object_type_exclude_viewport,
+ const int *object_type_exclude_select)
+{
+ const int view_value = (object_type_exclude_viewport != 0);
+
+ if (object_type_exclude_select) {
+ /* Ignore selection values when view is off,
+ * intent is to show if visible objects aren't selectable. */
+ const int select_value = (*object_type_exclude_select & ~object_type_exclude_viewport) != 0;
+ return ICON_VIS_SEL_11 + (view_value << 1) + select_value;
+ }
+
+ return view_value ? ICON_HIDE_ON : ICON_HIDE_OFF;
+}
+
static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C)
{
bScreen *screen = (bScreen *)id;
@@ -102,6 +119,65 @@ void RNA_api_space_text(StructRNA *srna)
RNA_def_function_output(func, parm);
}
+void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag)
+{
+ PropertyRNA *prop;
+
+ struct {
+ const char *name;
+ int type_mask;
+ const char *identifier[2];
+ } info[] = {
+ {"Mesh", (1 << OB_MESH), {"show_object_viewport_mesh", "show_object_select_mesh"}},
+ {"Curve",
+ (1 << OB_CURVES_LEGACY),
+ {"show_object_viewport_curve", "show_object_select_curve"}},
+ {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}},
+ {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}},
+ {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}},
+ {"Hair Curves",
+ (1 << OB_CURVES),
+ {"show_object_viewport_curves", "show_object_select_curves"}},
+ {"Point Cloud",
+ (1 << OB_POINTCLOUD),
+ {"show_object_viewport_pointcloud", "show_object_select_pointcloud"}},
+ {"Volume", (1 << OB_VOLUME), {"show_object_viewport_volume", "show_object_select_volume"}},
+ {"Armature",
+ (1 << OB_ARMATURE),
+ {"show_object_viewport_armature", "show_object_select_armature"}},
+ {"Lattice",
+ (1 << OB_LATTICE),
+ {"show_object_viewport_lattice", "show_object_select_lattice"}},
+ {"Empty", (1 << OB_EMPTY), {"show_object_viewport_empty", "show_object_select_empty"}},
+ {"Grease Pencil",
+ (1 << OB_GPENCIL),
+ {"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"}},
+ {"Camera", (1 << OB_CAMERA), {"show_object_viewport_camera", "show_object_select_camera"}},
+ {"Light", (1 << OB_LAMP), {"show_object_viewport_light", "show_object_select_light"}},
+ {"Speaker",
+ (1 << OB_SPEAKER),
+ {"show_object_viewport_speaker", "show_object_select_speaker"}},
+ {"Light Probe",
+ (1 << OB_LIGHTPROBE),
+ {"show_object_viewport_light_probe", "show_object_select_light_probe"}},
+ };
+
+ const char *view_mask_member[2] = {
+ "object_type_exclude_viewport",
+ "object_type_exclude_select",
+ };
+ for (int mask_index = 0; mask_index < 2; mask_index++) {
+ for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) {
+ prop = RNA_def_property(
+ srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(
+ prop, NULL, view_mask_member[mask_index], info[type_index].type_mask);
+ RNA_def_property_ui_text(prop, info[type_index].name, "");
+ RNA_def_property_update(prop, noteflag, NULL);
+ }
+ }
+}
+
void RNA_api_space_filebrowser(StructRNA *srna)
{
FunctionRNA *func;
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
index d8be9b7e80d..6f43afe23fe 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -691,6 +691,24 @@ static void rna_XrSessionSettings_use_absolute_tracking_set(PointerRNA *ptr, boo
# endif
}
+static int rna_XrSessionSettings_icon_from_show_object_viewport_get(PointerRNA *ptr)
+{
+# ifdef WITH_XR_OPENXR
+ const wmXrData *xr = rna_XrSession_wm_xr_data_get(ptr);
+ return rna_object_type_visibility_icon_get_common(
+ xr->session_settings.object_type_exclude_viewport,
+# if 0
+ /* For the future when selection in VR is reliably supported. */
+ &xr->session_settings.object_type_exclude_select
+# else
+ NULL
+# endif
+ );
+# else
+ return ICON_NONE;
+# endif
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1944,6 +1962,12 @@ static void rna_def_xr_session_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Custom Overlays", "Show custom VR overlays");
RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
+ prop = RNA_def_property(srna, "show_object_extras", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", V3D_OFSDRAW_SHOW_OBJECT_EXTRAS);
+ RNA_def_property_ui_text(
+ prop, "Show Object Extras", "Show object extras, including empties, lights, and cameras");
+ RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
+
prop = RNA_def_property(srna, "controller_draw_style", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, controller_draw_styles);
@@ -1982,6 +2006,15 @@ static void rna_def_xr_session_settings(BlenderRNA *brna)
"Absolute Tracking",
"Allow the VR tracking origin to be defined independently of the headset location");
RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
+
+ rna_def_object_type_visibility_flags_common(srna, NC_WM | ND_XR_DATA_CHANGED);
+
+ /* Helper for drawing the icon. */
+ prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(
+ prop, "rna_XrSessionSettings_icon_from_show_object_viewport_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Visibility Icon", "");
}
/** \} */