Commit: 1a1b51f329e9fa2050c1628b5f7135d08cc16b4b
Author: Julian Eisel
Date:   Fri Oct 28 23:11:20 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rB1a1b51f329e9fa2050c1628b5f7135d08cc16b4b

Fall back to return unit matrix

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

M       intern/ghost/intern/GHOST_C-api.cpp
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/windowmanager/intern/wm_device.c

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

diff --git a/intern/ghost/intern/GHOST_C-api.cpp 
b/intern/ghost/intern/GHOST_C-api.cpp
index c58cc5c..920d71d 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -1024,6 +1024,15 @@ void GHOST_HMDsetDeviceIPD(float value)
 #endif
 }
 
+static void ghost_UnitMat(float r_mat[4][4])
+{
+       r_mat[0][0] = r_mat[1][1] = r_mat[2][2] = r_mat[3][3] = 1.0f;
+       r_mat[0][1] = r_mat[0][2] = r_mat[0][3] = 0.0f;
+       r_mat[1][0] = r_mat[1][2] = r_mat[1][3] = 0.0f;
+       r_mat[2][0] = r_mat[2][1] = r_mat[2][3] = 0.0f;
+       r_mat[3][0] = r_mat[3][1] = r_mat[3][2] = 0.0f;
+}
+
 void GHOST_HMDgetLeftModelviewMatrix(float r_mat[4][4])
 {
 #ifdef WITH_OPENHMD
@@ -1031,7 +1040,7 @@ void GHOST_HMDgetLeftModelviewMatrix(float r_mat[4][4])
        GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
        ohmd->getLeftEyeGLModelviewMatrix(r_mat);
 #else
-       (void)r_mat;
+       ghost_UnitMat(r_mat);
 #endif
 }
 
@@ -1042,7 +1051,7 @@ void GHOST_HMDgetRightModelviewMatrix(float r_mat[4][4])
        GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
        ohmd->getRightEyeGLModelviewMatrix(r_mat);
 #else
-       (void)r_mat;
+       ghost_UnitMat(r_mat);
 #endif
 }
 
@@ -1053,7 +1062,7 @@ void GHOST_HMDgetLeftProjectionMatrix(float r_mat[4][4])
        GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
        ohmd->getLeftEyeGLProjectionMatrix(r_mat);
 #else
-       (void)r_mat;
+       ghost_UnitMat(r_mat);
 #endif
 }
 
@@ -1064,7 +1073,7 @@ void GHOST_HMDgetRightProjectionMatrix(float r_mat[4][4])
        GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
        ohmd->getRightEyeGLProjectionMatrix(r_mat);
 #else
-       (void)r_mat;
+       ghost_UnitMat(r_mat);
 #endif
 }
 
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 4b264ac..850d946 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3628,7 +3628,7 @@ static bool view3d_stereo3d_active(const bContext *C, 
Scene *scene, View3D *v3d,
 
 static bool view3d_hmd_view_active(wmWindowManager *wm, wmWindow *win, Scene 
*scene)
 {
-       return (wm->win_hmd == win && (scene->hmd_settings.flag & 
HMDVIEW_SESSION_RUNNING));
+       return (wm->win_hmd == win && (scene->hmd_settings.flag & 
HMDVIEW_SESSION_RUNNING) && (U.hmd_device > -1));
 }
 
 static void view3d_hmd_view_setup(Scene *scene, View3D *v3d, ARegion *ar)
diff --git a/source/blender/windowmanager/intern/wm_device.c 
b/source/blender/windowmanager/intern/wm_device.c
index b1f8f5c..399930a 100644
--- a/source/blender/windowmanager/intern/wm_device.c
+++ b/source/blender/windowmanager/intern/wm_device.c
@@ -30,6 +30,8 @@
 
 #include "BKE_context.h"
 
+#include "BLI_math.h"
+
 #include "DNA_userdef_types.h"
 
 #include "GHOST_C-api.h"
@@ -105,7 +107,7 @@ void WM_device_HMD_state_set(const int device, const bool 
enable)
 void WM_device_HMD_modelview_matrix_get(const bool is_left, float 
r_modelviewmat[4][4])
 {
        if (U.hmd_device == -1) {
-               r_modelviewmat = NULL;
+               unit_m4(r_modelviewmat);
        }
        else if (is_left) {
                GHOST_HMDgetLeftModelviewMatrix(r_modelviewmat);
@@ -118,7 +120,7 @@ void WM_device_HMD_modelview_matrix_get(const bool is_left, 
float r_modelviewmat
 void WM_device_HMD_projection_matrix_get(const bool is_left, float 
r_projmat[4][4])
 {
        if (U.hmd_device == -1) {
-               r_projmat = NULL;
+               unit_m4(r_projmat);
        }
        else if (is_left) {
                GHOST_HMDgetLeftProjectionMatrix(r_projmat);

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

Reply via email to