Bug in player collision debug visualization for negatively scaled boxes

Hi,

The player collision debug visualization for negatively scaled boxes is rendering the back faces, not the front faces:

[Image Removed]

The debug primitives are rendered via the dynamic mesh builder. FDynamicMeshBuilder::GetMesh() does already reverse the culling for negatively scaled meshes

Mesh.ReverseCulling = LocalToWorld.Determinant() < 0.0f ? true : false;

but in this case, the determinant is positive because FKAggregateGeom::GetAggGeom separates the scaling from the transformation:

const FVector Scale3D = Transform.GetScale3D();
FTransform ParentTM = Transform;
ParentTM.RemoveScaling();

There are multiple ways to fix it. The easiest (and worst) is to enable two-sided rendering in ShadedLevelColorationUnlitMateri. Alternatively, you could add a bReverseCulling flag to FDynamicMeshBuilderSettings and call GetMesh like this in GetBoxMesh (PrimitiveDrawingUtils.cpp)

FDynamicMeshBuilderSettings Settings;
Settings.bDisableBackfaceCulling = false;
Settings.bReverseCulling = Radii.X* Radii.Y* Radii.Z < 0;
Settings.bReceivesDecals = false;
Settings.bUseSelectionOutline = true;
MeshBuilder.GetMesh(BoxToWorld, MaterialRenderProxy, DepthPriorityGroup, Settings, nullptr, ViewIndex, Collector, HitProxy != nullptr ? HitProxy->Id : FHitProxyId());

However, we reversed the winding instead :

void GetBoxMesh(const FMatrix& BoxToWorld,const FVector& Radii,const FMaterialRenderProxy* MaterialRenderProxy,uint8 DepthPriorityGroup,int32 ViewIndex,FMeshElementCollector& Collector, HHitProxy* HitProxy)
{
...
 
	for (int32 f = 0; f < 6; f++)
	{
...
 
		// TRS CHANGE BEGIN - Georg Erhardt - 08/28/2025
		if (Radii.X * Radii.Y * Radii.Z >= 0)
		{
			MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[1], VertexIndices[2]);
			MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[2], VertexIndices[3]);
		}
		else
		{
			MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[2], VertexIndices[1]);
			MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[3], VertexIndices[2]);
		}
		// TRS CHANGE END - Georg Erhardt - 08/28/2025
	}
 
	MeshBuilder.GetMesh(BoxToWorld, MaterialRenderProxy, DepthPriorityGroup, false, false, true, ViewIndex, Collector, HitProxy);
}

I’ve tested it for boxes, spheres and capsules but only the boxes were rendering incorrectly.

No reply needed, just wanted to report the bug. Thanks!

Steps to Reproduce

  • Place a default cube on the map
  • Assign negative scaling (1, -1, 1)
  • Switch to player collision debug visualization
  • Note that the back faces are being rendered

Thanks for the bug report, I’ve passed this along to epic and will send you the public bug tracker link once it becomes available.

Regards,

Lance Chaney

Public bug tracker link is now available here: UE-316484