Simulation speed

Naut

04-07-2007 03:36:57

When I run a simulation of a simple box falling onto a plane. (just using physx not NX) it seems to fall rather lightliy...

The simulation setup: a 1m box : dimensions(0.5,0.5,0.5) falling from 50 ogre units/meters.

Gravity is -9.8 in the y dir.

I run my mainloop as a fixed loop at 1.0f/60.0f from which i call simulate and pass in a fixed rate of 1.0f/60.0.

Is this a correct way to run the simulation?

I looked at the CCD example vs the box example for comparing fall speeds, because the boxes fall at a more realistic speed. But having remarked out all the ccd specific code the ccdbox sample still runs more realistic while in essence the code is the same (unless i've overlooked something).

(The reason i'm using vanilla physx and not nx, is that i'm going to have a server/client setup for multiplayer. So hence the server will just run physx vanilla.)

betajaen

04-07-2007 09:29:42

Pretty much, yes.

Naut

04-07-2007 19:28:02

How would i make objects fall more realistic or be heavier when they fell?

Or do they all fall at a constant rate depending on gravity... so I would need to increase gravity in order to get more realistic results?

(I'm very new at this : )

betajaen

04-07-2007 19:33:01

It's realistic as it is. So a 1m box at a mass of 100 kilograms would fall like how it would in the real world.

You can increase the gravitational constant to something higher to make it a bit more dramatic if you wish.

Naut

04-07-2007 19:54:36

Funny how all those physics classes now makes alot of sense. Drop two objects of different mass in a vacuum under a constant gravity. Result both falling at the same time.

Basically there are only two things that could be affecting my drop rate, gravity or time. Gravity is most likely the variable to tweak if i want to enhance my drop rate. But first I must ensure that the timing is correct.

One last question, it's about the SetTiming feature. If i'm using the simulate function inside a fixed timestep loop, do I want to tweak the setTime function at all from default. default being:

gScene->setTiming((1.0f / 60.0f), 8, NX_TIMESTEP_FIXED);

betajaen

04-07-2007 20:23:53

By default the NxOgre simulation is at a fixed rate of 60FPS. There is a special class to deal with it for you. So I wouldn't worry about it to much.

Adjusting the gravity would effect every Actor. So if you wanted to make one Actor fall slighty faster than an other. You could check to see if it's not sleeping (if it isn't it's probably falling, or reacting to a collision), then adjust the dampening, or even add a force.

Naut

04-07-2007 20:48:41

I ended up doing a test, and measured a 1" cube and converted it to 0.0254 meters. (Basically as if you were dropping a quarter). The fall rate seems correct now.

But the restittion doesn't seem to want to apply to such a small scale. (Or am I missing something.) I was hoping to make the object fall and not bounce at all just by setting the restitution material.

Anyhow.. I apprec. all the info it's definitely got me dusting out the old physics books : )

betajaen

04-07-2007 20:52:12

Restitution? As in Bounce? Which reminds me, I need a getMaterial function()

mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes, default-material-restitution: 0");

See if that works, if not. I'm sure there are other things that could be done.

I'm expecting my Physics books to arrive soon. I'm starting year two of my Physics Degree in Sept, and I can't wait. :)

Naut

04-07-2007 21:54:52

Edit: Ignore the following and read the post below:

I tried setting the restitution to 0 with no results. Again, it seems to be the height at which such a small object is falling.. 50m.

If the height is set to 2m, then normal restitution values work.

So I tweaked the restitution value and added a bounce threshold.... and it only works if they are set to specific values:

//box dimensions
boxDesc.dimensions.set(0.0127,0.0127,0.0127);

// SDK threshold param
gPhysicsSDK->setParameter(NX_BOUNCE_THRESHOLD, -0.001);

// default material restitution
defaultMaterial->setRestitution(0.001);


This will make a 1" box converted to 0.0254 meters dropped from 50m not bounce.

Naut

06-07-2007 00:55:01

The real problem after quite a considerable amount of tests, seems to lay in the setTiming function. Because the object is falling from such great heights, it's new position when it meets the plane is far beyond the plane. So the solver will snap the object back and give the object a bounce, even though it has a material restitution value of zero. To solve this, and make the collision solver more accurate, I suppose one could go with CCD. But instead you can use the setTiming() function will divide your simulation time into smaller pieces and catch the collision before it passes beyond the plane. Hence if your object is falling from 1000 meters, you would need to increase the number of interations and substeps of the sim.

e.g.
gScene->setTiming((1.0f / 60.0f)/64, 64, NX_TIMESTEP_FIXED);
or
gScene->setTiming((1.0f / 60.0f)/4, 4, NX_TIMESTEP_FIXED);


If i'm incorrect, please correct me. As this seems to be the best solution i've found for objects falling from great heights.