Velocity threshold for RigidBody?

For a beginner’s project, I thought simple orbit simulation would be interesting. I’m modeling my planets as RigidBodyControls, and I’ve managed to implement fairly simple gravitational attraction between two objects.



I would now like to be able to establish orbits by giving planets a push before applying the gravitational forces. I’m currently using RigidBodyControl.applyImpulse(foo), but below a certain value there is no change in the Body’s position. Using RigidBodyControl.getLinearVelocity I’ve detected that any resultant velocity less than .8f has no lasting effect on the planet. I say ‘lasting’ because for a fraction of a second the planet moves, but then the velocity is immediately set to zero. I’ve tried lowering the velocity and mass of the planet, but the same issue occurs.



These same results hold with gravity turned off. After setting the velocity, no further modifications are made to the RigidBodyControl on my end. If it helps, I’m extending SimpleApplication.



Ex (Earth))

new RigidBodyControl(3.3022f * (float)Math.pow(10,23))

phys_planet.applyImpulse(new Vector3f(26f * (float)Math.pow(10,22),0,0), Vector3f.ZERO);



Am I missing something?

Just a hunch: try increasing physicsspace accuracy and/or scale up your scene.

No, not necessary, just do it properly ^^ Didn’t sound as if you were understanding what you are doing or need to do at all. Personally, I’d surely not use bullet physics to simulate a planetary constellation but simply move the planets according to proper calculations.

With no gravity and friction shouldn’t the velocity stay the same as long as the simulation goes on? What does precision have to do with it?

I ended up doing the calculations myself, as per normen’s suggestion. Thanks for the advice!

Hi,



i am also doing a little orbit sim to learn and play with JME and i have noticed something strange : everything seems to go fine until i freeze all my objects by setting their velocity, rotation and gravity to 0.

my physics listener loop then recompute gravity as expected (i monitor it on the hud) but the velocity on my objects are not affected anymore.



Is it as if the gravity works only on object who are already moving. Am i missing something ?



thanks.





ps: gonna try the advice of giving up with physics for such a simple project, bu my question remains valid.

What probably happens is that bullet freezes objects that it believes is in rest (moves very slowly), I encountered this problem too.

It might be a bug in jbullet, because it seems it ignores angular velocity altogether when determining to freeze or not thus causing unexpected freezes… (in c++ bullet the objects that freezes are usually those that are already still, making it transparent to the viewer)



If a body is frozen, it will not respond correctly to by-code applications of forces and impulses unless its un-frozen.



There was a setting in the c++ version of bullet that disabled this hibernation mode completely for a body, probably it exists in jbullet too.

I will need it for my project, Ill post here if I find it.

1 Like

RigidBodyControl.setSleepingThresholds(0, 0);

1 Like
ps: gonna try the advice of giving up with physics for such a simple project, bu my question remains valid.


ps: dont give up on stuff :P

You guys ever tried calling activate()?

Javadoc says: “reactivates this PhysicsRigidBody when it has been deactivated because it was not moving”

THANK YOU TRANSCENDENT! I created an account just to say thanks for your setSleepingThreshold suggestion. Spent forever trying to figure out what was going on in my program. It’s working great now :D:D

1 Like