Forces acting on a btRigidBody

rvboyd
Posts: 5
Joined: Wed Jun 29, 2011 7:34 pm

Forces acting on a btRigidBody

Post by rvboyd »

I'm new to Bullet and have a question about forces acting on a btRigidBody.

Is it possible to access all the individual forces acting on a btRigidBody? I want to be able to see the individual forces (both internal (i.e. gravity) and external (i.e. friction)) that are acting on the rigid body? Or can I only access the total force that is acting on it?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Forces acting on a btRigidBody

Post by dphil »

No, from the source, it looks like applied forces are immediately added to a total. If you wanted to keep track of each individual applied force, I suppose you could subclass btRigidBody and add some custom code to applyForce and applyCentralForce and store/track them yourself.
rvboyd
Posts: 5
Joined: Wed Jun 29, 2011 7:34 pm

Re: Forces acting on a btRigidBody

Post by rvboyd »

What about other forces (ones that I do not apply) that are acting on an object? Such as a normal force?

For example, I have a 1kg box in my simulation that is resting on a plane. I have gravity defined as -10N/kg in the y direction. If I call getTotalForces() on that box during a tick callback I would expect to see that the total forces acting on the box would be zero since the box is at rest, however the getTotalForces() returns (0,-10,0). Does the getTotalForces() method only return forces that are applied to rigid bodies before collision detection has occurred?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Forces acting on a btRigidBody

Post by dphil »

If I call getTotalForces() on that box during a tick callback I would expect to see that the total forces acting on the box would be zero since the box is at rest
Why? Just because an object is at rest does not mean there are no forces acting on it. Your gravity would aways be acting on the box, so it makes sense that - in the absence of any other forces - you see a "resting" force of (0,-10,0). Mind you, I suppose one would expect an equal upward force from the ground. So, I guess I'm not quite sure how it handles forces that result from collisions. It might be possible to add a callback for collision events, which may provide the force of the collision response. I am not sure about this though.
rvboyd
Posts: 5
Joined: Wed Jun 29, 2011 7:34 pm

Re: Forces acting on a btRigidBody

Post by rvboyd »

Sorry, I meant the resultant force would be zero, not that there would be zero forces acting on the box.

Thanks for the insight, I will look into collision events.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Forces acting on a btRigidBody

Post by dphil »

Ah, right, I misunderstood. And yeah, I see what you mean. You would expect it to be 0, assuming it treats collision force just like other applied forces. However this could also be related to object sleeping/deactivation. Perhaps when an object is asleep, collision forces are ignored. Maybe print out totalFroces() at each time step as a box is dropped from a height onto a flat surface, and see what it shows around the time of the collision and shortly after it comes to rest on the surface. That could shed some light on what it's doing (or not doing) with totalForces().