Ue4 and physx

hello,

while studying the unreal codebase I have come across something that I don’t quite understand in regards to UE4 vs PhysX…

here two snippets of code from the engine (v4.6)

first in “void ULandscapeMeshCollisionComponent::CreatePhysicsState()”

// Make transform for this landscape component PxActor
FTransform LandscapeComponentTransform = GetComponentToWorld();
FMatrix LandscapeComponentMatrix = LandscapeComponentTransform.ToMatrixWithScale();
bool bIsMirrored = LandscapeComponentMatrix.Determinant() < 0.f;
if (bIsMirrored)
{
   // Unreal and PhysX have opposite handedness, so we need to translate the origin and rearrange the data
   LandscapeComponentMatrix = FTranslationMatrix(FVector(CollisionSizeQuads, 0, 0)) * LandscapeComponentMatrix;
}

and then in “void ULandscapeHeightfieldCollisionComponent::CreatePhysicsState()”

// Make transform for this landscape component PxActor
FTransform LandscapeComponentTransform = GetComponentToWorld();
FMatrix LandscapeComponentMatrix = LandscapeComponentTransform.ToMatrixWithScale();
bool bIsMirrored = LandscapeComponentMatrix.Determinant() < 0.f;
if (!bIsMirrored)
{
    // Unreal and PhysX have opposite handedness, so we need to translate the origin and rearrange the data
    LandscapeComponentMatrix = FTranslationMatrix(FVector(CollisionSizeQuads*CollisionScale, 0, 0)) * LandscapeComponentMatrix;
}

as you can see in one version the LandscapeComponentMatrix is being changed because of if(bIsMirrored) and in the other if(!bIsMirrored)

the rest of the code seems fairly identical.

is this a bug in Ue4 ? or can some dev explain me a bit more about how UE4 and PhysX interact ?
The reason why i found this is because I was looking to understand how unreal generates the physics heightfield under the hood but for some reason my exported custom data seems to be rotated 90 degrees and the X axis is inverted - thus the search for the “handedness” in google which then led me to this code snippet.

any insight would be helpful.

chrys