[Bf-blender-cvs] [1ada9f5bf95] soc-2019-openxr: Support VR Session settings & add some basic ones

Julian Eisel noreply at git.blender.org
Tue Oct 15 16:02:00 CEST 2019


Commit: 1ada9f5bf95d6f732b16e58b74407e9bb8383cf0
Author: Julian Eisel
Date:   Tue Oct 15 15:43:41 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB1ada9f5bf95d6f732b16e58b74407e9bb8383cf0

Support VR Session settings & add some basic ones

* Adds the needed bits to support VR session settings and access them in
  the VR view drawing code.
* Added settings for: shading mode, grid floor, annotations, clipping.
  More can easily be added.
* The Add-on adds a "VR" tab in the side bar, containing buttons for the
  added settings

===================================================================

M	source/blender/CMakeLists.txt
M	source/blender/blenloader/CMakeLists.txt
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/makesdna/DNA_windowmanager_types.h
A	source/blender/makesdna/DNA_xr_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_wm.c
A	source/blender/makesrna/intern/rna_xr.c
M	source/blender/windowmanager/intern/wm_xr.c

===================================================================

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 203543b0ef0..a9d42a1764d 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -89,6 +89,7 @@ set(SRC_DNA_INC
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_windowmanager_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_workspace_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_world_types.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_xr_types.h
 )
 
 add_subdirectory(datatoc)
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 1520c7b82b8..5334f4bdbdc 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -92,6 +92,10 @@ if(WITH_ALEMBIC)
   add_definitions(-DWITH_ALEMBIC)
 endif()
 
+if(WITH_OPENXR)
+  add_definitions(-DWITH_OPENXR)
+endif()
+
 blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
 
 # needed so writefile.c can use dna_type_offsets.h
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 9e0d3b7a419..d91d3a2f877 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -30,6 +30,8 @@
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
+#include "DNA_defaults.h"
+
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
 #include "DNA_camera_types.h"
@@ -3932,5 +3934,18 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
   {
     /* Versioning code until next subversion bump goes here. */
+#ifdef WITH_OPENXR
+    if (!DNA_struct_find(fd->filesdna, "bXrSessionSettings")) {
+      for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
+        const View3D *v3d_default = DNA_struct_default_get(View3D);
+
+        wm->xr_session_settings.shading_type = OB_SOLID;
+        wm->xr_session_settings.draw_flags = (V3D_OFSDRAW_SHOW_GRIDFLOOR |
+                                              V3D_OFSDRAW_SHOW_ANNOTATION);
+        wm->xr_session_settings.clip_start = v3d_default->clip_start;
+        wm->xr_session_settings.clip_end = v3d_default->clip_end;
+      }
+    }
+#endif
   }
 }
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 332680713a0..073c911c87e 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -28,6 +28,7 @@
 #include "DNA_screen_types.h"
 #include "DNA_vec_types.h"
 #include "DNA_userdef_types.h"
+#include "DNA_xr_types.h"
 
 #include "DNA_ID.h"
 
@@ -182,6 +183,7 @@ typedef struct wmWindowManager {
   struct wmMsgBus *message_bus;
 
   //#ifdef WITH_OPENXR
+  bXrSessionSettings xr_session_settings;
   void *xr_context; /* GHOST_XrContextHandle */
   //#endif
 } wmWindowManager;
diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h
new file mode 100644
index 00000000000..0d23668a59f
--- /dev/null
+++ b/source/blender/makesdna/DNA_xr_types.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_XR_TYPES_H__
+#define __DNA_XR_TYPES_H__
+
+typedef struct bXrSessionSettings {
+  /** Shading type (OB_SOLID, ...). */
+  char shading_type;
+  /** View3D draw flags (V3D_OFSDRAW_NONE, V3D_OFSDRAW_SHOW_ANNOTATION, ...). */
+  char draw_flags;
+  char _pad[2];
+
+  /** Clipping distance. */
+  float clip_start, clip_end;
+
+  char _pad2[4];
+} bXrSessionSettings;
+
+#endif /* __DNA_XR_TYPES_H__ */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 80d37d89f14..508c90adf47 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -131,6 +131,7 @@ static const char *includefiles[] = {
     "DNA_layer_types.h",
     "DNA_workspace_types.h",
     "DNA_lightprobe_types.h",
+    "DNA_xr_types.h",
 
     /* see comment above before editing! */
 
@@ -1590,6 +1591,7 @@ int main(int argc, char **argv)
 #include "DNA_layer_types.h"
 #include "DNA_workspace_types.h"
 #include "DNA_lightprobe_types.h"
+#include "DNA_xr_types.h"
 
 /* end of list */
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index cefc5aded7c..17b136fd7a1 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -745,6 +745,7 @@ extern StructRNA RNA_WorldMistSettings;
 extern StructRNA RNA_WorldTextureSlot;
 extern StructRNA RNA_XnorController;
 extern StructRNA RNA_XorController;
+extern StructRNA RNA_XrSessionSettings;
 extern StructRNA RNA_uiPopover;
 extern StructRNA RNA_wmOwnerIDs;
 
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 259f656cc8c..b9f4a4dd17b 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -122,6 +122,12 @@ set(APISRC
   rna_workspace_api.c
 )
 
+if(WITH_OPENXR)
+  list(APPEND DEFSRC
+    rna_xr.c
+  )
+endif()
+
 string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
 list(APPEND GENSRC
   "${CMAKE_CURRENT_BINARY_DIR}/rna_prototypes_gen.h"
@@ -322,6 +328,10 @@ if(WITH_INPUT_NDOF)
   add_definitions(-DWITH_INPUT_NDOF)
 endif()
 
+if(WITH_OPENXR)
+  add_definitions(-DWITH_OPENXR)
+endif()
+
 # Build makesrna executable
 blender_include_dirs(
   .
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2d4da942610..28023ddea89 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -4279,6 +4279,9 @@ static RNAProcessItem PROCESS_ITEMS[] = {
     {"rna_movieclip.c", NULL, RNA_def_movieclip},
     {"rna_tracking.c", NULL, RNA_def_tracking},
     {"rna_mask.c", NULL, RNA_def_mask},
+#ifdef WITH_OPENXR
+    {"rna_xr.c", NULL, RNA_def_xr},
+#endif
     {NULL, NULL},
 };
 
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 04a59a48b63..1193402b086 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -205,6 +205,9 @@ void RNA_def_world(struct BlenderRNA *brna);
 void RNA_def_movieclip(struct BlenderRNA *brna);
 void RNA_def_tracking(struct BlenderRNA *brna);
 void RNA_def_mask(struct BlenderRNA *brna);
+#ifdef WITH_OPENXR
+void RNA_def_xr(struct BlenderRNA *brna);
+#endif
 
 /* Common Define functions */
 
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 5f60ecf449b..46a6e4589cb 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -2464,6 +2464,12 @@ static void rna_def_windowmanager(BlenderRNA *brna)
       prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
   RNA_def_property_ui_text(prop, "Text Clipboard", "");
 
+#  ifdef WITH_OPENXR
+  prop = RNA_def_property(srna, "xr_session_settings", PROP_POINTER, PROP_NONE);
+  RNA_def_property_flag(prop, PROP_NEVER_NULL);
+  RNA_def_property_ui_text(prop, "XR Session Settings", "");
+#  endif
+
   RNA_api_wm(srna);
 }
 
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
new file mode 100644
index 00000000000..68cf4a6ab18
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -0,0 +1,77 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup RNA
+ */
+
+#include "DNA_view3d_types.h"
+
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "rna_internal.h"
+
+#ifndef WITH_OPENXR
+BLI_STATIC_ASSERT(false, "Tried to compile rna_xr.c even though WITH_OPENXR is not defined.");
+#endif
+
+#ifdef RNA_RUNTIME
+
+#else /* RNA_RUNTIME */
+
+static void rna_def_xr_session_settings(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "XrSessionSettings", NULL);
+  RNA_def_struct_sdna(srna, "bXrSessionSettings");
+  RNA_def_struct_ui_text(srna, "XR-Session Settings", "");
+
+  prop = RNA_def_property(srna, "shading_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, rna_enum_shading_type_items);
+  RNA_def_property_ui_text(prop, "Shading Type", "Method to display/shade objects in the VR View");
+
+  prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", V3D_OFSDRAW_SHOW_GRIDFLOOR);
+  RNA_def_property_ui_text(prop, "Display Grid Floor", "Show the ground plane grid");
+
+  prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", V3D_OFSDRAW_SHOW

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list