Closed Vercidium closed 3 months ago
I came across this post that the old Bepu forums which suggested modifying the InverseInertiaTensor of the cylinder:
var cylinder = new Cylinder(0.8f, 22.0f);
var inertia = cylinder.ComputeInertia(50.0f);
inertia.InverseInertiaTensor.YY *= 0.1f; // <------- Fix here
var body = BodyDescription.CreateDynamic(pos, inertia, simulation.Shapes.Add(cylinder), 0.1f);
var handle = simulation.Bodies.Add(body);
This worked perfectly! Video here. I then changed the SpringSettings from (30, 1)
to (1, 30)
to reduce how much it bounces when it lands.
This post about rigid bodies also explains why this issue occurs. Their solution was to set the angular velocity back to zero every frame, or adjust the angular drag. I don't think adjusting the drag is possible is it?
For future reference, things that didn't fix the spinning:
Cylinder
to a Capsule
50
to 5000
SpringSettings
MaximumRecoveryVelocity
SolveDescription
from (10, 10)
to (100, 100)
or (1, 1)
Possible workaround:
FrictionCoefficient
so the cylinder slides down the hillYou're correct that this is related to inertia, in particular how highly nondiagonal inertias interact with angular integration. The default demos callbacks specify AngularIntegrationMode.Nonconserving
since it's usually fine, stable, and quick.
For long shapes like a tree, it's less good. Changing it to AngularIntegrationMode.ConserveMomentumWithGyroscopicTorque
should help.
Of course, beefing up the axis of minimum inertia (by scaling down the inverse) is a perfectly cromulent workaround for games.
I'm having some strange issues with cylinders, where they spin quickly and take a while to fall down. I'm using the Characters demo from this Github repo.
Video of the issue
I've played around with different dampening, friction and spring settings but can't figure out why this is happening. I'd like the cylinder to fall down regularly, have a tiny bit of bounce, and roll around a bit.
I have the following Contact settings:
Simulation settings:
Dampening settings:
Cylinder creation:
Terrain creation: