Fix regression introduced in pathfinding (avelocity bugs)

This commit is contained in:
Shyotl
2012-08-13 02:55:47 -05:00
parent 7335ae548c
commit aa54a386f3
2 changed files with 15 additions and 4 deletions

View File

@@ -242,6 +242,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
mNumFaces(0), mNumFaces(0),
mTimeDilation(1.f), mTimeDilation(1.f),
mRotTime(0.f), mRotTime(0.f),
mAngularVelocityRot(),
mJointInfo(NULL), mJointInfo(NULL),
mState(0), mState(0),
mMedia(NULL), mMedia(NULL),
@@ -272,6 +273,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
{ {
mPositionAgent = mRegionp->getOriginAgent(); mPositionAgent = mRegionp->getOriginAgent();
} }
resetRot();
LLViewerObject::sNumObjects++; LLViewerObject::sNumObjects++;
} }
@@ -2131,14 +2133,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
if (new_rot != getRotation() if (new_rot != getRotation()
|| new_angv != old_angv) || new_angv != old_angv)
{ {
if (new_rot != getRotation()) if (new_angv != old_angv)
{ {
setRotation(new_rot); resetRot();
} }
// Set the rotation of the object followed by adjusting for the accumulated angular velocity (llSetTargetOmega)
setRotation(new_rot * mAngularVelocityRot);
setChanged(ROTATED | SILHOUETTE); setChanged(ROTATED | SILHOUETTE);
resetRot();
} }
@@ -5599,8 +5601,13 @@ void LLViewerObject::applyAngularVelocity(F32 dt)
ang_vel *= 1.f/omega; ang_vel *= 1.f/omega;
// calculate the delta increment based on the object's angular velocity
dQ.setQuat(angle, ang_vel); dQ.setQuat(angle, ang_vel);
// accumulate the angular velocity rotations to re-apply in the case of an object update
mAngularVelocityRot *= dQ;
// Just apply the delta increment to the current rotation
setRotation(getRotation()*dQ); setRotation(getRotation()*dQ);
setChanged(MOVED | SILHOUETTE); setChanged(MOVED | SILHOUETTE);
} }
@@ -5609,6 +5616,9 @@ void LLViewerObject::applyAngularVelocity(F32 dt)
void LLViewerObject::resetRot() void LLViewerObject::resetRot()
{ {
mRotTime = 0.0f; mRotTime = 0.0f;
// Reset the accumulated angular velocity rotation
mAngularVelocityRot.loadIdentity();
} }
U32 LLViewerObject::getPartitionType() const U32 LLViewerObject::getPartitionType() const

View File

@@ -751,6 +751,7 @@ protected:
F32 mTimeDilation; // Time dilation sent with the object. F32 mTimeDilation; // Time dilation sent with the object.
F32 mRotTime; // Amount (in seconds) that object has rotated according to angular velocity (llSetTargetOmega) F32 mRotTime; // Amount (in seconds) that object has rotated according to angular velocity (llSetTargetOmega)
LLQuaternion mAngularVelocityRot; // accumulated rotation from the angular velocity computations
LLVOJointInfo* mJointInfo; LLVOJointInfo* mJointInfo;
U8 mState; // legacy U8 mState; // legacy