diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 8513500b86..0da404125e 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -644,20 +644,8 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { return true; } - // Chceck if the projection matrix is identity - bool identity = true; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - float value = projMatrix[i * 4 + j]; - - // Other number than zero on non-diagonale - if ((i != j) && (fabs(value) > EPSILON)) identity = false; - // Other number than one on diagonale - if ((i == j) && (fabs(value - 1.0f) > EPSILON)) identity = false; - } - } - // Update 3D geometry count + bool identity = IsMatrixIdentity(projMatrix); if (!identity && !ortho) { vr3DGeometryCount++; } @@ -708,6 +696,11 @@ void UpdateVRView(float* leftEye, float* rightEye) { float* matrix[] = {vrMatrix[VR_VIEW_MATRIX_LEFT_EYE], vrMatrix[VR_VIEW_MATRIX_RIGHT_EYE]}; for (int index = 0; index < 2; index++) { + // Validate the view matrix + if (IsMatrixIdentity(dst[index])) { + return; + } + // Get view matrix from the game Lin::Matrix4x4 gameView = {}; memcpy(gameView.m, dst[index], 16 * sizeof(float)); diff --git a/Common/VR/VRMath.cpp b/Common/VR/VRMath.cpp index 2fd7f1d538..d65f13a1a7 100644 --- a/Common/VR/VRMath.cpp +++ b/Common/VR/VRMath.cpp @@ -13,6 +13,20 @@ float ToRadians(float deg) { return (float)(deg * M_PI / 180.0f); } +bool IsMatrixIdentity(float* matrix) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + float value = matrix[i * 4 + j]; + + // Other number than zero on non-diagonale + if ((i != j) && (fabs(value) > EPSILON)) return false; + // Other number than one on diagonale + if ((i == j) && (fabs(value - 1.0f) > EPSILON)) return false; + } + } + return true; +} + /* ================================================================================ diff --git a/Common/VR/VRMath.h b/Common/VR/VRMath.h index 20317f4a8d..4f6e0610c9 100644 --- a/Common/VR/VRMath.h +++ b/Common/VR/VRMath.h @@ -9,6 +9,7 @@ float ToDegrees(float rad); float ToRadians(float deg); +bool IsMatrixIdentity(float* matrix); // XrPosef XrPosef XrPosef_Identity();