intersecting bodys on impact and in rest

M1tchken

11-11-2008 15:36:40

hi !

I'm new to this forum so goodday to all :)


I'm working on an arcade game and because I had some experience with newton and we all love ogre :), I decided to work with Ogrenewt.


There is one major problem i'm dealing with now. I can solve it using some workarounds but it has major effects on how the physics respond.

Here's the problem:

http://www.mitchvl.net/Problem.JPG


As you can see, my player has an ellipsoid collision mesh. That collision mesh works great on horizontal platforms, although i had to correct the player's Y position when impacting on ground, because it was intersecting with the ground and almost didn't correct itself.

As you might think that's a pretty big problem when the ground level suddenly changes from horizontal to a slope (hangbridge) like on the screenshot. Even worse, in this case the ground is dynamic and has it's own physics, so i had some really weird looking physics when the Y correction was enabled.

So i disabled the Y correction for the bridge and all looked great. except when the player is not moving, it started to slowly dig itself in the ground. You should probably know there is a constant gravital force on the player, if i disable this, the hangbridge physics are all screwed because the bridge needs the playerforce to hang.


I hope you all understand my problem. What's the point in collision physics using a physics library when you have to manually correct positions on impact?


I hope there is someone out here that can help me.


greets

M1tchken

12-11-2008 11:50:34

here is a movie of the problem: http://www.mitchvl.net/movie.wmv

micken

14-11-2008 06:20:05

Well you can start from the root of your problem. Somehow the ellipsoid collision mess is letting your terrain intersect with it. How to solve this?

1) Use a CustomContactCallback to position the player each time the ellipsoid and terrain contact and have it place the bottom most vertice of the ellipsoid at the point on the terrain most directly related to that of the bottom most vertice.

2) Create a continuous collision between your terrain and the player. This way the 2 will always be checked for collision and you can prevent them from ever intersecting eachother.

M1tchken

14-11-2008 13:50:15

Well you can start from the root of your problem. Somehow the ellipsoid collision mess is letting your terrain intersect with it. How to solve this?

1) Use a CustomContactCallback to position the player each time the ellipsoid and terrain contact and have it place the bottom most vertice of the ellipsoid at the point on the terrain most directly related to that of the bottom most vertice.

2) Create a continuous collision between your terrain and the player. This way the 2 will always be checked for collision and you can prevent them from ever intersecting eachother.


i've done both :) but if i correct the players position the hangbridge physics will not be accurate.

walaber

14-11-2008 16:36:56

what scale are you using for your objects, and what units for mass?

Usually penetration problems in Newton come from using very small scale for the objects, or improperly calculated mass / inertia values.

can you give some examples of the size, mass, and method of inertia calculation for the objects in question?



also, how are you moving the player around the world? are you using forces, or are you just calling setVelocity manually?

M1tchken

14-11-2008 17:25:49

what scale are you using for your objects, and what units for mass?

Usually penetration problems in Newton come from using very small scale for the objects, or improperly calculated mass / inertia values.

can you give some examples of the size, mass, and method of inertia calculation for the objects in question?



also, how are you moving the player around the world? are you using forces, or are you just calling setVelocity manually?


1 block in the level as you can see in the screen and movie are 100 units big. The mass of the player is 80.0 and is calculated with the momentofinertia::blabla function.

Real mass = CHAR_MASS; // is 80.0f
Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid(mass, size);
m_pPhysicsBody->setMassMatrix(mass, inertia);
m_pPhysicsBody->setAutoFreeze ;
m_pPhysicsBody->setCustomForceAndTorqueCallback(boost::bind(&Character::ForceCallback, this, _1));
m_pPhysicsBody->setMaterialGroupID(m_MatID);
m_pPhysicsBody->setUserData(this);
m_pPhysicsBody->setContinuousCollisionMode(1);



i only use setvelocity for jumping. other movements are forces

M1tchken

15-11-2008 17:48:37

I've scaled everything down with factor 0.01.


Now everything works perfectly, so it was idd a scaling problem.


golden tip:
ALSWAYS CHECK YOUR SCALE WHEN WORKING WITH A NON SCALABLE PHYSICS ENGINE :p


thx 4 all the help !!