Always-Active Rigid Body Vibrating at "Rest"

Post Reply
Xenoprimate
Posts: 14
Joined: Fri Jun 26, 2015 4:59 pm

Always-Active Rigid Body Vibrating at "Rest"

Post by Xenoprimate »

Hi guys, I have a 'ball' ontop of a platform that I can tilt according to user input. Here's a screenshot:
ballOnPlatform.png
ballOnPlatform.png (747.57 KiB) Viewed 4299 times
Anyway, the ball has its performance deactivation disabled, because it's the main game entity (e.g.

Code: Select all

setActivationState(DISABLE_DEACTIVATION);
). However I've noticed that when it comes to rest the ball's velocity keeps increasing, and as such the ball 'vibrates' on the spot, which is rather immersion-breaking.

Its velocity is increasing in the direction of gravity, and the component of the velocity in the 'down' direction gradually goes from almost 0 to higher and higher over time. The ball seems to 'sink' slightly in to the platform and then be reset on top of it again over and over again. After leaving it for about a minute, the velocity goes to about [0, -50, 0], and gravity is [0, -490.50, -0]. At this point the ball almost sinks 25% of the way in to the platform before being set on top of it from frame to frame. The ball has continuous collision detection enabled. If you're curious about the scale, the ball's radius is 4.0.

So my question is: Is there a way either to stop the velocity being set incorrectly, or failing that, to stop it vibrating?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Always-Active Rigid Body Vibrating at "Rest"

Post by drleviathan »

Even though it is the main game entity it should be possible to make it do what you want while allowing it to go inactive in the physics simulation. I would recommend figuring out how to make your game without resorting to setActivationState(DISABLE_DEACTIVATION). You can activate it directly using btCollisionObject::activate() on its btRigidBody so there is no need to worry about it getting "stuck" in a deactivated state.
Xenoprimate
Posts: 14
Joined: Fri Jun 26, 2015 4:59 pm

Re: Always-Active Rigid Body Vibrating at "Rest"

Post by Xenoprimate »

Thanks for the insight.

I'm not sure if that would be suitable, because the ball, at any point, may be collided with by independently-moving objects. In the end, I would be resorting to calling ::activate() on it every frame, before the physics tick.

Furthermore it feels like a sticky plaster over the issue. Is there no way to get the behaviour I want?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Always-Active Rigid Body Vibrating at "Rest"

Post by drleviathan »

When a ball at rest (inactive) gets hit by a moving object (active) the physics simulation will automatically activate the ball. Real activation triggers (i.e. collisions) in the physics engine are handled properly, however if you were driving the ball with an external trigger (e.g. keyboard) then you would need a API hook for activating the ball -- which is what btCollisionObject::activate() is for. It isn't plaster at all -- it is the correct way to tell the physics simulation that it should activate the object because of custom game-driven logic.
Post Reply