[Solved] Strange rotation behavior

Nitori
Posts: 2
Joined: Fri Aug 30, 2013 1:49 am

[Solved] Strange rotation behavior

Post by Nitori »

I'm working on basic bullet integration, and I'm running into a very odd behavior. I drop a "box" onto some terrain, but for some strange reason it keeps settling on the corner. It will fall down and bounce a bit, but you'd expect it to land on one of its faces. I've tried rolling it down a hill just to make sure it's not just a perfect drop angle, but it exhibits similar behavior.

This is what I mean (the yellow dot is the debug drawer registering a contact point):

Image

I have a few theories on the source of the problem, but I'm not really familiar with debugging 3D physics:
  • Each sub-block is represented as a child shape in a larger compound shape. There are two compound shapes in this scene, one for the "box" and one for the (entire) terrain. I know there's a performance hit for having the terrain all in a single shape (since the AABB is huge), but I'll deal with that later. However I'm not sure if compound shapes this large cause issues.
  • The inertia for the "box" is calculated by just calling calculateLocalInertia with a mass of 150. This is being calculated as (312, 250, 162), and I don't remember enough from physics in uni to know if that value makes sense.
I'm almost certain I'm doing something dumb, but I've checked everything else I can think of. I ran a full wire-frame view (though it's really slow since it has ~1 million line segments to accumulate) and I can see that my engine render matches the Bullet-side world.
Last edited by Nitori on Fri Aug 30, 2013 9:59 pm, edited 1 time in total.
Nitori
Posts: 2
Joined: Fri Aug 30, 2013 1:49 am

Re: Strange rotation behavior

Post by Nitori »

Found the source of the problem. I was conflating the ideas of inertia and center of gravity in my head, and thought that setting inertia set the center of gravity properly. However that is not the case: in Bullet it seems the center of gravity is always at the origin of the shape (with no way to change it, which is a bit silly).

Everything behaves as you'd expect it to now by just moving the the center of the shape to the origin:

Image