Why would two different functions which return exactly the same value cause different results?

Ok, I think this one has broken my brain,

I have a custom SkeletalMeshComponent, and I override GetRenderMatrix().

Now, I have two functions, let’s call them GetRenderMatrix_Old() and GetRenderMatrix_New(), both defined as const, and they both return an FMatrix in the form of:

FMatrix adjTransform = ComponentToWorld.ToMatrixWithScale() * AdjustedViewProjectMatrix * InverseOldViewProjectMatrix

return adjTransform;

Now, when debugging, they both give EXACTLY the same numerical values for the all the components that make up the matrix (ComponentToWorld, AdjustedViewProjectMatrix, InverseOldViewProjectMatrix), as well as the final result (adjTransform ).

What totally breaks my mind is that when using GetRenderMatrix_New() instead of GetRenderMatrix_Old(), the actual rendering of the mesh is totally messed up. Please note that both functions are defined as const (so they cannot change class members) and they take no input parameters.

I am seriously 75WAT here.

Does anyone have any ideas how I can even begin to figure out what is going on here?

The first thing that comes to my mind is that you are accessing resources that reside on the render thread form the game thread, can you please share a bit more about the role of those matrices?

Hi lion,

Thanks very much for having a look.

Indeed, there was originally a problem with accessing resources on the game thread from the render thread, however, my workaround included circumventing this and I made a very tiny mistake (in one version the near clipping plane is retrieved from the local Player’s Sceneview, which evaluation to 5, whereas in the other function it was hardcoded to 3).

I missed this tiny difference in values when debugging, and nearly broke my brain in the process.

So, all is sorted now. If you’d like to have a look at the thread with all the details, you can find it here,

Thanks again!