[Bf-blender-cvs] [7cf31cb] HMD_viewport: Cleanup: Use 4x4 matrices, naming, compiler hints, use API function

Julian Eisel noreply at git.blender.org
Mon Aug 1 02:52:18 CEST 2016


Commit: 7cf31cb0481a1b4c1eaf219b40af56c05f79fab2
Author: Julian Eisel
Date:   Mon Aug 1 02:49:36 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rB7cf31cb0481a1b4c1eaf219b40af56c05f79fab2

Cleanup: Use 4x4 matrices, naming, compiler hints, use API function

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

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_OpenHMDManager.cpp
M	intern/ghost/intern/GHOST_OpenHMDManager.h
M	source/blender/blenkernel/intern/camera.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_device.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 2a88e15..8ef591d 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -937,10 +937,10 @@ extern int         GHOST_HMDgetOpenDeviceIndex(void);
 extern const char *GHOST_HMDgetDeviceName(int index);
 extern const char *GHOST_HMDgetVendorName(int index);
 extern float       GHOST_HMDgetDeviceIPD(void);
-extern void        GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[16]);
-extern void        GHOST_HMDgetRightModelviewMatrix(float rightMatrix[16]);
-extern void        GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[16]);
-extern void        GHOST_HMDgetRightProjectionMatrix(float rightMatrix[16]);
+extern void        GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[4][4]);
+extern void        GHOST_HMDgetRightModelviewMatrix(float rightMatrix[4][4]);
+extern void        GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[4][4]);
+extern void        GHOST_HMDgetRightProjectionMatrix(float rightMatrix[4][4]);
 
 #ifdef __cplusplus
 }
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 4bbbbb8..dc1424e 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -1012,7 +1012,7 @@ float GHOST_HMDgetDeviceIPD()
 #endif
 }
 
-void GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[16])
+void GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
@@ -1022,7 +1022,7 @@ void GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[16])
 #endif
 }
 
-void GHOST_HMDgetRightModelviewMatrix(float rightMatrix[16])
+void GHOST_HMDgetRightModelviewMatrix(float rightMatrix[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
@@ -1032,7 +1032,7 @@ void GHOST_HMDgetRightModelviewMatrix(float rightMatrix[16])
 #endif
 }
 
-void GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[16])
+void GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
@@ -1042,7 +1042,7 @@ void GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[16])
 #endif
 }
 
-void GHOST_HMDgetRightProjectionMatrix(float rightMatrix[16])
+void GHOST_HMDgetRightProjectionMatrix(float rightMatrix[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index 5228bf4..0de4b4d 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -268,40 +268,40 @@ bool GHOST_OpenHMDManager::getRotationQuat(float orientation[4]) const
 	return true;
 }
 
-void GHOST_OpenHMDManager::getLeftEyeGLModelviewMatrix(float mat[16]) const
+void GHOST_OpenHMDManager::getLeftEyeGLModelviewMatrix(float mat[4][4]) const
 {
 	if (!m_device) {
 		return;
 	}
 
-	ohmd_device_getf(m_device, OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX, mat);
+	ohmd_device_getf(m_device, OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX, *mat);
 }
 
-void GHOST_OpenHMDManager::getRightEyeGLModelviewMatrix(float mat[16]) const
+void GHOST_OpenHMDManager::getRightEyeGLModelviewMatrix(float mat[4][4]) const
 {
 	if (!m_device) {
 		return;
 	}
 
-	ohmd_device_getf(m_device, OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX, mat);
+	ohmd_device_getf(m_device, OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX, *mat);
 }
 
-void GHOST_OpenHMDManager::getLeftEyeGLProjectionMatrix(float mat[16]) const
+void GHOST_OpenHMDManager::getLeftEyeGLProjectionMatrix(float mat[4][4]) const
 {
 	if (!m_device) {
 		return;
 	}
 
-	ohmd_device_getf(m_device, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX, mat);
+	ohmd_device_getf(m_device, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX, *mat);
 }
 
-void GHOST_OpenHMDManager::getRightEyeGLProjectionMatrix(float mat[16]) const
+void GHOST_OpenHMDManager::getRightEyeGLProjectionMatrix(float mat[4][4]) const
 {
 	if (!m_device) {
 		return;
 	}
 
-	ohmd_device_getf(m_device, OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX, mat);
+	ohmd_device_getf(m_device, OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX, *mat);
 }
 
 void GHOST_OpenHMDManager::getPositionVector(float position[3]) const
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h b/intern/ghost/intern/GHOST_OpenHMDManager.h
index 691ba3a..afbce69 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -126,25 +126,25 @@ public:
 	 * \param mat   A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the left eye of the HMD.
 	 *  Nothing is written if available() is false.
 	 */
-	void getLeftEyeGLModelviewMatrix(float mat[16]) const;
+	void getLeftEyeGLModelviewMatrix(float mat[4][4]) const;
 
 	/**
 	 * \param mat   A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the right eye of the HMD.
 	 *  Nothing is written if available() is false.
 	 */
-	void getRightEyeGLModelviewMatrix(float mat[16]) const;
+	void getRightEyeGLModelviewMatrix(float mat[4][4]) const;
 
 	/**
 	 * \param mat   A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the left eye of the HMD.
 	 *  Nothing is written if available() is false.
 	 */
-	void getLeftEyeGLProjectionMatrix(float mat[16]) const;
+	void getLeftEyeGLProjectionMatrix(float mat[4][4]) const;
 
 	/**
 	 * \param mat   A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the right eye of the HMD.
 	 *  Nothing is written if available() is false.
 	 */
-	void getRightEyeGLProjectionMatrix(float mat[16]) const;
+	void getRightEyeGLProjectionMatrix(float mat[4][4]) const;
 
 	 /**
 	 * \param position  A 3-D vector representing the absolute position of the device, in space.
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index da30542..9f9bd09 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -803,28 +803,13 @@ void BKE_camera_multiview_proj_matrix(const bool is_left, float r_projmat[4][4])
 	/* set projection matrix from hmd */
 	if (U.hmd_device != -1)
 	{
-		float cameraProjMatrix[16];
+		float cameraProjMatrix[4][4];
 		if (is_left)
 			WM_device_HMD_left_projection_matrix_get(cameraProjMatrix);
 		else
 			WM_device_HMD_right_projection_matrix_get(cameraProjMatrix);
 
-		r_projmat[0][0] = cameraProjMatrix[0];
-		r_projmat[0][1] = cameraProjMatrix[1];
-		r_projmat[0][2] = cameraProjMatrix[2];
-		r_projmat[0][3] = cameraProjMatrix[3];
-		r_projmat[1][0] = cameraProjMatrix[4];
-		r_projmat[1][1] = cameraProjMatrix[5];
-		r_projmat[1][2] = cameraProjMatrix[6];
-		r_projmat[1][3] = cameraProjMatrix[7];
-		r_projmat[2][0] = cameraProjMatrix[8];
-		r_projmat[2][1] = cameraProjMatrix[9];
-		r_projmat[2][2] = cameraProjMatrix[10];
-		r_projmat[2][3] = cameraProjMatrix[11];
-		r_projmat[3][0] = cameraProjMatrix[12];
-		r_projmat[3][1] = cameraProjMatrix[13];
-		r_projmat[3][2] = cameraProjMatrix[14];
-		r_projmat[3][3] = cameraProjMatrix[15];
+		copy_m4_m4(r_projmat, cameraProjMatrix);
 
 		//transpose_m4(r_projmat);
 	}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index d50c691..2e89dc1 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -525,10 +525,10 @@ int         WM_device_HMD_current_get(void) ATTR_WARN_UNUSED_RESULT;
 const char *WM_device_HMD_name_get(int index) ATTR_WARN_UNUSED_RESULT;
 const char *WM_device_HMD_vendor_get(int index) ATTR_WARN_UNUSED_RESULT;
 float       WM_device_HMD_IPD_get(void) ATTR_WARN_UNUSED_RESULT;
-void        WM_device_HMD_left_modelview_matrix_get(float leftMatrix[16]);
-void        WM_device_HMD_right_modelview_matrix_get(float rightMatrix[16]);
-void        WM_device_HMD_left_projection_matrix_get(float leftMatrix[16]);
-void        WM_device_HMD_right_projection_matrix_get(float rightMatrix[16]);
+void        WM_device_HMD_left_modelview_matrix_get(float r_mat[4][4]) ATTR_NONNULL();
+void        WM_device_HMD_right_modelview_matrix_get(float r_mat[4][4]) ATTR_NONNULL();
+void        WM_device_HMD_left_projection_matrix_get(float r_mat[4][4]) ATTR_NONNULL();
+void        WM_device_HMD_right_projection_matrix_get(float r_mat[4][4]) ATTR_NONNULL();
 
 #endif /* WITH_INPUT_HMD */
 
diff --git a/source/blender/windowmanager/intern/wm_device.c b/source/blender/windowmanager/intern/wm_device.c
index 61c0352..b8efaff 100644
--- a/source/blender/windowmanager/intern/wm_device.c
+++ b/source/blender/windowmanager/intern/wm_device.c
@@ -96,33 +96,33 @@ float WM_device_HMD_IPD_get(void)
 /**
  * Get left eye modelview matrix from currently opened HMD.
  */
-void WM_device_HMD_left_modelview_matrix_get(float leftMatrix[16])
+void WM_device_HMD_left_modelview_matrix_get(float r_mat[4][4])
 {
-	GHOST_HMDgetLeftModelviewMatrix(leftMatrix);
+	GHOST_HMDgetLeftModelviewMatrix(r_mat);
 }
 
 /**
  * Get right eye modelview matrix from currently opened HMD.
  */
-void WM_device_HMD_right_modelview_matrix_get(float rightMatrix[16])
+void WM_device_HMD_right_modelview_matrix_get(float r_mat[4][4])
 {
-	GHOST_HMDgetRightModelviewMatrix(rightMatrix);
+	GHOST_HMDgetRightModelviewMatrix(r_mat);
 }
 
 /**
  * Get left eye projection matrix from currently opened HMD.
  */
-void WM_device_HMD_left_projection_matrix_get(float leftMatrix[16])
+void WM_device_HMD_left_projection_matrix_get(float r_mat[4][4])
 {
-	GHOST_HMDgetLeftProjectionMatrix(leftMatrix);
+	GHOST_HMDgetLeftProjectionMatrix(r_mat);
 }
 
 /**
  * Get right eye projection matrix from currently opened HMD.
  */
-void WM_device_HMD_right_projection_matrix_get(float rightMatrix[16])
+void WM_device_HMD_right_projection_matrix_get(float r_mat[4][4])
 {
-	GHOST_HMDgetRightProjectionMatrix(rightMatrix);
+	GHOST_HMDgetRightProjectionMatrix(r_mat);
 }
 /** \} */
 
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index e09b7c1..8906b94 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -328,8 +328,8 @@ void WM_device_HMD_state_set(const int device, const bool enable) RET_NONE
 float WM_device_

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list