bepuphysics2 icon indicating copy to clipboard operation
bepuphysics2 copied to clipboard

Coefficient Of Restitution

Open Blwnkl opened this issue 6 years ago • 3 comments

I'm trying to create BodyDescription entities that represent "rubber bumpers": zero "local inertia" (i.e. - kinematic objects), but I need to specify the COR somehow. I note that the "Material" class went away in V2, and I think that somehow "SpringSettings" might be relevant to what I need; but not sure. I guess the best way I can pose the question is: what's the high-level API point-of-contact that I should access to achieve this? Thanks!! Jim

Blwnkl avatar Oct 16 '18 17:10 Blwnkl

Coefficient of restitution is not currently supported: https://github.com/bepu/bepuphysics2/issues/3 https://github.com/bepu/bepuphysics2/blob/master/Documentation/QuestionsAndAnswers.md#where-is-the-bouncinessrestitution-material-property

You can indeed do something kinda-sorta-similar with spring settings. All contact materials are defined by the INarrowPhaseCallbacks.ConfigureContactManifold callbacks that are defined when the Simulation is created. You can use something like the BodyProperty<T> helper to store per-body information for the callbacks to check. The RagdollDemo does something similar for collision filtering.

But you'll run into the some of the same issues that currently block coefficient of restitution support. Speculative contacts fundamentally don't play well with any kind of bounciness. You could try updating at a higher rate (e.g. 600hz instead of 60hz) and using much smaller speculative margins, but it'll still be very difficult to get exactly the same behavior as you would get from a coefficient of restitution.

You could also use a hack. Use the narrow phase callbacks to detect when a new collision occurs, cache the approaching velocity, and then manually apply a 'bounce' response.

RossNordby avatar Oct 17 '18 00:10 RossNordby

Reopening just so people wondering where the heck bounciness is have an issue to look at.

RossNordby avatar Apr 19 '19 23:04 RossNordby

Added a demo showing how to get bounciness without a coefficient of restitution: https://github.com/bepu/bepuphysics2/blob/master/Demos/Demos/BouncinessDemo.cs

RossNordby avatar Oct 25 '20 20:10 RossNordby