summaryrefslogtreecommitdiff
path: root/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorDave SIMmONs <simon@lindenlab.com>2011-03-15 09:10:39 -0700
committerDave SIMmONs <simon@lindenlab.com>2011-03-15 09:10:39 -0700
commit57ac771b154d7722e4774b40a607a11f3286f472 (patch)
tree20a555064cedcbdd6bbea3dbeeb866f95601ba19 /indra/newview/llagent.cpp
parent18ae6c639e58c4c996d4c3b2a4b34ef41deab970 (diff)
parentbc0833d5db9e887f72ea6e7a630781203ad6ad77 (diff)
Merge
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r--indra/newview/llagent.cpp51
1 files changed, 34 insertions, 17 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 7d491a7774..9025982310 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1214,6 +1214,12 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
return;
}
+ // Are there any pending callbacks from previous auto pilot requests?
+ if (mAutoPilotFinishedCallback)
+ {
+ mAutoPilotFinishedCallback(dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < mAutoPilotStopDistance, mAutoPilotCallbackData);
+ }
+
mAutoPilotFinishedCallback = finish_callback;
mAutoPilotCallbackData = callback_data;
mAutoPilotRotationThreshold = rot_threshold;
@@ -1262,22 +1268,8 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
}
mAutoPilot = TRUE;
- mAutoPilotTargetGlobal = target_global;
-
- // trace ray down to find height of destination from ground
- LLVector3d traceEndPt = target_global;
- traceEndPt.mdV[VZ] -= 20.f;
-
- LLVector3d targetOnGround;
- LLVector3 groundNorm;
- LLViewerObject *obj;
+ setAutoPilotTargetGlobal(target_global);
- LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj);
- F64 target_height = llmax((F64)gAgentAvatarp->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]);
-
- // clamp z value of target to minimum height above ground
- mAutoPilotTargetGlobal.mdV[VZ] = targetOnGround.mdV[VZ] + target_height;
- mAutoPilotTargetDist = (F32)dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal);
if (target_rotation)
{
mAutoPilotUseRotation = TRUE;
@@ -1295,12 +1287,36 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
//-----------------------------------------------------------------------------
+// setAutoPilotTargetGlobal
+//-----------------------------------------------------------------------------
+void LLAgent::setAutoPilotTargetGlobal(const LLVector3d &target_global)
+{
+ if (mAutoPilot)
+ {
+ mAutoPilotTargetGlobal = target_global;
+
+ // trace ray down to find height of destination from ground
+ LLVector3d traceEndPt = target_global;
+ traceEndPt.mdV[VZ] -= 20.f;
+
+ LLVector3d targetOnGround;
+ LLVector3 groundNorm;
+ LLViewerObject *obj;
+
+ LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj);
+ F64 target_height = llmax((F64)gAgentAvatarp->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]);
+
+ // clamp z value of target to minimum height above ground
+ mAutoPilotTargetGlobal.mdV[VZ] = targetOnGround.mdV[VZ] + target_height;
+ mAutoPilotTargetDist = (F32)dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal);
+ }
+}
+
+//-----------------------------------------------------------------------------
// startFollowPilot()
//-----------------------------------------------------------------------------
void LLAgent::startFollowPilot(const LLUUID &leader_id)
{
- if (!mAutoPilot) return;
-
mLeaderID = leader_id;
if ( mLeaderID.isNull() ) return;
@@ -1338,6 +1354,7 @@ void LLAgent::stopAutoPilot(BOOL user_cancel)
if (mAutoPilotFinishedCallback)
{
mAutoPilotFinishedCallback(!user_cancel && dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < mAutoPilotStopDistance, mAutoPilotCallbackData);
+ mAutoPilotFinishedCallback = NULL;
}
mLeaderID = LLUUID::null;