From a969a8f99cc952e4647ee6e0a5ab1b95e8cd6ab5 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Fri, 28 Dec 2012 16:46:06 +0100 Subject: [PATCH] UseNewTargetOmegaCode loosely ported from Henri --- indra/newview/app_settings/settings.xml | 11 +++ indra/newview/llviewerobject.cpp | 92 +++++++++++++++++++++---- indra/newview/llviewerobject.h | 3 +- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 988a2b196..27b60f227 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9,6 +9,17 @@ settings_rlv.xml + UseNewTargetOmegaCode + + Comment + Enable target omega code from Viewer 3.4 + Persist + 1 + Type + Boolean + Value + 0 + SGIgnoreSimulatorCameraConstraints Comment diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f22a1a1af..3751b6e3a 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -243,6 +243,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mTimeDilation(1.f), mRotTime(0.f), mAngularVelocityRot(), + mPreviousRotation(), mState(0), mMedia(NULL), mClickAction(0), @@ -272,7 +273,12 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe { mPositionAgent = mRegionp->getOriginAgent(); } - resetRot(); + + static const LLCachedControl use_new_target_omega ("UseNewTargetOmegaCode", true); + if (use_new_target_omega) + { + resetRot(); + } LLViewerObject::sNumObjects++; } @@ -2107,17 +2113,53 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, } } - if (new_rot != getRotation() - || new_angv != old_angv) - { - if (new_angv != old_angv) + static const LLCachedControl use_new_target_omega ("UseNewTargetOmegaCode", true); + if (use_new_target_omega) + { // New, experimental code + if (new_rot != getRotation() || new_angv != old_angv) { + if (new_angv != old_angv) + { + if (new_rot != mPreviousRotation) + { + resetRot(); + } + else if (new_angv != old_angv) + { + if (flagUsePhysics()) + { + resetRot(); + } + else + { + mRotTime = 0.0f; + } + } + } + + // Remember the last rotation value + mPreviousRotation = new_rot; + + // Set the rotation of the object followed by adjusting for the + // accumulated angular velocity (llSetTargetOmega) + setRotation(new_rot * mAngularVelocityRot); + setChanged(ROTATED | SILHOUETTE); + } + } + else + { // Old code + if (new_rot != mPreviousRotation || new_angv != old_angv) + { + if (new_rot != mPreviousRotation) + { + mPreviousRotation = new_rot; + setRotation(new_rot); + } + + setChanged(ROTATED | SILHOUETTE); + resetRot(); } - - // Set the rotation of the object followed by adjusting for the accumulated angular velocity (llSetTargetOmega) - setRotation(new_rot * mAngularVelocityRot); - setChanged(ROTATED | SILHOUETTE); } @@ -5511,8 +5553,12 @@ void LLViewerObject::applyAngularVelocity(F32 dt) // 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; + static const LLCachedControl use_new_target_omega ("UseNewTargetOmegaCode", true); + if (use_new_target_omega) + { + // 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); @@ -5524,8 +5570,28 @@ void LLViewerObject::resetRot() { mRotTime = 0.0f; - // Reset the accumulated angular velocity rotation - mAngularVelocityRot.loadIdentity(); + static const LLCachedControl use_new_target_omega ("UseNewTargetOmegaCode", true); + if(use_new_target_omega) + { + // Reset the accumulated angular velocity rotation + mAngularVelocityRot.loadIdentity(); + } +} + +//virtual +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + + static const LLCachedControl use_new_target_omega ("UseNewTargetOmegaCode", true); + if(use_new_target_omega) + { + resetRot(); + } + else + { + mRotTime = 0.f; + } } U32 LLViewerObject::getPartitionType() const diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index c83b1695a..700370f01 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -214,7 +214,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; mRotTime = 0.f;} + void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } @@ -742,6 +742,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 + LLQuaternion mPreviousRotation; U8 mState; // legacy LLViewerObjectMedia* mMedia; // NULL if no media associated