Aloush154 / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

applyGravity outside stepSimulation's 'for' causes determinism loss when forces are applied midTick #689

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make a pretick callback that applies a force opposing gravity.
2. Test it in a high FPS environment (so that around 0-2 substeps done at each 
stepSimulation)
3. Test in a low FPS environment so that each stepSimulation runs 6-9 substeps.

What is the expected output? What do you see instead?
Expected: Same results in both scenearios. Instead, in Scenario 3, smaller 
forces make a larger change since gravity is not applied as often as they are.

What version of the product are you using? On what operating system?
Windows, 2.81

Please provide any additional information below.
applyGravity is executed outside the step execution loop. This causes the loss 
of determinism if forces are applied mid-step, which is my current case: I'm 
running some game scripts at each preTick, this means that in high FPS 
environments, gravity quickly cancels this forces, while in low FPS, the script 
forces are able to stack for several physic ticks.

At the moment, I'm wrapping stepSimulation calls with my own for and 
calculations similar to the ones within it, so that each call to stepSimulation 
runs exactly 1 substep.

Is this the expected behaviour, or is this a bug?

Original issue reported on code.google.com by darthemmanuel2@gmail.com on 17 Jan 2013 at 11:53

GoogleCodeExporter commented 8 years ago
I've experienced this problem as well. You need to call clearForces and 
applyGravity from within your simulation tick before you apply any user forces.

Original comment by tamaynar...@gmail.com on 22 Jan 2013 at 6:40

GoogleCodeExporter commented 8 years ago
See https://github.com/bulletphysics/bullet3/issues/104

Original comment by erwin.coumans on 30 Mar 2014 at 6:23