Skip to content

Commit

Permalink
Merge pull request #58507 from aaronfranke/camera-matrix
Browse files Browse the repository at this point in the history
Use is_zero_approx and fix spelling in CameraMatrix invert
  • Loading branch information
akien-mga authored Feb 26, 2022
2 parents 0393057 + 061ab30 commit 234eb83
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/math/camera_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,15 @@ void CameraMatrix::invert() {
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
real_t pvt_val; /* Value of current pivot element */
real_t hold; /* Temporary storage */
real_t determinat; /* Determinant */

determinat = 1.0;
real_t determinant = 1.0f;
for (k = 0; k < 4; k++) {
/** Locate k'th pivot element **/
pvt_val = matrix[k][k]; /** Initialize for search **/
pvt_i[k] = k;
pvt_j[k] = k;
for (i = k; i < 4; i++) {
for (j = k; j < 4; j++) {
if (Math::absd(matrix[i][j]) > Math::absd(pvt_val)) {
if (Math::abs(matrix[i][j]) > Math::abs(pvt_val)) {
pvt_i[k] = i;
pvt_j[k] = j;
pvt_val = matrix[i][j];
Expand All @@ -455,9 +453,9 @@ void CameraMatrix::invert() {
}

/** Product of pivots, gives determinant when finished **/
determinat *= pvt_val;
if (Math::absd(determinat) < 1e-7) {
return; //(false); /** Matrix is singular (zero determinant). **/
determinant *= pvt_val;
if (Math::is_zero_approx(determinant)) {
return; /** Matrix is singular (zero determinant). **/
}

/** "Interchange" rows (with sign change stuff) **/
Expand Down

0 comments on commit 234eb83

Please sign in to comment.