Skip to content

Commit

Permalink
Add early return for case in which the inverse of determinant is not …
Browse files Browse the repository at this point in the history
…finite (fixes CookiePLMonster#4)

This change better aligns our implementation with behavior found in d3dx9_31!c_D3DXMatrixInverse.
  • Loading branch information
riverar committed Nov 7, 2020
1 parent 3fc2991 commit d958c6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/D3DXMatrix.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <d3dx9.h>
#include <DirectXMath.h>
#include <cmath>

// D3DX Matrix functions implemented in the means of DirectXMath

Expand All @@ -12,7 +13,7 @@ D3DXMATRIX* WINAPI D3DXMatrixInverse_XM(D3DXMATRIX *pOut, FLOAT *pDeterminant, C
const float det = XMVectorGetX(determinant);

// Mirror the behaviour of D3DXMatrixInverse
if (det == 0.0f)
if (det == 0.0f || !std::isfinite(1.0f / det))
{
return nullptr;
}
Expand Down

0 comments on commit d958c6b

Please sign in to comment.