This project has moved and is read-only. For the latest updates, please go here.

Bug in Simplemath.inl Matrix !=

Nov 13, 2014 at 12:14 AM
Edited Nov 13, 2014 at 12:17 AM
Calling != on two matrices will not work correctly if they only differ in translation. The reason is that the function is defined as :

inline bool Matrix::operator != ( const Matrix& M ) const

return ( XMVector4NotEqual( x1, y1 )
         && XMVector4NotEqual( x2, y2 )
         && XMVector4NotEqual(x3, y3)
            && XMVector4NotEqual(x4, y4)) != 0;

The issue is that the first call XMVector4NotEqual will return false, because the first vector is equal, so it will bail out immediately (the rest are && and it just short-circuits because the first result is false).

Replacing && with || fixes it.

That's all.
Nov 13, 2014 at 7:28 PM
Thanks for the report!
Nov 13, 2014 at 7:31 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Marked as answer by walbourn on 11/13/2014 at 12:56 PM