Bug or bad setting of Havok world and rigid body?

Bug or bad setting of Havok world and rigid body?

Hello, I have two problems, first one is, that I have base platform defined as this:

hkVector4 baseSize( 50.0f, 0.5f, 150.0f);
hkVector4 basePos(0.0f,-0.25f,0.0f);
hkpRigidBody* baseRigidBody = GameUtils::createBox(baseSize, 0.0f, basePos,0);
baseRigidBody->setCollisionFilterInfo( hkpGroupFilter::calcFilterInfo( hkpGroupFilterSetup::LAYER_STATIC ) );

m_world->addEntity( baseRigidBody );
baseRigidBody->removeReference();

And rigid body defined like this:

size.set(1.0f,1.0f,1.0f); //teeter totter box
pos.set( 0.0f,3.5f, -27.0f);
rb = GameUtils::createBox(size, 0.001f, pos,0.0f);
m_world->addEntity( rb );
rb->removeReference();

After some collision is this box catapulted by teeter-totter, it gets some height and then falls onto base. Problem is, that this box penetrate little bit into the base during the impact. When is impact speed too high, it penetrate thru whole base and falls down into the free space. Where I should look for problem?

And second thing and maybe possible Havok bug is on this picture:

http://img135.imageshack.us/img135/9779/41802372ub8.jpg

Why is this cube resting on its edge? Its not normal behavior...

18 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,
For the first problem, it sounds like you need to enable continuous collision detection for the box. I'd recommend starting with MOVING quality and see how it goes from there. Check out the "Continuous Physics" section in the documentation for more info, or the DiscreteVsContinuousDemo (in PhysicsUseCaseContinuousPhysicsDiscreteVsContinuous).

For the second problem, have you tried viewing the world in the Visual Debugger? It's possible that your physics and graphics transforms are out of sync. I've also seen that behavior in the past when using MOTION_STABILIZED_SPHERE_INERTIA or MOTION_STABILIZED_BOX_INERTIA motion types - if you're using these, you should switch to the regular versions instead. Finally, it's possible that the body just deactivated in that position. Again, the Visual Debugger would help, as you could tell whether the body was active or not.

Does the second problem happen a lot, or was that the only time you've seen it?

-Chris

Hi,

Ive seen this behaviour in my simulation too. Some Boxes land on their edge and deactivate in this strange position. It happens in my simulation to one of a few boxes that I drop from some height to the ground ( each box has another starting orientation)

Thats how I initialize the Boxes motionType and Quality:

RBodyinfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA;
RBodyinfo.m_qualityType = HK_COLLIDABLE_QUALITY_MOVING;

Could this line be the reason for the behaviour?
RBodyinfo.m_solverDeactivation = RBodyinfo.SOLVER_DEACTIVATION_LOW;

I also checked my Visual Debugger and it shows the same result.

For me myself this isnt a big problem at the moment, but it would be nice to understand this behaviour

Hi guys,

What units is your world in? Is it in meters? How large is the inertia tensor that is being computed? Are you using the default world collision tolerance? I don't think that the solver deactivation is going to be having an effect since that setting is the default setting.

Would it be possible for one of you guys, if Chris's suggestions don't work, to post or send over a snapshot of your world with the box behaving badly.

Thanks,
Sean

Developer Support Engineer
Havok
www.havok.com

Hi,

1. Units
I didnt change the scale or the units of my world and could not find any code that seems to change this values (I am very new to Havok and sometimes things happen without a purpose while trying and testing).

2. InertiaTensor
The inertia-Tensor Matrix of all my Boxes looks like this:
208.333, 0, 0
0, 208.333, 0
0, 0, 208.333

3. collision tolerance
My tolerance is at 0.1 like the default. I tested a few values and with 0.1 - 0.4 the box lands and deactivates on its edge. With 0.5f the box doesnt deactivate on its edge and behaves normal. But with 0.6 and 0.7 it again lands on its edge and deactivates in this position.

This is for me at the moment not understandable, but I hope I could help you with this.

4. Snapshot

I can try and record the visual debugger if you want. If you really want to see something just tell me.

Hi guys,

I was able to reproduce what you are seeing by setting the inertia tensor really high in relation to the object's mass. Are you using the hkpInertiaTensorComputer::computeShapeVolumeMassProperties() function to compute the inertia tensor or are you setting it manually? I would say, don't increase the mass of the rigid body. Decrease the inertia tensor.

For a rigid body that was 2m along each axis and had a mass of 10, the inertia tensor was about 7 along the diagonal.

Let me know if that helps.

Thanks,
Sean

Developer Support Engineer
Havok
www.havok.com

Hi everybody,
Im looking for some strange or bad behaviour of Havok for my Bachelor work. So if you have something please write it here, my job is to find some bug and then work out some solution to this not happen.

For example if you have very fast object with default collidable quality it will fly thru the another object without any collision. So you must set motiontype to HK_COLLIDABLE_QUALITY_BULLET and then is it fine.
This is very basic example and not definitely bug(its about setting and lot of strange behaviours are only about bad setting of object or world) but this is something what I am looking for (but real bug in Havok is also welcomed :) )

Thanks to all

Paul

Hi Paul,

I am curious how this relates to your Bachelor work. This is more of a personal inquiry than anything. What kind of class is this for?

The situation you described below is kind of a classic physics simulation problem, the bullet through paper problem. Turning on HK_COLLIDABLE_QUALITY_BULLET means that it does continuous collision detection which is Havok's solution to the problem. I am sure that you will be able to find interesting problems on the forum and you can probably find more general physics simulation problems by searching online.

Thanks,
Sean

Developer Support Engineer
Havok
www.havok.com

Hi Sean,
This is Bachelor work for whole my three years studies at university. Its for our Center of Computer Graphics and Visualisation. Half of my work is to understand Havok, make some demos and write some kind of Czech manual-How to start with Havok. And second half is about making set of tests to find some bugs or weird behavior in physic engines, find something specially in Havok and how to solve it.

Hi Paul,

Very cool. Let me know if you have any questions.

Cheers,
Sean

Developer Support Engineer
Havok
www.havok.com

Quoting - sean.thurston
Hi Paul,

Very cool. Let me know if you have any questions.

Cheers,
Sean

Hi Sean, so I got around 8 tests finished now and first problem is : I have one box 1x1x1m with restitution set to zero, this box stands on the fixed base(which is also set restitution to zero). Then I drop off the same box from height 20m to land exactly on the first box. Problem is, that there is still some bouncing and its not possible to build this way more than three boxes at each other(to make some stable pillar).
How can I turn off this bouncing? I expected clear impact without any bounce so I could build this way stable pillar with infinitive height?

Hi Paul,

It is going to be hard to remove all the energy from the collision in this case. I would say that if you wanted to stack boxes like this, I would use a collision listener. You should be able to zero out the velocity of the riid body when the contact point is added. If you are using 6.5, a kind of new restitution model was added. You can try manipulating the m_contactRestingVelocity value to see if that gives you any different results.

Cheers,
Sean

Developer Support Engineer
Havok
www.havok.com

Quoting - sean.thurston
Hi Paul,

It is going to be hard to remove all the energy from the collision in this case. I would say that if you wanted to stack boxes like this, I would use a collision listener. You should be able to zero out the velocity of the riid body when the contact point is added. If you are using 6.5, a kind of new restitution model was added. You can try manipulating the m_contactRestingVelocity value to see if that gives you any different results.

Cheers,
Sean

Hi Sean,
So I moved from 6.0 to 6.5 and tried m_contactRestingVelocity setting but nearly without any effect (just a little bit different behaviour but no impovement). I tried to implement collision listener and set velocity of two colliding rigid bodies to zero, but I dont know how can I change velocity of the rigid body A or B from the event (I am using example from the demo- Physics->Api->Collide->Collision Callbacks->Collision Events
void MyCollisionListener::contactPointAddedCallback( hkpContactPointAddedEvent& event ).

During this testing I tried to change size of these boxes from 1x1x1 to 10x0.1x10 (for better stability) but another problem came up. These boxes look like papers(I will call them papers) and when is in the stack around 30-50 "papers" - then whole stack is unrealisticly bouncing(even when restitution of every object in the scene is set to zero).
When there is around 60 papers, bouncing is really big and some papers are unrealisticely pulled out of the stack.
When I continue in adding papers, whole stack became unstable and fall down.

Hi Paul,

Couple of things on this one. I want to point you to a stacking demo, the BenchmarkSuiteDemo. It does some stacking, not dropping and stacking, but I think it would still be good to look at.

iIn terms of setting the linear velocity of the bodies, use hkGetRigidBody(event.m_bodyA->getRootCollidable()). That should give you the rigid body and then if you want to force it you can use the setLinearVelocityAsCriticalOperation() function to set the velocities of the body.

From running some tests, there are some ways that you can tune the engine a little to get better results. Try setting the qualityType of the rigidbody up to QUALITY_BULLET. Try turning up the SOLVER_TYPE to be something higher. Try different values and see what result you get. This will probably make the simulation a little slower, but if these are tests then that shouldn't matter so much. Try turning up the linear and angular dampening of the rigid body up a little. Try not to drop the boxes from such a great height onto the stack. Higher velocity when it hits the stack is going to be bad. Trying letting the stack settle before you add the next box. Try setting the mass of the body lighter as you move higher up the stack.

I think that if you try some of those, you might start seeing some better results. It is going to be difficult to remove all the energy out of a collision. When you start putting more and more force down on a box, the bodies can start to get close to penetrating. In order to prevent this a force is applied and the bodies get pushed apart. This can then impart a force all the way through the stack and you get a bounce.

Let me know how that goes.

Cheers,
Sean

Developer Support Engineer
Havok
www.havok.com

Hi Sean,
thanks for your previous post, it was very useful.
I finished all of my tests and now I would like to solve the 3 remainings where I have still some problems.

Test1: There is small box (1x1x1m and 5kg) and on this box(right in the middle) is another much much bigger and heavier box (10x10x10m, m=5000kg).
Restitution set to zero, friction=1. When I have standard world solver (i think its 4 iters medium) the big box pull down small box into the base without any resistance.
When I set world solver to 8iters hard (I think its the best I can use) behavior is much better but still not what I expected. Big box is bouncing on the small box until it fall down on the side and then after some unrealistic bouncing are these rigid bodies deactivated. Bullet quality mode doesnt help.

Test2: Pendulum and energy - this test is very very similar to the Stiff spring demo. I count global energy of the pendulum body in every frame (sphere with m=1kg). Why pendulum looses energy? About 50% of energy at the begining is damped until system stop loosing energy (it can be seen by eye - penulum aplitude after one minute is much lower than in begining and stops getting lower at some height-then it pendulate forever).

Test 6: I have problem with dumping also in such a primitive thing like: ball with restitution set to 1, base also set to 1. Ball is dropped from some height and bounces. But it have smaller and smaller amplitude until it stops bouncing. Is there some air resistance or something build in Havok 6.5? I think that I hadnt this problem in previous version. (setting angular or linear dumping to zero doesnt help, 8iters hard also) and when I set falling ball to bullet quality it bounces higher and higher with gaining energy(like the restitution was more than 1)

Thanks Paul

Hi Paul,

Did you build all of these demos in the demo framework or did you build them into a standalone program? I would actually like to get a hold of your exact setups. If it is in the demo framework, can you pass through your code? Otherwise can you take a world snapshot of your tests so I can experiment with them a little bit.

As for the cases themselves, they mostly sound like loss of energy problems. This is pretty much the nature of real-time physics simulations. It is typically the case that it is better to lost energy than to gain energy. They also approximate things. The restitution/friction model is really just an approximation. You can try increasing those values above 1 (in the PSI case) to mitigate lost energy. Maybe try a value like 1.03. Try something like that.

Test Case 1 I still have to take a look at.

Thanks,
Sean

Developer Support Engineer
Havok
www.havok.com

Quoting - sean.thurston
Hi Paul,

Did you build all of these demos in the demo framework or did you build them into a standalone program? I would actually like to get a hold of your exact setups. If it is in the demo framework, can you pass through your code? Otherwise can you take a world snapshot of your tests so I can experiment with them a little bit.

As for the cases themselves, they mostly sound like loss of energy problems. This is pretty much the nature of real-time physics simulations. It is typically the case that it is better to lost energy than to gain energy. They also approximate things. The restitution/friction model is really just an approximation. You can try increasing those values above 1 (in the PSI case) to mitigate lost energy. Maybe try a value like 1.03. Try something like that.

Test Case 1 I still have to take a look at.

Thanks,
Sean

Hi Sean,
You can find my last build here: http://leteckaposta.cz/488955784 (its everything build in demo framework).
Problem with pendulum can be also seen in Stiff spring demo-its same setup, but only ball instead of box at the end of the constraint... (never mind if the ball or box, loosing of energy can be seen by eye).

I can send you whole my source code but not thru this forum (I dont wanna make it public and its also quite lot of code in whole project). I looked for some kind of private message here but it seems that there is nothing like that.... Can I send it to you thru e-mail? Just send me some hello message to pavel.karlik(((at)))seznam.cz (without brackets-its because of spam) and I will write you back with my whole source code.

Thanks,
Paul

Hi Paul,

Very nice demos. It looks like you have Test 6 pretty much resolved (possibly setting the restitution value a little bigger than 1).

Test 1: This is not really unexpected in my mind. You can check out this portion of the docs: Havok Physics->Havok Dynamics->Constraints->Tuning and Tweaking Constraints. This is similar to the stability issues that it talks about in there. Your masses are two different. If you make then within 10x of each other instead of 1000x, I think you will see better results. If you wanted the boxes to have those masses all the other times in the simulation, you could look at using Response Modifiers, specifically a mass modifier: Havok Physics->Collision Detection->Contact Modifiers.

Test 2: This is again an energy loss issue similar to restitution. One thing you can try is adding a little energy back into the system by having a negative linear damping. I tried -0.02 and it worked pretty well. You might see some better results with that.

Don't worry about the source. I have some test cases of my own now. Let me know if you have any other questions.

Cheers,
Sean

Developer Support Engineer
Havok
www.havok.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today