Hey all,
This thread was from awhile back, but I thought I’d update it to say I have solved this and wanted to share my solution, since I think this is extremely useful.
I mentioned in my last post that working out the physics would be too messy (read: I was intimidated by giving it a try). Well today I decided to give it a try anyway to see what I might be able to figure out. Good news: it turns out it’s pretty easy to make simulations run at arbitrary speeds.
For my test, I set up two rectangle bodies and applied strong force and torque values to let them fly, then bounce off of walls. I tracked one corner of each rectangle by plotting its position on screen for each drawing frame, leaving a colored trace in place. Then I changed the gravity on the second box to see what I could get going – the idea being that if I could get each box to plot the same complicated path at different speeds, then the problem had been solved.
I’ve gotten a fairly close match with up to about 5x speed. At 6x and greater, the disparity starts to become more noticeable, but if you don’t need a great deal of accuracy, you may be fine going higher.
The math:
(“rate” is how fast you want the simulation to run; 1=normal speed)
Gravity: multiply by rate^2
Applied forces and torques: multiply by rate
All bodies: multiply linearDamping and angularDamping by rate
That’s all there is to it! Note that friction, density, and restitution should not be changed.
Note:
If you use very strong forces or very high damping rates, the simulation becomes less accurate.
I haven’t tested joints yet, but I’ll let you know how it goes. I’ll be looking at reactionForce, reactionTorque, maxMotorForce, maxMotorTorque, motorSpeed, and dampingRatio. I expect they all need to be multiplied by rate. Not sure what to expect yet with the frequency field of DISTANCE and WELD joints.
I’ll also look to see if calculated impact forces might have to be accounted for.