diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp
index 25318c940ab28569024c2a6c1a66241bd57b16fb..f96db0a5df4fb15c3b0e852880552d112c7e448f 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 5e045fa6956abad0de9065fb4cd6dffa220a8e0c..dd1709ec0c21cb1af0d562a96d865c21c0a8c1d3 100755
--- a/indra/newview/llagentpilot.h
+++ b/indra/newview/llagentpilot.h
@@ -60,24 +60,34 @@ class LLAgentPilot
 	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 @@ class LLAgentPilot
 	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 ec3d775dc7678f9019e83eda4055a3b35a463fb3..0118d2dfc1b36cca4b6bcd29bb10f026bb1747be 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 db7e0149cc5bded53449aedad45cfe91c5151f44..b98cbd5b78fd836fc41119ad01b62419a619adbc 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
old mode 100644
new mode 100755
index e9e0268587955c0b1b26e1ad6912187ca6c0bf2a..eb022851e7218e5f6982ad9c4ee38d9e002f9a12
--- 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;
 	}
 };