[sldev] Linear motion interpolation weirdness?

John Hurliman jhurliman at wsu.edu
Mon Apr 9 00:02:47 PDT 2007


In llviewerobject.cpp starting around line 1997, the basic linear motion 
interpolation for objects is done to calculate their position in between 
the object update packets. The algorithm used is:

LLVector3 <http://gza.props.org:8180/source/s?defs=LLVector3> pos <http://gza.props.org:8180/source/s?defs=pos> 	= (vel <http://gza.props.org:8180/source/s?defs=vel> + (0.5f * (dt <http://gza.props.org:8180/source/s?defs=dt>-HAVOK_TIMESTEP <http://gza.props.org:8180/source/s?defs=HAVOK_TIMESTEP>)) * accel <http://gza.props.org:8180/source/s?defs=accel>) * dt <http://gza.props.org:8180/source/s?defs=dt>;

But it it wrapped inside this check:


*if* (!(accel <http://gza.props.org:8180/source/s?defs=accel>.isExactlyZero <http://gza.props.org:8180/source/s?defs=isExactlyZero>() && vel <http://gza.props.org:8180/source/s?defs=vel>.isExactlyZero <http://gza.props.org:8180/source/s?defs=isExactlyZero>()))

So even though velocity is figured in to the equation, the calculation will never be reached unless it is zero. Why is interpolation only being done when (vel.isExactlyZero()), and if this is the correct behavior why is velocity used in the algorithm?

John Hurliman



More information about the SLDev mailing list