summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2014-01-03 18:19:25 -0500
committerOz Linden <oz@lindenlab.com>2014-01-03 18:19:25 -0500
commit05a313f546c4f943a74ec2214cabf4df747eda5a (patch)
treecc2381b4bd55690ed39fd7cdddbc93d0da08d7fb
parent6051a865578f08e65e058478a6cc7fedb5aefb7b (diff)
change shaking to decay exponentially
-rw-r--r--indra/newview/llfloaterregionrestarting.cpp28
-rw-r--r--indra/newview/llfloaterregionrestarting.h3
2 files changed, 19 insertions, 12 deletions
diff --git a/indra/newview/llfloaterregionrestarting.cpp b/indra/newview/llfloaterregionrestarting.cpp
index b793d259cd..94c805205a 100644
--- a/indra/newview/llfloaterregionrestarting.cpp
+++ b/indra/newview/llfloaterregionrestarting.cpp
@@ -100,15 +100,17 @@ void LLFloaterRegionRestarting::draw()
{
LLFloater::draw();
- const F32 SHAKE_INTERVAL = 0.03;
- const U32 SHAKE_ITERATIONS = 4;
- const F32 SHAKE_AMOUNT = 1.5;
-
+ const F32 SHAKE_INTERVAL = 0.04;
+ const F32 SHAKE_TOTAL_DURATION = 1.8; // the length of the default alert tone for this
+ const F32 SHAKE_INITIAL_MAGNITUDE = 1.5;
+ F32 time_shaking;
+
if(SHAKE_START == sShakeState)
{
mShakeTimer.setTimerExpirySec(SHAKE_INTERVAL);
sShakeState = SHAKE_LEFT;
- mIterations = 0;
+ mShakeIterations = 0;
+ mShakeMagnitude = SHAKE_INITIAL_MAGNITUDE;
}
if(SHAKE_DONE != sShakeState && mShakeTimer.hasExpired())
@@ -118,30 +120,34 @@ void LLFloaterRegionRestarting::draw()
switch(sShakeState)
{
case SHAKE_LEFT:
- gAgentCamera.setPanLeftKey(SHAKE_AMOUNT);
+ gAgentCamera.setPanLeftKey(mShakeMagnitude);
sShakeState = SHAKE_UP;
break;
case SHAKE_UP:
- gAgentCamera.setPanUpKey(SHAKE_AMOUNT);
+ gAgentCamera.setPanUpKey(mShakeMagnitude);
sShakeState = SHAKE_RIGHT;
break;
case SHAKE_RIGHT:
- gAgentCamera.setPanRightKey(SHAKE_AMOUNT);
+ gAgentCamera.setPanRightKey(mShakeMagnitude);
sShakeState = SHAKE_DOWN;
break;
case SHAKE_DOWN:
- gAgentCamera.setPanDownKey(SHAKE_AMOUNT);
- mIterations = mIterations + 1;
- if(SHAKE_ITERATIONS == mIterations)
+ gAgentCamera.setPanDownKey(mShakeMagnitude);
+ mShakeIterations++;
+ time_shaking = SHAKE_INTERVAL * (mShakeIterations * 4 /* left, up, right, down */);
+ if(SHAKE_TOTAL_DURATION <= time_shaking)
{
sShakeState = SHAKE_DONE;
+ mShakeMagnitude = 0.0;
}
else
{
sShakeState = SHAKE_LEFT;
+ F32 percent_done_shaking = (SHAKE_TOTAL_DURATION - time_shaking) / SHAKE_TOTAL_DURATION;
+ mShakeMagnitude = SHAKE_INITIAL_MAGNITUDE * (percent_done_shaking * percent_done_shaking); // exponential decay
}
break;
diff --git a/indra/newview/llfloaterregionrestarting.h b/indra/newview/llfloaterregionrestarting.h
index 95fe772a28..46416db2c8 100644
--- a/indra/newview/llfloaterregionrestarting.h
+++ b/indra/newview/llfloaterregionrestarting.h
@@ -49,7 +49,8 @@ private:
virtual void regionChange();
std::string mName;
- U32 mIterations;
+ U32 mShakeIterations;
+ F32 mShakeMagnitude;
LLTimer mShakeTimer;
boost::signals2::connection mRegionChangedConnection;