In the meantime I thought about adding a boolean option to Cesium3DTileset
called e.g. ForceBuildChaosTriangleMeshes
or something like that. So that only if it is checked, the degenerate triangles are not discarded.
I’ve piped this option all the way from Cesium3DTileset.cpp
to the BuildChaosTriangleMeshes
function in CesiumGltfComponent.cpp
but I’m pretty sure that that’s not the best way to approach that. I’m not (yet) a C++ dev unfortunately.
In Cesium3DTileset
the function createOffGameThread
is called and from there on in CesiumGltfComponent.cpp
it’s:
loadModelAnyThreadPart
-> loadNode
-> loadMesh
-> loadPrimitive
-> BuildChaosTriangleMeshes
so I’ve added this boolean as parameter to each of those functions and the code in BuildChaosTriangleMeshes
then looks like this and does indeed work.
EDIT 2: I have created a pull request on github, just so that I can better share the code changes I made: Add option to enforce BuildChaosMeshTriangles for degenerate triangles by arbertrary · Pull Request #1456 · CesiumGS/cesium-unreal · GitHub
for (int32 i = 0; i < triangleCount; ++i) {
const int32 index0 = 3 * i;
int32 vIndex0 = indices[index0 + 1];
int32 vIndex1 = indices[index0];
int32 vIndex2 = indices[index0 + 2];
if (forceBuildChaosTriangleMeshes) {
triangles.Add(Chaos::TVector<int32, 3>(vIndex0, vIndex1, vIndex2));
faceRemap.Add(i);
} else{
if (!isTriangleDegenerate(
vertices.X(vIndex0),
vertices.X(vIndex1),
vertices.X(vIndex2))) {
triangles.Add(Chaos::TVector<int32, 3>(vIndex0, vIndex1, vIndex2));
faceRemap.Add(i);
}
}
It does, however, produce a lot of the following warnings and only once on editor startup (at least it seems like that right now) the Error callstack at the bottom. Both do not cause the editor to crash or the collision to not work.
LogPhysics: Warning: (Invalid Normal from ConvertQueryImpactHit) Non-normalized OutResult.Normal from hit conversion: X=0.000 Y=0.000 Z=0.000 (Component- CesiumGltfPrimitiveComponent /Game/Maps/CesiumWorld/UEDPIE_0_Globe.Globe:PersistentLevel.Cesium3DTileset_3.CesiumGltfComponent_7.CesiumGltfPrimitiveComponent_2)
LogPhysics: Warning: Start Loc(X=-1372.168 Y=5104.144 Z=-658.756), End Loc(X=-26133.757 Y=-31954.970 Z=-23318.980), Hit Loc(X=-1865.093 Y=4366.414 Z=-1109.849), ImpactNormal(X=0.000 Y=0.000 Z=0.000) NormalPreSafeNormalize(X=0.000 Y=0.000 Z=0.000)
LogPhysics: Warning: (Invalid Normal from ConvertQueryImpactHit) Non-normalized OutResult.Normal from hit conversion: X=0.000 Y=0.000 Z=0.000 (Component- CesiumGltfPrimitiveComponent /Game/Maps/CesiumWorld/UEDPIE_0_Globe.Globe:PersistentLevel.Cesium3DTileset_3.CesiumGltfComponent_20.CesiumGltfPrimitiveComponent_6)
LogPhysics: Warning: Start Loc(X=-1472.014 Y=5123.337 Z=-649.842), End Loc(X=-1727.085 Y=4042.166 Z=-1103.723), Hit Loc(X=-1664.978 Y=4305.417 Z=-993.209), ImpactNormal(X=0.000 Y=0.000 Z=0.000) NormalPreSafeNormalize(X=0.000 Y=0.000 Z=0.000)
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: OutResult.Normal.IsNormalized() [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp] [Line: 76]
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007ffbf12123b5 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf1195c70 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf11d407c UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf125fce9 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf13d93f1 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf1b50c57 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf1bd19d5 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5374502 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf53775b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5319da1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a1e1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5319da1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a1e1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5319da1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a1e1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5319da1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a1e1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5319da1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a1e1 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534a7b8 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf5349777 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf503d280 UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf534828f UnrealEditor-CoreUObject.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf0bbaacd UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf0bbcd2d UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf0bcf70c UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf0bcf7bd UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf0b99e51 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf2b987eb UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf2b9fd32 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf57e1c9f UnrealEditor-Core.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf57e22ae UnrealEditor-Core.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf57eeeb0 UnrealEditor-Core.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf2bc75aa UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf2bd0bfe UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf1c89839 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbf1c967a2 UnrealEditor-Engine.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbed9658f8 UnrealEditor-UnrealEd.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffbee5bea06 UnrealEditor-UnrealEd.dll!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf28af2 UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf4d28c UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf4d37a UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf50854 UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf66984 UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff7ecf69d7a UnrealEditor.exe!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffce9d47344 KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffcebd3cc91 ntdll.dll!UnknownFunction []