jrouwe/JoltPhysics

[Feature request] A way to clear mCachedResult in Shape Settings

Closed this issue · 1 comments

I had a use case where I was trying to do create a shape instance, detect error and sanitize only if there is an error (childShape is a MeshShapeSettings instance):

        auto createdRef = childShape->Create();
        if (createdRef.HasError())
        {
            // Remove degenerate and duplicate triangles, then try again
            childShape->Sanitize();

            createdRef = childShape->Create();
            if (createdRef.HasError()) // still has error from cached result
            {
                return;
            }
        }

I can't see a way in the API to clear mCachedResult so that this is possible. This is because in my use case, most meshes have no error, but the few that do should be sanitized. I figured it'd be better performance to not require sanitize before create each time.

I've added Shape::ClearCachedShape.