Commit: 39107d3ed1ddda78a59140e9aa2e7f48ad663f20
Author: Julian Eisel
Date:   Wed Mar 11 20:36:19 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB39107d3ed1ddda78a59140e9aa2e7f48ad663f20

Merge branch 'soc-2019-openxr' into vr_scene_inspection

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



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

diff --cc source/blender/makesdna/DNA_windowmanager_types.h
index 03ee75c2da0,9226ff20ae6..3badbe379e4
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@@ -125,12 -125,7 +125,12 @@@ typedef struct ReportTimerInfo 
  typedef struct wmXrData {
    void *context; /* GHOST_XrContextHandle */
  
 +  /** Permanent session settings (draw mode, feature toggles, etc). Stored in 
files and accessible
 +   * even before the session runs. */
-   bXrSessionSettings session_settings;
+   XrSessionSettings session_settings;
 +
 +  /** Runtime state information for managing Blender specific behaviors. Not 
stored in files. */
 +  struct XrRuntimeSessionState *session_state;
  } wmXrData;
  //#endif
  
diff --cc source/blender/makesdna/DNA_xr_types.h
index f3d6f3deadc,70927399a32..a026f7554cb
--- a/source/blender/makesdna/DNA_xr_types.h
+++ b/source/blender/makesdna/DNA_xr_types.h
@@@ -21,38 -21,17 +21,38 @@@
  #ifndef __DNA_XR_TYPES_H__
  #define __DNA_XR_TYPES_H__
  
 +#include "DNA_view3d_types.h"
 +
- typedef struct bXrSessionSettings {
+ typedef struct XrSessionSettings {
 -  /** Shading type (OB_SOLID, ...). */
 -  char shading_type;
 +  /** Shading settings, struct shared with 3D-View so settings are the same. 
*/
 +  struct View3DShading shading;
 +
 +  char _pad[7];
 +
 +  char base_pose_type; /* eXRSessionBasePoseType */
 +  /** Object to take the location and rotation as base position from. */
 +  Object *base_pose_object;
 +  float base_pose_location[3];
 +  float base_pose_angle;
 +
    /** View3D draw flags (V3D_OFSDRAW_NONE, V3D_OFSDRAW_SHOW_ANNOTATION, ...). 
*/
    char draw_flags;
 -  char _pad[2];
 +  char _pad2[3];
  
    /** Clipping distance. */
    float clip_start, clip_end;
  
 -  char _pad2[4];
 +  int flag;
- } bXrSessionSettings;
+ } XrSessionSettings;
  
 +typedef enum eXrSessionFlag {
 +  XR_SESSION_USE_POSITION_TRACKING = (1 << 0),
 +} eXrSessionFlag;
 +
 +typedef enum eXRSessionBasePoseType {
 +  XR_BASE_POSE_SCENE_CAMERA = 0,
 +  XR_BASE_POSE_OBJECT = 1,
 +  XR_BASE_POSE_CUSTOM = 2,
 +} eXRSessionBasePoseType;
 +
  #endif /* __DNA_XR_TYPES_H__ */
diff --cc source/blender/makesrna/intern/rna_xr.c
index 9ef7d72028e,7fdb77c3d0e..04340b7a916
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@@ -85,64 -34,12 +85,63 @@@ static void rna_def_xr_session_settings
    StructRNA *srna;
    PropertyRNA *prop;
  
 -  srna = RNA_def_struct(brna, "XrSessionSettings", NULL);
 -  RNA_def_struct_ui_text(srna, "XR-Session Settings", "");
 +  static const EnumPropertyItem base_pose_types[] = {
 +      {XR_BASE_POSE_SCENE_CAMERA,
 +       "SCENE_CAMERA",
 +       0,
 +       "Scene Camera",
 +       "Follow the active scene camera to define the VR view's reference 
pose"},
 +      {XR_BASE_POSE_OBJECT,
 +       "OBJECT",
 +       0,
 +       "Object",
 +       "Follow the transformation of an object to define the VR view's 
reference pose"},
 +      {XR_BASE_POSE_CUSTOM,
 +       "CUSTOM",
 +       0,
 +       "Custom",
 +       "Follow a custom transformation to define the VR view's reference 
pose"},
 +      {0, NULL, 0, NULL, NULL},
 +  };
  
 -  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");
 +  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", PROP_POINTER, PROP_NONE);
 +  RNA_def_property_flag(prop, PROP_NEVER_NULL);
 +  RNA_def_property_ui_text(prop, "Shading Settings", "");
 +  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
 +
 +  prop = RNA_def_property(srna, "base_pose_type", PROP_ENUM, PROP_NONE);
 +  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 +  RNA_def_property_enum_items(prop, base_pose_types);
 +  RNA_def_property_ui_text(
 +      prop, "Base Pose Type", "Define where the base pose for the VR view 
comes from");
 +  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
 +
 +  prop = RNA_def_property(srna, "base_pose_object", PROP_POINTER, PROP_NONE);
 +  RNA_def_property_flag(prop, PROP_EDITABLE);
 +  RNA_def_property_ui_text(
 +      prop,
 +      "Base Pose Object",
 +      "Object to take the location and rotation for the centroid from, to 
which translation and "
 +      "rotation deltas from the VR headset will be applied to");
 +  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
 +
 +  prop = RNA_def_property(srna, "base_pose_location", PROP_FLOAT, 
PROP_TRANSLATION);
 +  RNA_def_property_ui_text(
 +      prop,
 +      "Base Pose Location",
 +      "Coordinates for the centroid to apply translation deltas from the VR 
headset to");
 +  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 
RNA_TRANSLATION_PREC_DEFAULT);
 +  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
 +
 +  prop = RNA_def_property(srna, "base_pose_angle", PROP_FLOAT, 
PROP_AXISANGLE);
 +  RNA_def_property_ui_text(
 +      prop,
 +      "Base Pose Angle",
 +      "Rotation angle around the Z-Axis to apply the rotation deltas from the 
VR headset to");
 +  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
  
    prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
    RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", 
V3D_OFSDRAW_SHOW_GRIDFLOOR);
diff --cc source/blender/windowmanager/intern/wm_operators.c
index 6cc46304d87,16f2f822338..635a0f7a1c5
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@@ -3675,7 -3651,7 +3675,7 @@@ static int wm_xr_session_toggle_exec(bC
    wmWindowManager *wm = CTX_wm_manager(C);
  
    /* Lazy-create xr context - tries to dynlink to the runtime, reading 
active_runtime.json. */
-   if (wm_xr_init(C, wm) == false) {
 -  if (wm_xr_context_ensure(wm) == false) {
++  if (wm_xr_init(wm) == false) {
      return OPERATOR_CANCELLED;
    }
  
diff --cc source/blender/windowmanager/intern/wm_xr.c
index 56a79ece1a1,be6af48f5de..4de13eb3809
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@@ -34,7 -31,8 +34,9 @@@
  #include "BLI_math_geom.h"
  #include "BLI_math_matrix.h"
  
+ #include "CLG_log.h"
+ 
 +#include "DNA_camera_types.h"
  #include "DNA_object_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_view3d_types.h"
@@@ -103,12 -74,12 +105,12 @@@ typedef struct 
  
  typedef struct {
    wmWindowManager *wm;
-   bContext *evil_C;
  } wmXrErrorHandlerData;
  
 -void wm_xr_draw_view(const GHOST_XrDrawViewInfo *, void *);
 -void *wm_xr_session_gpu_binding_context_create(GHOST_TXrGraphicsBinding);
 -void wm_xr_session_gpu_binding_context_destroy(GHOST_TXrGraphicsBinding, void 
*);
 -wmSurface *wm_xr_session_surface_create(wmWindowManager *, unsigned int);
 +/* -------------------------------------------------------------------- */
 +
 +static wmSurface *g_xr_surface = NULL;
++static CLG_LogRef LOG = {"wm.xr"};
  
  /* -------------------------------------------------------------------- */
  /** \name XR-Context
@@@ -136,7 -106,7 +137,7 @@@ static void wm_xr_error_handler(const G
    }
  }
  
- bool wm_xr_init(bContext *C, wmWindowManager *wm)
 -bool wm_xr_context_ensure(wmWindowManager *wm)
++bool wm_xr_init(wmWindowManager *wm)
  {
    if (wm->xr.context) {
      return true;
@@@ -198,152 -159,6 +198,152 @@@ void wm_xr_exit(wmWindowManager *wm
  
  /** \} */ /* XR-Context */
  
 +/* -------------------------------------------------------------------- */
 +/** \name XR Runtime Session State
 + *
 + * \{ */
 +
 +static XrRuntimeSessionState *wm_xr_runtime_session_state_create(void)
 +{
 +  XrRuntimeSessionState *state = MEM_callocN(sizeof(*state), __func__);
 +  return state;
 +}
 +
 +void wm_xr_runtime_session_state_free(XrRuntimeSessionState **state)
 +{
 +  MEM_SAFE_FREE(*state);
 +}
 +
 +static void wm_xr_reference_pose_calc(const Scene *scene,
-                                       const bXrSessionSettings *settings,
++                                      const XrSessionSettings *settings,
 +                                      GHOST_XrPose *r_pose)
 +{
 +  const Object *base_pose_object = ((settings->base_pose_type == 
XR_BASE_POSE_OBJECT) &&
 +                                    settings->base_pose_object) ?
 +                                       settings->base_pose_object :
 +                                       scene->camera;
 +
 +  if (settings->base_pose_type == XR_BASE_POSE_CUSTOM) {
 +    float tmp_quatx[4], tmp_quatz[4];
 +
 +    copy_v3_v3(r_pose->position, settings->base_pose_location);
 +    axis_angle_to_quat_single(tmp_quatx, 'X', M_PI_2);
 +    axis_angle_to_quat_single(tmp_quatz, 'Z', settings->base_pose_angle);
 +    mul_qt_qtqt(r_pose->orientation_quat, tmp_quatz, tmp_quatx);
 +  }
 +  else if (base_pose_object) {
 +    float tmp_quat[4];
 +    float tmp_eul[3];
 +
 +    mat4_to_loc_quat(r_pose->position, tmp_quat, base_pose_object->obmat);
 +
 +    /* Only use rotation around Z-axis to align view with floor. */
 +    quat_to_eul(tmp_eul, tmp_quat);
 +    tmp_eul[0] = M_PI_2;
 +    tmp_eul[1] = 0;
 +    eul_to_quat(r_pose->orientation_quat, tmp_eul);
 +  }
 +  else {
 +    copy_v3_fl(r_pose->position, 0.0f);
 +    unit_qt(r_pose->orientation_quat);
 +  }
 +}
 +
 +static void wm_xr_draw_data_populate(const XrRuntimeSessionState *state,
 +                                     const GHOST_XrDrawViewInfo *draw_view,
-                                      const bXrSessionSettings *settings,
++                                     const XrSessionSettings *settings,
 +                                     const Scene *scene,
 +                                     wmXrDrawData *r_draw_data)
 +{
 +  const bool position_tracking_toggled = (state->prev_settings_flag &
 +                                          XR_SESSION_USE_POSITION_TRACKING) !=
 +                                         (settings->flag & 
XR_SESSION_USE_POSITION_TRACKING);
 +  const bool 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to