On Sun, 2005-04-03 at 21:56 -0700, Sean Lynch wrote: > Ok, I put the simulation step back into begin_round and moved all > movement to advance_time. I now store the previous position and > quaternion from the simulation for each body and interpolate to get the > current position and orientation, so motion should appear very smooth > now even with a large physics timestep! One gotcha: I'm using linear > interpolation of the quaternions, which is fast but not perfectly > accurate, so very fast moving objects may appear to "jitter" slightly. > However, the results can never be worse than not interpolating at all, > so I think people should be able to live with that.
Hmmm, actually, timestep and round time *do* need to be separated, not least because the user may have multiple simulations with different step times, and there are other things that may be dependent on round time. What I'm planning to do is to put the step into advance_time, call a method named prestep() on each of the bodies in the simulation just before the step, and calculate time into the current step in advance_time, which is a little more complex but gives much greater flexibility. Another option might be to call a Pyrex _update_matrix method on each body, since I need to maintain a separate list of bodies, and pass the time into that in order to avoid making that calculation several times. Since it'd be a cdef method instead of a Python method, it shouldn't create that much overhead, probably much less than doing an extra multiplication for each body. BTW, while I've been playing with quaternions to do interpolation, I've realized that one could conceivably use a square root approximation to calculate the quaternion magnitude for normalization, since normalization is done a lot and the quaternion being normalized will almost always have a magnitude that is very close to 1. Maybe if Soya starts making heavier use of quaternions I will write a fast normalize function. Of course, being able to inline functions would be a bigger performance boost, as would making more use of quaternions in the first place, so we should probaly focus on that sort of thing first.
signature.asc
Description: This is a digitally signed message part
