Page 1 of 1
Super-bouncy boxes.
Posted: Tue Apr 16, 2013 2:41 am
by majik00
So, I have columns of boxes which are connected to another kinematic box (floor) with a PrismaticJoint. If there's just one or two boxes, they seem to fall fine, but the more there are, the bouncier they get. Even the box on the floor (not the actual floor) can start bouncing even higher than it's original position. The chain reaction of the column of boxes bouncing off of each other could be never ending. All of the cube's material's bounciness is set to 0. Is there something else I'm missing to allow the boxes to act more rigid? I appreciate any help, I'm relatively new to Bepu.
Re: Super-bouncy boxes.
Posted: Tue Apr 16, 2013 3:14 am
by Norbo
One option would be to increase the Space.Solver.IterationLimit. It defaults to 10 which is high enough for most things, but 'difficult' configurations can require more. In addition, you may find that the minimum iteration count, SolverSettings.DefaultMinimumIterations, should be increased to stop the solver from short circuiting too early on any given pair because the impulses can take a while (in terms of iterations) to propagate.
Another brute force option is to update the space more frequently and use a smaller time step. The time step can be changed in the Space.TimeStepSettings.TimeStepDuration.
There's also another option that has been floating around on the to-do list for a while. Regular constraints can be made 'soft' and allow partial constraint violation, but collision softness is currently highly rigid and unconfigurable. Extremely rigid systems can be very difficult to solve and tend to result in more instability (like bouncing!). Just adding a configurable universal softness parameter for collision would go a long ways, but there may be some better alternatives.
Re: Super-bouncy boxes.
Posted: Tue Apr 16, 2013 3:24 am
by Norbo
By the way, if you'd like to play around with collision softness, adding it only requires changing two lines in the ContactPenetrationConstraint.
Change the first line of the SolveIteration function:
Code: Select all
float lambda = (RelativeVelocity - bias) * velocityToImpulse;
to:
Code: Select all
float lambda = (RelativeVelocity - bias + SOFTNESS * accumulatedImpulse) * velocityToImpulse;
And then, midway through the Update method at around line 176, change:
Code: Select all
velocityToImpulse = -1 / (entryA + entryB);
to:
Code: Select all
velocityToImpulse = -1 / (SOFTNESS + entryA + entryB);
SOFTNESS in the above should be some nonnegative value. 0 is completely rigid. Higher values make collision response squishier. Setting it to 0.2 and shooting a ball in the WallDemo, for example, feels like the ball is some kind of viscous blob. 0.02 is pretty rigid, but still has a very slight damping effect.
Re: Super-bouncy boxes.
Posted: Tue Apr 16, 2013 4:40 am
by Norbo
I went ahead and
added CollisionResponseSettings.Softness since it can help quite a bit in some cases.