Bleeding Spheres restitution>.4 get infinite micro bounce

toglia

18-05-2008 23:39:32

NxHello!

My scene right now is extremely simple:

1)Floor is turned on.
2)created material with restitution = 0.4, could be higher though.
3)created 20 spheres at random heights and position with that Nxmaterial.

Play!

These spheres fall, bounce, collide, and stop bouncing as normal. But I noticed when doing some closeups they never stopped bouncing! :shock: They kept jumping very very little, I would say like 1 mm, forever! I even added a little angular damping and they stoped rolling but kept bouncing. To see it you have to do a good closeup.

Right now I can't post my code cause I'm not at home, but I will if its necessary.

Any clues? Thanks for the attention.

toglia

19-05-2008 06:03:20

toglia, you knew you had the gravity too high and the scene timing was left normal, you fool! :twisted:

Fixed it by leaving my gravity high ( I had to change it cause my models are not real size and they fall very slow), but I pushed down my timing to compensate the accuracy of the simulation.

mScene->getNxScene()->setTiming(1.0f / 150.0f, 8, NX_TIMESTEP_FIXED);

I also solved it by increasing the linear damping and the sleep energy threshold, but that's just a bad way of doing it cause those little bounces stop only when the body stops completely, meanwhile it's trembling...

Don't know if its the best way of solving the speed issue but it works for me...

betajaen

19-05-2008 11:31:54

Try increasing the sleep linear threshold. You shouldn't need to mess around with the scene timing.

toglia

19-05-2008 18:47:13

But its the only way I have managed to get a good physics accuracy with fast moving objects.

You remember the little spheres inside the big one? I got it working perfectly but later on I found out that these little spheres got out constantly. Every time something made the little spheres do a rapid movement they just got out. Terrible... I fixed that by decreasing the timing which I think does more physics calculations per second and pushing up the gravity value to compensate that the scene gets really slow...

I know there's something called CCD (Continuous Collision Detection) but I think I read somewhere that it only works for convex shapes, I have spheres...

By the way is CCD available in bleeding? I could do a convex with less than 255 verts that looked like a sphere. Although I would suspect the rolling got clumsy.

betajaen

19-05-2008 18:51:01

No, CCD isn't in bleeding yet - due to storage of skeletons not being in the resource systems.

Instead of messing around with decreasing the timing. Try increasing the sub-steps on the solver (SceneController), and increasing the sub-steps on each actor you determine special.

Aiursrage2k

20-05-2008 04:49:18

Set the sdk parameter.
NX_BOUNCE_TRESHOLD
A contact with a relative velocity below this will not bounce. (range: (-inf, 0])

betajaen

20-05-2008 10:36:50

Good catch! Toglia, it's this in NxOgre.

mWorld->getPhysXDriver()->setBounceThreshold(x)

Or Params for World:

bounce-threshold: x

toglia

01-06-2008 01:14:44

Hello again,

thanks for the tips! But there's one thing that I still don't get:

Try increasing the sub-steps on the solver (SceneController), and increasing the sub-steps on each actor you determine special.

If I do mScene->getSceneController()-> I only get two unprotected methods "Simulate" and "getType". I tried using Simulate on the main loop and got very weird results when higher than 0.01. Really low values didn't make any noticeable difference...

On the other hand I also tried looking for the actors sub-step with no luck. :oops:

I'll have to change my modeling unit...

betajaen

01-06-2008 09:37:08

Stupid "protected" functions, If you remove that, you have access to the setTiming functions.

If I remember correctly, this is default (when using the accumulator)

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

Try increasing 4 to 5 or 6.

Otherwise;

mActor->setSolverIterationCount(x)

For every actor you need; try 5 or 8 to start with.

toglia

06-06-2008 07:38:28

I made the setTiming procedure of SceneController public, did the same test of small bodies inside a big compound shape, apply some force, but as always these bodies get out if they reach a certain amount of velocity. I tried increasing the numSubSteps and iterCount from 6 to 128 :twisted: but didnt fix it :cry:.

betajaen

06-06-2008 11:27:12

Did you try messing around with the sleep linear/angular velocity?

toglia

07-06-2008 05:08:28

The problem about the small bouncing can be partially fixed with the bounceThreshold (mentioned) or with the sleep enery threshold (also mentioned), at least. But I went off topic after you told me it was a bad idea to change the Scene timing to get better physics accuracy.

I have found that sometimes even with the default values its difficult to prevent actors passing through walls or getting out of closed compound shapes (my case). So I would really like to know if there´s a true workaround for this besides ccd or making everything slower (I´m thinking maybe there isn´t).

It´s weird that PhysX didn´t make ccd for spheres.

betajaen

07-06-2008 11:03:51

It´s weird that PhysX didn´t make ccd for spheres.

How I understand it is; The mesh is stretched in the direction of travel; calculating a sphere in a physics library is pretty easy; you just need the radius and pi. Stretching the sphere makes it no longer a sphere and you need more than radius and pi then.