From 4ade726a07e11997e6bfc216186d11334790eb6a Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Mon, 10 Sep 2012 16:31:27 +0200 Subject: [PATCH] Fix PATH-842 rotation reset on object update --- indra/newview/llviewerobject.cpp | 20 +++++++++++++++----- indra/newview/llviewerobject.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 186e7d57b..b8833d302 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -241,6 +241,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mNumFaces(0), mTimeDilation(1.f), mRotTime(0.f), + mAngularVelocityRot(), mState(0), mMedia(NULL), mClickAction(0), @@ -270,6 +271,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe { mPositionAgent = mRegionp->getOriginAgent(); } + resetRot(); LLViewerObject::sNumObjects++; } @@ -2105,14 +2107,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, if (new_rot != getRotation() || 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); - - resetRot(); } @@ -5498,8 +5500,13 @@ void LLViewerObject::applyAngularVelocity(F32 dt) ang_vel *= 1.f/omega; + // calculate the delta increment based on the object's angular velocity 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); setChanged(MOVED | SILHOUETTE); } @@ -5508,6 +5515,9 @@ void LLViewerObject::applyAngularVelocity(F32 dt) void LLViewerObject::resetRot() { mRotTime = 0.0f; + + // Reset the accumulated angular velocity rotation + mAngularVelocityRot.loadIdentity(); } U32 LLViewerObject::getPartitionType() const diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 2b9597510..791393533 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -736,6 +736,7 @@ protected: F32 mTimeDilation; // Time dilation sent with the object. F32 mRotTime; // Amount (in seconds) that object has rotated according to angular velocity (llSetTargetOmega) + LLQuaternion mAngularVelocityRot; // accumulated rotation from the angular velocity computations U8 mState; // legacy LLViewerObjectMedia* mMedia; // NULL if no media associated