diff options
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rw-r--r-- | indra/newview/llviewerobject.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 17091a91d6..aba1d131e1 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -236,6 +236,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), @@ -265,6 +266,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe { mPositionAgent = mRegionp->getOriginAgent(); } + resetRot(); LLViewerObject::sNumObjects++; } @@ -2038,14 +2040,21 @@ 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); + if (flagUsePhysics()) + { + resetRot(); + } + else + { + resetRotTime(); + } } + // Set the rotation of the object followed by adjusting for the accumulated angular velocity (llSetTargetOmega) + setRotation(new_rot * mAngularVelocityRot); setChanged(ROTATED | SILHOUETTE); - - resetRot(); } @@ -4052,7 +4061,7 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos return retval; } - +//virtual void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) { if(index < 0 || index >= getNumTEs()) @@ -5406,18 +5415,31 @@ 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); } } -void LLViewerObject::resetRot() +void LLViewerObject::resetRotTime() { mRotTime = 0.0f; } +void LLViewerObject::resetRot() +{ + resetRotTime(); + + // Reset the accumulated angular velocity rotation + mAngularVelocityRot.loadIdentity(); +} + U32 LLViewerObject::getPartitionType() const { return LLViewerRegion::PARTITION_NONE; |