Center of Mass Shifting

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Center of Mass Shifting

Post by RJNelson68 »

I would like to know if there is a way to shift the center of mass of an rigidBody without offsetting the collision object position? I've been looking around the forum and all of the solutions I saw seem to handle it that way or use a part of a compound object. This seems impractical and I am hoping there is a better way.
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Center of Mass Shifting

Post by RandyGaul »

The center of mass is calculated based off of the makeup of a shape. I don't know about bullet specifically, but in an engine that supports compositions you should be able to displace your collision model in model space in order to shift its center of mass, without modifying the composition's transform position (graphical position).

Other than this displacement, you'd need to modify various portions of a collision object's density. A non-uniform density will shift the center of mass towards the location with the most mass. Non-uniform density isn't something that I really ever hear about being used in physics engines. Usually it's easier to make a composition of convex polyhedra, and assign various density values to the separate pieces.
sphet
Posts: 38
Joined: Mon May 06, 2013 6:14 pm

Re: Center of Mass Shifting

Post by sphet »

I too wonder about this - and looking at some other physics systems most of them solve it with a 'transform' shape or some kind of offset.

One exception seems to be in Havok Physics, which has a center of mass (COM) vector which is applied when gathering the matrix for a body prior to solving. In my head I wonder is it as simple as that? When using the rigid body's matrix for solving, can we not just offset it by the COM vector, and then restore it after solving?

I plan on trying this as the overhead of another shape in the collision detection methods and the game-side shape hierarchy traversal shows up in our profiler (slow platform) and I would like to streamline the shape hierarchy and collision detection system. I am working with an existing proprietary physics engine that needs a lot of optimizations.

Any thoughts on this from other people - my maths are not super and so I likely am oversimplifying the problem.

S
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Center of Mass Shifting

Post by Dirk Gregorius »

For me the body position and center of mass are two different things. Usually the center of mass is just defined in the local frame of the rigid body and all solver calculations are applied there. After the physics engine moved the center of mass you simply update the position accordingly.

I recommend Box2D if you are looking for a good example how this works. It also shows how to build the inertia relative to the body frame and then shifting it to the center of mass. This is how things are done in most physics engine to my best knowledge. Anything else would seem like an unnecessary limitation in my opinion.
sphet
Posts: 38
Joined: Mon May 06, 2013 6:14 pm

Re: Center of Mass Shifting

Post by sphet »

Dirk,

Your suggestion that all physics systems work this way makes sense to me, but my understanding of bullet is that the COM is fixed to the body's position, and an offset in the 'shape hierarchy' is required to have offset COMs. Perhaps I have read the documentation wrong.

Havok does not have this - I cannot speak for PhysX or other system.

A question:

I took a look at box2d, thanks for the pointer. Similar to Havok, the center of mass is stored within a sweep structure, so that the COM can be interpolated. Is this required if I am not using swept collisions?


Regards,

S
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Center of Mass Shifting

Post by Dirk Gregorius »

No, you only need the sweep structure for CCD, so you can just store the local center of mass and a potential cached global center of mass on the rigid body. You would need to keep the world position and world center of mass in sync though.
Post Reply