Transform to matrix gives different result

hi guys ~_O, in a material, I want to check whether a vertex is inside a UBoxCompoent or not! to do that i send the inverse transform and the extent of the box to the material.
when i get inverse transform with below code everything works fine

FMatrix matrix = boxComponent->ComponentToWorld.ToInverseMatrixWithScale();

but with this code

FMatrix matrix = box->ComponentToWorld.Inverse().ToMatrixWithScale();

when i set nonuniform scale and nonzero rotation to my box it gives wrong result! i don’t understand why they give different results !? O_o

Hey UP033,

You are seeing a different result because of the way the Inverse gets calculated. Technically the result is the same but a few of the values end up being assigned as -0.000000000 instead of 0.000000000.

Such as:

The top result being:

FMatrix MatrixTestOne = Box->ComponentToWorld.Inverse( ).ToMatrixWithScale( );

And the bottom:

FMatrix MatrixTestTwo = Box->ComponentToWorld.ToMatrixWithScale( ).Inverse( );

I suggest that if one of these methods is working for you, use that one.