If the sum of all times is identical, so is the result. This is not true for Armagetron.Lucifer wrote:Hmm, not sure. The m/s^2 function is based on time since the beginning of acceleration, and if you're calculating it with just the interval between frames, the function is different.Jonathan wrote: I just edited the post you're quoting and added some stuff because probably not many people know what I meant and what Armagetron does.
Back to your reply, I don't see a problem with the following.Code: Select all
position += t*velocity + .5*t*t*acceleration; // possibility 1 position += t*(velocity + .5*t*acceleration); // possibility 2 velocity += acceleration;
That's horrible. Try it and watch it fail.I sincerely think (and I could well be wrong), that the function is just velocity + acceleration in this case, and if I'm right, armagetron is doing it right. Which also means:
looks right to me.Code: Select all
velocity += acceleration; position += t*velocity;
Doing everything right is at least difficult and impractical, depending on what you're doing. But if something is easy to do right, do it right.I admit I'm only about to take my trig class and I'm skipping college-level algebra to do it, but we did cover acceleration in exercises anyway, last semester.
There are two things to keep in mind here.
1. Like a movie, we use frames to approximate motion because we can't simulate it in realtime. We can only show where everything is at certain intervals, and we can only do collision-testing and movement at those intervals. So some inaccuracy has to be allowed to accomodate it.
Armagetron is .5*t*t*acceleration too far ahead. When I tried an internet game with a fixed client, it became unplayable.2. We don't have to be perfectly exact anyway. The player isn't going to notice a difference of +-0.02 m/s. How high is our margin of error really?
Do you have any idea how fast programs actually run?3. (I said I'm only about to take trig) We need these calculations optimized for performance as much as possible, so it's preferable to accept a certain minimum margin of error if that gives us extra cycles to render with. Unless our rendering is spot-on accurate, it's going to hide deficiencies in the physics model anyway.
In case you were wondering, correct one-dimensional acceleration (without changing speed) takes 15 cycles on my CPU, and after 11 everything has entered the FPU pipeline or is already finished. With 3 dimensions it needs 17 cycles, and everything has entered the FPU pipeline or is finished in 13. Adding speed+=t*acceleration gets us at 20 and 16, using 64-bit floating point. Now we have a speed problem for sure!
It should.Anyway, I'll reread this after I've slept, when the math will make more sense to me.