JoltPhysics icon indicating copy to clipboard operation
JoltPhysics copied to clipboard

[Feature Request] gjk treat quadratics as polyhedrons with convex radius

Open ocohen opened this issue 1 year ago • 3 comments
trafficstars

Hi,

I'm hoping there's already a way to do this, but based on what I saw while debugging the ShapeCast code it looks like when sweeping a sphere the convex radius is 0, and the sphere's support function has the radius embedded in it.

When working on past engines we've seen great stability and perf improvements by treating the sphere (and capsule) as a point (line) with a convex radius as the radius.

Is this approach supported? It seems like it should be possible based on the convex radius variables passed around, but I was seeing them as 0 for the sphere. Maybe there's a different type of sphere I am missing?

Thanks for the great library

ocohen avatar Feb 17 '24 20:02 ocohen

I think you're looking for ShapeCastSettings::mUseShrunkenShapeAndConvexRadius = true.

jrouwe avatar Feb 17 '24 21:02 jrouwe

Yes that's it, I figured there was a setting I was missing. Question - is there any reason why capsules and spheres don't always assume this is true? I get why you might not want this for convexes that have hard edges, but for quadratics is there a case where you don't want this?

ocohen avatar Feb 17 '24 21:02 ocohen

I haven't run into the issues that you're talking about yet. It wouldn't be hard to change the behavior but then I would need to do some checking if there is indeed a quality / perf difference.

jrouwe avatar Feb 17 '24 21:02 jrouwe

Hello, this is implemented now. In my tests it gave a significant performance boost.

jrouwe avatar Feb 23 '24 18:02 jrouwe

Awesome, I did something similar in our project (more hacky than yours) for spheres and capsules. Thanks for following up

ocohen avatar Feb 23 '24 18:02 ocohen