UseNewTargetOmegaCode loosely ported from Henri

This commit is contained in:
Siana Gearz
2012-12-28 16:46:06 +01:00
parent 71eb0fedd9
commit a969a8f99c
3 changed files with 92 additions and 14 deletions

View File

@@ -9,6 +9,17 @@
<string>settings_rlv.xml</string>
</array>
<key>UseNewTargetOmegaCode</key>
<map>
<key>Comment</key>
<string>Enable target omega code from Viewer 3.4</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SGIgnoreSimulatorCameraConstraints</key>
<map>
<key>Comment</key>

View File

@@ -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<bool> 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<bool> 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<bool> 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<bool> 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<bool> use_new_target_omega ("UseNewTargetOmegaCode", true);
if(use_new_target_omega)
{
resetRot();
}
else
{
mRotTime = 0.f;
}
}
U32 LLViewerObject::getPartitionType() const

View File

@@ -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