OpenXR - Do not apply head rotation on identity matrix

This commit is contained in:
Lubos 2022-11-09 17:59:14 +01:00
parent 584ca5db6e
commit 8716021244
3 changed files with 21 additions and 13 deletions

View file

@ -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));

View file

@ -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;
}
/*
================================================================================

View file

@ -9,6 +9,7 @@
float ToDegrees(float rad);
float ToRadians(float deg);
bool IsMatrixIdentity(float* matrix);
// XrPosef
XrPosef XrPosef_Identity();