diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp index 4c5f9e0a..53bc0d60 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp @@ -98,48 +98,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire #ifdef _DEBUG printf("Matrix Determinant: %f\n", det); printf("Matrix Determinant - 1 = %f\n", det -1); - printf("FLOATING POINT ERROR: %f\n", FLOATING_POINT_ERROR); #endif - - // use approxEqual to avoid direct comparisons - if (approxEqual(det, 1.0f) || - approxEqual(det, -1.0f)) - { - -#ifdef _DEBUG - printf("Matrix is Orthogonal\n"); -#endif - /* this matrix is orthogonal - - since inv(M) * M = I - when orthogonal - trans(M) * M = I - - proper orthogonal - inv(M) = trans(M) - improper orthogonal - inv(M) = -trans(M) - */ - - if (approxEqual(det, 1)) - { - // proper orthogonal - int srcIndex = 0; - for (int col = 0; col < source.width; col++) - for (int row = 0; row < source.height; row++) - destMatrix[col + row * source.width] = srcMatrix[srcIndex++]; - } - else - { - // improper orthogonal - int srcIndex = 0; - for (int col = 0; col < source.width; col++) - for (int row = 0; row < source.height; row++) - destMatrix[col + row * source.width] = -srcMatrix[srcIndex++]; - } - } - else - { float sign; @@ -167,12 +126,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire = (sign / det) * determinant(temp_matrix, temp_side); // swap signs - sign = (sign == 1) ? -1.0f : 1.0f; + sign *= -1.0f; } } - - } dest.writeComplete(); } } diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp index ba74e7ef..ba4f0821 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp @@ -98,49 +98,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe #ifdef _DEBUG printf("Matrix Determinant: %f\n", det); printf("Matrix Determinant - 1: %f\n", det-1); - printf("FLOATING POINT ERROR: %f\n", FLOATING_POINT_ERROR); #endif - - // use approxEqual to avoid direct comparisons - if (approxEqual(det,1) || approxEqual(det, -1)) - { - -#ifdef _DEBUG - printf("Matrix is Orthogonal\n"); -#endif - /* this matrix is orthogonal - since inv(M) * M = I - when orthogonal - trans(M) * M = I - - proper orthogonal - inv(M) = trans(M) - improper orthogonal - inv(M) = -trans(M) - */ - - if (approxEqual(det, 1)) - { - // proper orthogonal - int srcIndex = 0; - for (int col = 0; col < source.width; col++) - for (int row = 0; row < source.height; row++) - destMatrix[col + row * source.width] = srcMatrix[srcIndex++]; - } - else - { - // improper orthogonal - int srcIndex = 0; - for (int col = 0; col < source.width; col++) - for (int row = 0; row < source.height; row++) - destMatrix[col + row * source.width] = -srcMatrix[srcIndex++]; - } - } - else - { - - float sign; + float sign; for (int col = 0; col < source.width; col++) { @@ -166,11 +126,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe = (sign / det) * determinant(temp_matrix, temp_side); // swap signs - sign = (sign == 1) ? -1.0f : 1.0f; + sign *= -1.0f; } } - } dest.writeComplete(); }