This project is read-only.

TimeStep per body and negative TimeSteps

Dec 12, 2012 at 4:23 PM

I'm trying to change the engine so that each object can process time at a different speed. So far I've created a TimeBody that inherits body, and has an extra parameter called dilation, initially set to 1.0.

Within the PhysicsSystem I am going through Integrate and going to all the functions which pass dt (difference in time) and altering them so they call the functions, for each body, using dt multiplied by the new dilation variable.

The goal is to be able to change the dilation value dynamically, and have the objects work at different speeds relative to each other.

Do you think this could work, or would it take too much tweaking to do in this engine?

Issues I know that might come up are:

What happens when two objects with the same velocity collide as a result of different dilation? (this might work fine)

What happens when a negative dt is passed (I tried passing a negative in before modifications, it seems funky, I'll have to consider using an absolute value and flipping the velocities in these special cases)

Any advice would be great!

My background:

I've got a fair bit of algebra and calculus know-how, built simple 2D engines, this is the first time with a 3D engine, but I have 3D experience so it all makes pretty good sense to me.

Dec 13, 2012 at 4:47 PM

Well I realized that when TimeSpan is negative, objects maintain the same velocities, I will have to look into "fixing" this. Also the collisions seem to only happen on the inside of objects (as if they were inside out) so this might take some work.

Other then that, it's working pretty well. Simply passing a different change in time to each object worked as intended. There was one special case where two objects collided that had the same velocity (Dot product was zero, therefore collision wasn't handled properly). To solve it, I simply scaled the velocity for the dot product calculation by the dilation, which should resolve all collision issues.

I rained some cubes on a 'slow spot' that dilates time around it with falloff. It can be seen here:

http://www.youtube.com/watch?v=JFd1JTdb1gs