From aa75558dd8a645da954e5c3b099d6ef2c1392dd5 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Sun, 30 Jun 2024 19:08:45 +1000 Subject: [PATCH] Cleanup. --- .../Private/CesiumGltfComponent.cpp | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp index cf9e07b61..ba97554af 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp +++ b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp @@ -83,6 +83,15 @@ namespace { using TMeshVector2 = FVector2f; using TMeshVector3 = FVector3f; using TMeshVector4 = FVector4f; + +// We scale up the meshes because Chaos has a degenerate triangle +// epsilon test in `TriangleMeshImplicitObject.cpp` that is almost laughably +// too eager. Perhaps it would be fine if our meshes actually used units of +// centimeters like UE, but they usually use meters instead. UE considering +// a triangle that is ~10cm on each side to be degenerate is... infuriating. +// +// We scale up the collision meshes by a power-of-two factor so that only +// the exponent portion of the floating point number is affected. constexpr double scaleFactor = 1024.0; } // namespace @@ -3845,14 +3854,6 @@ BuildChaosTriangleMeshes( Chaos::TParticles vertices; vertices.AddParticles(vertexCount); for (int32 i = 0; i < vertexCount; ++i) { - // Scale up the collision meshes because Unreal has a degenerate triangle - // epsilon test in `TriangleMeshImplicitObject.cpp` that is almost laughably - // too eager. Perhaps it would be fine if our meshes actually used units of - // centimeters like UE, but they usually use meters instead. UE considering - // a triangle that is ~10cm on each side to be degenerate is... infuriating. - // - // We scale up the collision meshes by a power-of-two factor so that only - // the exponent portion of the floating point number is affected. vertices.X(i) = vertexData[i].Position; } @@ -3868,15 +3869,8 @@ BuildChaosTriangleMeshes( int32 vIndex1 = indices[index0]; int32 vIndex2 = indices[index0 + 2]; - // if (!isTriangleDegenerate( - // vertices.X(vIndex0), - // vertices.X(vIndex1), - // vertices.X(vIndex2))) { triangles.Add(Chaos::TVector(vIndex0, vIndex1, vIndex2)); faceRemap.Add(i); - //} else { - // UE_LOG(LogCesium, Warning, TEXT("Degenerate")); - //} } TUniquePtr> pFaceRemap = MakeUnique>(faceRemap);