When using CMatrix<f64>, an error arises in function CMatrix4<T>::getInverse(CMatrix4<T>& out). The line of code with the error is 1330 where it says: if( core::iszero ( d, FLT_MIN ) ).
The problem is that FLT_MIN is floating point and "d" is double, resulting in the compiler not knowing what iszero() to use (or at least it gave me grief, of all people). For that, I created iszeroT( const T a, const T tolerance = 0 ) and I cast the FLT_MIN to (T). Yeah, it's not exactly correct, but c++ doesn't have type checking.
Code: Select all
template<class T>
inline bool iszeroT( const T a, const T tolerance = 0 )
{
return abs_(a) < tolerance;
}
Code: Select all
enum EMatrixTolerance
{
EMTOL_NONE, // no tolerance
EMTOL_F32,
EMTOL_F64
} matrixTolerance;
// usage as in the problem I presented...
switch( matrixTolerance )
{
case EMTOL_NONE: if ( iszero( (s32)d ) ) return false; break;
case EMTOL_F32: if ( iszero( (f32)d, FLT_MIN ) return false; break;
case EMTOL_F64: if ( iszero( (f64)d, DBL_MIN ) return false; break;
}