Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to enforce BuildChaosMeshTriangles for degenerate triangles #1456

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arbertrary
Copy link

@arbertrary arbertrary commented Jun 17, 2024

Currently, Cesium discards degenerate triangles in the function BuildChaosMeshTriangles in CesiumGltfComponent.cpp.
This causes collision to not work for the discarded triangles.

  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 (!isTriangleDegenerate(
            vertices.X(vIndex0),
            vertices.X(vIndex1),
            vertices.X(vIndex2))) {
      triangles.Add(Chaos::TVector<int32, 3>(vIndex0, vIndex1, vIndex2));
      faceRemap.Add(i);
    }
  }

https://github.com/arbertrary/cesium-unreal/blob/b6b26aa823bdcbcad41cd44c3d7ab2aa86953a74/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp#L3821C1-L3834C4

As described and discussed with @kring in this thread on the Cesium community forums, there might be cases where users would want to enforce that these degenerate triangles are not being discarded.

https://community.cesium.com/t/line-trace-passing-through-cesium3dtileset-on-high-lod/27485

This pull request is a naive approach to adding a boolean option to the Cesium3DTileset actor which a user can activate to enforce this behavior.

Most likely this is not a sensible solution to that issue (dragging that boolean through ~5 different functions seems a bit excessive) but it might serve as a starting point.

… triangles when building chaos mesh triangles in GltfComponent
@kring kring added this to the July Release milestone Jun 24, 2024
@kring kring self-requested a review June 26, 2024 05:04
@kring
Copy link
Member

kring commented Jun 26, 2024

Thanks for the PR @arbertrary!
It's unfortunate that we need this, but I think it's a good stopgap workaround until we can investigate more thoroughly what's going on here. I'm going to make a few changes to avoid threading the bool through and then I'll merge this.

@kring
Copy link
Member

kring commented Jun 30, 2024

Hi @arbertrary I spent some time digging into this problem today, and I think I've found a good solution:
#1465
So we're going to hold off on adding this new option for tomorrow's release, and hopefully ship a complete fix next release.

@kring kring removed this from the July Release milestone Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants