From a21927e510376edf14af34b01d4fffad9eabd8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Wed, 8 Jan 2020 13:15:37 -0500 Subject: [PATCH] [Follow] If target av isn't rendered, still try to get their position Mainly moves code around, rather small change. --- indra/newview/llagent.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 20bfac5d9..bfb6e98d7 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1757,16 +1757,25 @@ void LLAgent::autoPilot(F32 *delta_yaw) bool follow = !mLeaderID.isNull(); //mAutoPilotBehaviorName == "Follow"; if (follow) { - LLViewerObject* object = gObjectList.findObject(mLeaderID); - if (!object) + if (auto object = gObjectList.findObject(mLeaderID)) { - mAutoPilotBehaviorName.clear(); // Nothing left to follow pilot - stopAutoPilot(); - return; + mAutoPilotTargetGlobal = object->getPositionGlobal(); + if (const auto& av = object->asAvatar()) // Fly if avatar target is flying + setFlying(av->mInAir); + } + else // We might still have a valid avatar pos + { + const LLVector3d& get_av_pos(const LLUUID & id); + auto pos = get_av_pos(mLeaderID); + if (pos.isExactlyZero()) // Default constructed or invalid from server + { + mAutoPilotBehaviorName.clear(); // Nothing left to follow pilot + stopAutoPilot(); + return; + } + mAutoPilotTargetGlobal = pos; + // Should we fly if the height difference is great enough here? Altitude is often invalid... } - mAutoPilotTargetGlobal = object->getPositionGlobal(); - if (const auto& av = object->asAvatar()) // Fly if avatar target is flying - setFlying(av->mInAir); } if (!isAgentAvatarValid()) return;