## Scaling the world including forces?

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

### Scaling the world including forces?

Based on http://www.bulletphysics.org/mediawiki- ... _The_World I scaled the world in my simulator. Mainly I had to scale it so that it never produces btRigidBody elements smaller than indicated as I experienced heavy jittering. I also understand when gravity is applied that for larger objects the falling might look like slow-motion, that is why I also have to scale things down to make it look more realistic. But I see that the wiki assumes that the integration step is 1/60.0f. This is not true in my case. My integration step is 1/240.0f and I am always taking full integration step, no substeps to avoid interpolation (I had stability issues in the past). Based on the different integration step, I feel that a rigidbody falls slower as well. Is that true? I can only make my simulator to run properly by introducing a gravity scaling constant of about 20.0f to get a feeling of reasonable gravity (I might have to measure what it actually is).

Can anybody tell me how I have to scale gravity? Do I also have to scale all other forces that I apply in my simulator using applyForce() etc. to make the simulation run independently of the integration step?

drleviathan
Posts: 567
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

### Re: Scaling the world including forces?

When you scale the world up you are effectively changing the units of measure from meters to some smaller unit. For example, if you were to scale all dimensions by 100 you are simply switching to centimeters and your velocities use cm/sec by definition. Similarly acceleration uses cm/sec^2.

In short, when you scale distance by some factor (f) (and you are not changing your unit of time) then you simply scale velocity and acceleration by the same factor (f).

velocity = m/sec --> f*m/sec

acceleration = m/sec^2 --> f*m/sec^2

drleviathan
Posts: 567
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

### Re: Scaling the world including forces?

Oh yeah, you were wondering about how to scale the forces.

Force = mass * acceleration = kg * m / sec^2

There is only one measure of distance in those units, and it is on the top, so you would similarly scale it by the factor (f).

newForce --> f * oldForce

Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

### Re: Scaling the world including forces?

Gravity should not be affected by time-step size, but motor constraints (and likely any constraint/impulse) are affected by it. Most likely what you are experiencing is just "time dilation" caused by stepping just 1/240 when real world time increases by 1/60. Just use the built in function to automatically step the world by your real-world increase at 1/240 intervals, or do it yourself (more or less the same result). If you are more adventurous, you can change OGL so that it steps at 240fps rather than 60fps, and that should work too.

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

### Re: Scaling the world including forces?

Thabks for your answers. True, gravity was not affected by the timestep. It was all matter of proper scaling. The only thing that I had to do as well was to do a weight scaling as well. In my simulation, it was horribly instable to simulate constrained rigidbodies of cubic shape with edge length of 0.05 and density of 1. Instead I had to make a weight normalization by calculating an appropriate density. I did this by assuming the smallest cube to be unit weight (in my case 0.05^3 m^3 is 1 kilogramm). It is a bit heavy since this is the density of iron more or less, but the simulation does not have problems of small weights anymore. Any other solutions?

Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

### Re: Scaling the world including forces?

Higher simulation frequency normally helps the most, after that switching solvers to dantzig or similar and using DP