summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-02-10 15:57:08 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-02-10 15:57:08 -0500
commit49b8f8af026a627db47c9592fc92eccda790401e (patch)
tree181bbe92c8d7522e087a2913ea8fb2919f405de3 /indra/newview
parent54bf80bf450fa6b8b50c573ca5ef902b4462d410 (diff)
SH-915 WIP - LLAgentPilot class cleanup, added interpolation for camera motion
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llagentpilot.cpp81
-rwxr-xr-xindra/newview/llagentpilot.h29
-rwxr-xr-xindra/newview/llappviewer.cpp8
-rwxr-xr-xindra/newview/llstartup.cpp2
-rwxr-xr-x[-rw-r--r--]indra/newview/llviewermenu.cpp13
5 files changed, 75 insertions, 58 deletions
diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp
index 25318c940a..f96db0a5df 100755
--- a/indra/newview/llagentpilot.cpp
+++ b/indra/newview/llagentpilot.cpp
@@ -41,9 +41,6 @@
LLAgentPilot gAgentPilot;
-BOOL LLAgentPilot::sLoop = TRUE;
-BOOL LLAgentPilot::sReplaySession = FALSE;
-
LLAgentPilot::LLAgentPilot() :
mNumRuns(-1),
mQuitAfterRuns(FALSE),
@@ -52,7 +49,9 @@ LLAgentPilot::LLAgentPilot() :
mStarted(FALSE),
mPlaying(FALSE),
mCurrentAction(0),
- mOverrideCamera(FALSE)
+ mOverrideCamera(FALSE),
+ mLoop(TRUE),
+ mReplaySession(FALSE)
{
}
@@ -266,7 +265,7 @@ void LLAgentPilot::startPlayback()
LLViewerJoystick::getInstance()->toggleFlycam();
}
gAgent.startAutoPilotGlobal(mActions[0].mTarget);
- moveCamera(mActions[0]);
+ moveCamera();
mStarted = FALSE;
}
else
@@ -287,22 +286,51 @@ void LLAgentPilot::stopPlayback()
gAgent.stopAutoPilot();
}
- if (sReplaySession)
+ if (mReplaySession)
{
LLAppViewer::instance()->forceQuit();
}
}
-void LLAgentPilot::moveCamera(Action& action)
+void LLAgentPilot::moveCamera()
{
if (!getOverrideCamera())
return;
+
+ if (mCurrentAction<mActions.count())
+ {
+ S32 start_index = llmax(mCurrentAction-1,0);
+ S32 end_index = mCurrentAction;
+ F32 t = 0.0;
+ F32 timedelta = mActions[end_index].mTime - mActions[start_index].mTime;
+ F32 tickelapsed = mTimer.getElapsedTimeF32()-mActions[start_index].mTime;
+ if (timedelta > 0.0)
+ {
+ t = tickelapsed/timedelta;
+ }
+
+ if ((t<0.0)||(t>1.0))
+ {
+ llwarns << "mCurrentAction is invalid, t = " << t << llendl;
+ return;
+ }
+
+ Action& start = mActions[start_index];
+ Action& end = mActions[end_index];
+
+ F32 view = lerp(start.mCameraView, end.mCameraView, t);
+ LLVector3 origin = lerp(start.mCameraOrigin, end.mCameraOrigin, t);
+ LLQuaternion start_quat(start.mCameraXAxis, start.mCameraYAxis, start.mCameraZAxis);
+ LLQuaternion end_quat(end.mCameraXAxis, end.mCameraYAxis, end.mCameraZAxis);
+ LLQuaternion quat = nlerp(t, start_quat, end_quat);
+ LLMatrix3 mat(quat);
- LLViewerCamera::getInstance()->setView(action.mCameraView);
- LLViewerCamera::getInstance()->setOrigin(action.mCameraOrigin);
- LLViewerCamera::getInstance()->mXAxis = LLVector3(action.mCameraXAxis);
- LLViewerCamera::getInstance()->mYAxis = LLVector3(action.mCameraYAxis);
- LLViewerCamera::getInstance()->mZAxis = LLVector3(action.mCameraZAxis);
+ LLViewerCamera::getInstance()->setView(view);
+ LLViewerCamera::getInstance()->setOrigin(origin);
+ LLViewerCamera::getInstance()->mXAxis = LLVector3(mat.mMatrix[0]);
+ LLViewerCamera::getInstance()->mYAxis = LLVector3(mat.mMatrix[1]);
+ LLViewerCamera::getInstance()->mZAxis = LLVector3(mat.mMatrix[2]);
+ }
}
void LLAgentPilot::updateTarget()
@@ -336,13 +364,13 @@ void LLAgentPilot::updateTarget()
if (mCurrentAction < mActions.count())
{
gAgent.startAutoPilotGlobal(mActions[mCurrentAction].mTarget);
- moveCamera(mActions[mCurrentAction]);
+ moveCamera();
}
else
{
stopPlayback();
mNumRuns--;
- if (sLoop)
+ if (mLoop)
{
if ((mNumRuns < 0) || (mNumRuns > 0))
{
@@ -377,29 +405,8 @@ void LLAgentPilot::updateTarget()
}
}
-// static
-void LLAgentPilot::startRecord(void *)
-{
- gAgentPilot.startRecord();
-}
-
-void LLAgentPilot::saveRecord(void *)
-{
- gAgentPilot.stopRecord();
-}
-
-void LLAgentPilot::addWaypoint(void *)
+void LLAgentPilot::addWaypoint()
{
- gAgentPilot.addAction(STRAIGHT);
-}
-
-void LLAgentPilot::startPlayback(void *)
-{
- gAgentPilot.mNumRuns = -1;
- gAgentPilot.startPlayback();
+ addAction(STRAIGHT);
}
-void LLAgentPilot::stopPlayback(void *)
-{
- gAgentPilot.stopPlayback();
-}
diff --git a/indra/newview/llagentpilot.h b/indra/newview/llagentpilot.h
index 5e045fa695..dd1709ec0c 100755
--- a/indra/newview/llagentpilot.h
+++ b/indra/newview/llagentpilot.h
@@ -60,24 +60,34 @@ public:
void startPlayback();
void stopPlayback();
-
bool isRecording() { return mRecording; }
bool isPlaying() { return mPlaying; }
bool getOverrideCamera() { return mOverrideCamera; }
void updateTarget();
- static void startRecord(void *);
- static void addWaypoint(void *);
- static void saveRecord(void *);
- static void startPlayback(void *);
- static void stopPlayback(void *);
- static BOOL sLoop;
- static BOOL sReplaySession;
+ void addWaypoint();
+ void moveCamera();
+
+ void setReplaySession(BOOL new_val) { mReplaySession = new_val; }
+ BOOL getReplaySession() { return mReplaySession; }
+
+ void setLoop(BOOL new_val) { mLoop = new_val; }
+ BOOL getLoop() { return mLoop; }
+
+ void setQuitAfterRuns(BOOL quit_val) { mQuitAfterRuns = quit_val; }
+ void setNumRuns(S32 num_runs) { mNumRuns = num_runs; }
+
+private:
+
+
+
+ BOOL mLoop;
+ BOOL mReplaySession;
S32 mNumRuns;
BOOL mQuitAfterRuns;
-private:
+
void setAutopilotTarget(const S32 id);
BOOL mRecording;
@@ -106,7 +116,6 @@ private:
LLDynamicArray<Action> mActions;
LLTimer mTimer;
- void moveCamera(Action& action);
};
extern LLAgentPilot gAgentPilot;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ec3d775dc7..0118d2dfc1 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -468,8 +468,8 @@ static void settings_to_globals()
LLSelectMgr::sRenderHiddenSelections = gSavedSettings.getBOOL("RenderHiddenSelections");
LLSelectMgr::sRenderLightRadius = gSavedSettings.getBOOL("RenderLightRadius");
- gAgentPilot.mNumRuns = gSavedSettings.getS32("StatsNumRuns");
- gAgentPilot.mQuitAfterRuns = gSavedSettings.getBOOL("StatsQuitAfterRuns");
+ gAgentPilot.setNumRuns(gSavedSettings.getS32("StatsNumRuns"));
+ gAgentPilot.setQuitAfterRuns(gSavedSettings.getBOOL("StatsQuitAfterRuns"));
gAgent.setHideGroupTitle(gSavedSettings.getBOOL("RenderHideGroupTitle"));
gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
@@ -2289,7 +2289,7 @@ bool LLAppViewer::initConfiguration()
if (clp.hasOption("replaysession"))
{
- LLAgentPilot::sReplaySession = TRUE;
+ gAgentPilot.setReplaySession(TRUE);
}
if (clp.hasOption("nonotifications"))
@@ -4224,7 +4224,7 @@ void LLAppViewer::idle()
{
if (gAgentPilot.isPlaying() && gAgentPilot.getOverrideCamera())
{
- // camera positioning handled inside gAgentPilot.
+ gAgentPilot.moveCamera();
}
else
{
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index db7e0149cc..b98cbd5b78 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1989,7 +1989,7 @@ bool idle_startup()
}
// Start automatic replay if the flag is set.
- if (gSavedSettings.getBOOL("StatsAutoRun") || LLAgentPilot::sReplaySession)
+ if (gSavedSettings.getBOOL("StatsAutoRun") || gAgentPilot.getReplaySession())
{
LLUUID id;
LL_DEBUGS("AppInit") << "Starting automatic playback" << LL_ENDL;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index e9e0268587..eb022851e7 100644..100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1901,19 +1901,20 @@ class LLAdvancedAgentPilot : public view_listener_t
std::string command = userdata.asString();
if ("start playback" == command)
{
- LLAgentPilot::startPlayback(NULL);
+ gAgentPilot.setNumRuns(-1);
+ gAgentPilot.startPlayback();
}
else if ("stop playback" == command)
{
- LLAgentPilot::stopPlayback(NULL);
+ gAgentPilot.stopPlayback();
}
else if ("start record" == command)
{
- LLAgentPilot::startRecord(NULL);
+ gAgentPilot.startRecord();
}
else if ("stop record" == command)
{
- LLAgentPilot::saveRecord(NULL);
+ gAgentPilot.stopRecord();
}
return true;
@@ -1931,7 +1932,7 @@ class LLAdvancedToggleAgentPilotLoop : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- LLAgentPilot::sLoop = !(LLAgentPilot::sLoop);
+ gAgentPilot.setLoop(!gAgentPilot.getLoop());
return true;
}
};
@@ -1940,7 +1941,7 @@ class LLAdvancedCheckAgentPilotLoop : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- bool new_value = LLAgentPilot::sLoop;
+ bool new_value = gAgentPilot.getLoop();
return new_value;
}
};