MCPcopy Create free account
hub / github.com/ZDoom/Raze / inverseMatrix

Method inverseMatrix

source/common/utility/matrix.cpp:687–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685}
686
687bool VSMatrix::inverseMatrix(VSMatrix &result)
688{
689 // Calculate mat4 determinant
690 FLOATTYPE det = mat4Determinant(mMatrix);
691
692 // Inverse unknown when determinant is close to zero
693 if (fabs(det) < 1e-15)
694 {
695 for (int i = 0; i < 16; i++)
696 result.mMatrix[i] = FLOATTYPE(0.0);
697 return false;
698 }
699 else
700 {
701 mat4Adjoint(mMatrix, result.mMatrix);
702
703 FLOATTYPE invDet = FLOATTYPE(1.0) / det;
704 for (int i = 0; i < 16; i++)
705 {
706 result.mMatrix[i] = result.mMatrix[i] * invDet;
707 }
708 }
709 return true;
710}

Callers 1

LoadMethod · 0.80

Calls 3

mat4DeterminantFunction · 0.85
fabsFunction · 0.85
mat4AdjointFunction · 0.85

Tested by

no test coverage detected