From 516ad5b3c234321daf01294d6e03bdc4be019d36 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 17 Feb 2012 19:03:16 -0800 Subject: PATH-292: Implementing the new freeze/unfreeze functionality on the basic panel. --- indra/newview/llpathfindingmanager.cpp | 181 +++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 indra/newview/llpathfindingmanager.cpp (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp new file mode 100644 index 0000000000..e46ec0e171 --- /dev/null +++ b/indra/newview/llpathfindingmanager.cpp @@ -0,0 +1,181 @@ +/** + * @file llpathfindingmanager.cpp + * @author William Todd Stinson + * @brief A state manager for the various pathfinding states. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include + +#include + +#include "llviewerprecompiledheaders.h" +#include "llpathfindingmanager.h" +#include "llsingleton.h" +#include "llhttpclient.h" +#include "llagent.h" +#include "llviewerregion.h" + +#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" + +#define CAP_SERVICE_AGENT_STATE "AgentPreferences" +#define ALTER_PERMANENT_OBJECTS_FIELD "alter_permanent_objects" + +//--------------------------------------------------------------------------- +// AgentStateResponder +//--------------------------------------------------------------------------- + +class AgentStateResponder : public LLHTTPClient::Responder +{ +public: + AgentStateResponder(LLPathfindingManager::agent_state_callback_t pAgentStateCB, const std::string &pCapabilityURL); + virtual ~AgentStateResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + LLPathfindingManager::agent_state_callback_t mAgentStateCB; + std::string mCapabilityURL; +}; + +//--------------------------------------------------------------------------- +// LLPathfindingManager +//--------------------------------------------------------------------------- + +LLPathfindingManager::LLPathfindingManager() +{ +} + +LLPathfindingManager::~LLPathfindingManager() +{ +} + +bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const +{ + std::string retrieveNavMeshURL = getRetrieveNavMeshURLForCurrentRegion(); + return !retrieveNavMeshURL.empty(); +} + +void LLPathfindingManager::requestGetAgentState(agent_state_callback_t pAgentStateCB) const +{ + std::string agentStateURL = getAgentStateURLForCurrentRegion(); + + if (agentStateURL.empty()) + { + pAgentStateCB(kAgentStateError); + } + else + { + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(pAgentStateCB, agentStateURL); + LLHTTPClient::get(agentStateURL, responder); + } +} + +void LLPathfindingManager::requestSetAgentState(EAgentState pAgentState, agent_state_callback_t pAgentStateCB) const +{ + std::string agentStateURL = getAgentStateURLForCurrentRegion(); + + if (agentStateURL.empty()) + { + pAgentStateCB(kAgentStateError); + } + else + { + LLSD request; + request[ALTER_PERMANENT_OBJECTS_FIELD] = static_cast(pAgentState == kAgentStateUnfrozen); + + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(pAgentStateCB, agentStateURL); + LLHTTPClient::post(agentStateURL, request, responder); + } +} + +void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, agent_state_callback_t pAgentStateCB) const +{ + llassert(pContent.has(ALTER_PERMANENT_OBJECTS_FIELD)); + llassert(pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).isBoolean()); + EAgentState agentState = (pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + + pAgentStateCB(agentState); +} + +void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL, agent_state_callback_t pAgentStateCB) const +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + pAgentStateCB(kAgentStateError); +} + +std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_RETRIEVE_NAVMESH); +} + +std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); +} + +std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const +{ + std::string capabilityURL(""); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + capabilityURL = region->getCapability(pCapabilityName); + } + + if (capabilityURL.empty()) + { + llwarns << "cannot find capability '" << pCapabilityName << "' for current region '" + << ((region != NULL) ? region->getName() : "") << "'" << llendl; + } + + return capabilityURL; +} + +//--------------------------------------------------------------------------- +// AgentStateResponder +//--------------------------------------------------------------------------- + +AgentStateResponder::AgentStateResponder(LLPathfindingManager::agent_state_callback_t pAgentStateCB, const std::string &pCapabilityURL) + : mAgentStateCB(pAgentStateCB), + mCapabilityURL(pCapabilityURL) +{ +} + +AgentStateResponder::~AgentStateResponder() +{ +} + +void AgentStateResponder::result(const LLSD &pContent) +{ + LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mAgentStateCB); +} + +void AgentStateResponder::error(U32 pStatus, const std::string &pReason) +{ + LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL, mAgentStateCB); +} -- cgit v1.2.3 From 1757f3967874a2885b45e3324bf19f677e76f6bc Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 21 Feb 2012 18:40:40 -0800 Subject: PATH-296: Refining the behavior of the freeze/unfreeze functionality to support both basic and edit/test pathfinding floaters open at the same time. --- indra/newview/llpathfindingmanager.cpp | 104 +++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 24 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e46ec0e171..3905e6d9f3 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -27,8 +27,6 @@ #include -#include - #include "llviewerprecompiledheaders.h" #include "llpathfindingmanager.h" #include "llsingleton.h" @@ -36,6 +34,9 @@ #include "llagent.h" #include "llviewerregion.h" +#include +#include + #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" #define CAP_SERVICE_AGENT_STATE "AgentPreferences" @@ -48,7 +49,7 @@ class AgentStateResponder : public LLHTTPClient::Responder { public: - AgentStateResponder(LLPathfindingManager::agent_state_callback_t pAgentStateCB, const std::string &pCapabilityURL); + AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState = LLPathfindingManager::kAgentStateUnknown); virtual ~AgentStateResponder(); virtual void result(const LLSD &pContent); @@ -57,8 +58,8 @@ public: protected: private: - LLPathfindingManager::agent_state_callback_t mAgentStateCB; - std::string mCapabilityURL; + std::string mCapabilityURL; + LLPathfindingManager::EAgentState mRequestedAgentState; }; //--------------------------------------------------------------------------- @@ -66,6 +67,10 @@ private: //--------------------------------------------------------------------------- LLPathfindingManager::LLPathfindingManager() + : LLSingleton(), + mAgentStateSignal(), + mAgentState(kAgentStateUnknown), + mLastKnownNonErrorAgentState(kAgentStateUnknown) { } @@ -79,52 +84,103 @@ bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const return !retrieveNavMeshURL.empty(); } -void LLPathfindingManager::requestGetAgentState(agent_state_callback_t pAgentStateCB) const +LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateSignal(agent_state_callback_t pAgentStateCallback) { - std::string agentStateURL = getAgentStateURLForCurrentRegion(); + return mAgentStateSignal.connect(pAgentStateCallback); +} - if (agentStateURL.empty()) +LLPathfindingManager::EAgentState LLPathfindingManager::getAgentState() +{ + if (!isPathfindingEnabledForCurrentRegion()) { - pAgentStateCB(kAgentStateError); + setAgentState(kAgentStateNotEnabled); } else { - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(pAgentStateCB, agentStateURL); - LLHTTPClient::get(agentStateURL, responder); + if (!isValidAgentState(mAgentState)) + { + requestGetAgentState(); + } } + + return mAgentState; } -void LLPathfindingManager::requestSetAgentState(EAgentState pAgentState, agent_state_callback_t pAgentStateCB) const +LLPathfindingManager::EAgentState LLPathfindingManager::getLastKnownNonErrorAgentState() const { + return mLastKnownNonErrorAgentState; +} + +void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState) +{ + llassert(isValidAgentState(pRequestedAgentState)); std::string agentStateURL = getAgentStateURLForCurrentRegion(); if (agentStateURL.empty()) { - pAgentStateCB(kAgentStateError); + setAgentState(kAgentStateNotEnabled); } else { LLSD request; - request[ALTER_PERMANENT_OBJECTS_FIELD] = static_cast(pAgentState == kAgentStateUnfrozen); + request[ALTER_PERMANENT_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(pAgentStateCB, agentStateURL); + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); LLHTTPClient::post(agentStateURL, request, responder); } } -void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, agent_state_callback_t pAgentStateCB) const +bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) +{ + return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); +} + +void LLPathfindingManager::requestGetAgentState() +{ + std::string agentStateURL = getAgentStateURLForCurrentRegion(); + + if (agentStateURL.empty()) + { + setAgentState(kAgentStateNotEnabled); + } + else + { + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL); + LLHTTPClient::get(agentStateURL, responder); + } +} + +void LLPathfindingManager::setAgentState(EAgentState pAgentState) +{ + mAgentState = pAgentState; + + if (mAgentState != kAgentStateError) + { + mLastKnownNonErrorAgentState = mAgentState; + } + + mAgentStateSignal(mAgentState); +} + +void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) { llassert(pContent.has(ALTER_PERMANENT_OBJECTS_FIELD)); llassert(pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).isBoolean()); EAgentState agentState = (pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - pAgentStateCB(agentState); + if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) + { + agentState = kAgentStateError; + llassert(0); + } + + setAgentState(agentState); } -void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL, agent_state_callback_t pAgentStateCB) const +void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - pAgentStateCB(kAgentStateError); + setAgentState(kAgentStateError); } std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const @@ -160,9 +216,9 @@ std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::st // AgentStateResponder //--------------------------------------------------------------------------- -AgentStateResponder::AgentStateResponder(LLPathfindingManager::agent_state_callback_t pAgentStateCB, const std::string &pCapabilityURL) - : mAgentStateCB(pAgentStateCB), - mCapabilityURL(pCapabilityURL) +AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState) + : mCapabilityURL(pCapabilityURL), + mRequestedAgentState(pRequestedAgentState) { } @@ -172,10 +228,10 @@ AgentStateResponder::~AgentStateResponder() void AgentStateResponder::result(const LLSD &pContent) { - LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mAgentStateCB); + LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mRequestedAgentState); } void AgentStateResponder::error(U32 pStatus, const std::string &pReason) { - LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL, mAgentStateCB); + LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); } -- cgit v1.2.3 From 42779ff3b4ba2503a0594276e1f415485be1eeab Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 22 Feb 2012 14:04:13 -0800 Subject: Adding a missing base constructor to the list. --- indra/newview/llpathfindingmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 3905e6d9f3..76766c4e09 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -217,7 +217,8 @@ std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::st //--------------------------------------------------------------------------- AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState) - : mCapabilityURL(pCapabilityURL), + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), mRequestedAgentState(pRequestedAgentState) { } -- cgit v1.2.3 From 73aa47f391341e6d6ef5136ef73302be689d3e9d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 23 Feb 2012 16:51:06 -0800 Subject: PATH-292: Reworking how and where linksets are requested and managed. --- indra/newview/llpathfindingmanager.cpp | 111 +++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 76766c4e09..aafa2eaa10 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -33,6 +33,8 @@ #include "llhttpclient.h" #include "llagent.h" #include "llviewerregion.h" +#include "llpathfindinglinkset.h" +#include "llpathfindinglinksetlist.h" #include #include @@ -42,6 +44,8 @@ #define CAP_SERVICE_AGENT_STATE "AgentPreferences" #define ALTER_PERMANENT_OBJECTS_FIELD "alter_permanent_objects" +#define CAP_SERVICE_LINKSETS "ObjectNavMeshProperties" + //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- @@ -62,6 +66,26 @@ private: LLPathfindingManager::EAgentState mRequestedAgentState; }; +//--------------------------------------------------------------------------- +// LinksetsResponder +//--------------------------------------------------------------------------- + +class LinksetsResponder : public LLHTTPClient::Responder +{ +public: + LinksetsResponder(const std::string &pCapabilityURL, LLPathfindingManager::linksets_callback_t pLinksetsCallback); + virtual ~LinksetsResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + +private: + std::string mCapabilityURL; + LLPathfindingManager::linksets_callback_t mLinksetsCallback; +}; + //--------------------------------------------------------------------------- // LLPathfindingManager //--------------------------------------------------------------------------- @@ -84,6 +108,11 @@ bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const return !retrieveNavMeshURL.empty(); } +bool LLPathfindingManager::isAllowAlterPermanent() +{ + return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); +} + LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateSignal(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); @@ -130,6 +159,45 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } +LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLinksets(linksets_callback_t pLinksetsCallback) const +{ + ELinksetsRequestStatus status; + + std::string linksetsURL = getLinksetsURLForCurrentRegion(); + if (linksetsURL.empty()) + {; + status = kLinksetsRequestNotEnabled; + } + else + { + LLHTTPClient::ResponderPtr responder = new LinksetsResponder(linksetsURL, pLinksetsCallback); + LLHTTPClient::get(linksetsURL, responder); + status = kLinksetsRequestStarted; + } + + return status; +} + +LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +{ + ELinksetsRequestStatus status; + + std::string linksetsURL = getLinksetsURLForCurrentRegion(); + if (linksetsURL.empty()) + { + status = kLinksetsRequestNotEnabled; + } + else + { + LLHTTPClient::ResponderPtr responder = new LinksetsResponder(linksetsURL, pLinksetsCallback); + LLSD postData = pLinksetList->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); + LLHTTPClient::put(linksetsURL, postData, responder); + status = kLinksetsRequestStarted; + } + + return status; +} + bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) { return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); @@ -183,6 +251,19 @@ void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string setAgentState(kAgentStateError); } +void LLPathfindingManager::handleLinksetsResult(const LLSD &pContent, linksets_callback_t pLinksetsCallback) const +{ + LLPathfindingLinksetListPtr linksetListPtr(new LLPathfindingLinksetList(pContent)); + pLinksetsCallback(kLinksetsRequestCompleted, linksetListPtr); +} + +void LLPathfindingManager::handleLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL, linksets_callback_t pLinksetsCallback) const +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + LLPathfindingLinksetListPtr linksetListPtr(new LLPathfindingLinksetList()); + pLinksetsCallback(kLinksetsRequestError, linksetListPtr); +} + std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const { return getCapabilityURLForCurrentRegion(CAP_SERVICE_RETRIEVE_NAVMESH); @@ -193,6 +274,11 @@ std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); } +std::string LLPathfindingManager::getLinksetsURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_LINKSETS); +} + std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const { std::string capabilityURL(""); @@ -236,3 +322,28 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) { LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); } + +//--------------------------------------------------------------------------- +// LinksetsResponder +//--------------------------------------------------------------------------- + +LinksetsResponder::LinksetsResponder(const std::string &pCapabilityURL, LLPathfindingManager::linksets_callback_t pLinksetsCallback) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mLinksetsCallback(pLinksetsCallback) +{ +} + +LinksetsResponder::~LinksetsResponder() +{ +} + +void LinksetsResponder::result(const LLSD &pContent) +{ + LLPathfindingManager::getInstance()->handleLinksetsResult(pContent, mLinksetsCallback); +} + +void LinksetsResponder::error(U32 pStatus, const std::string &pReason) +{ + LLPathfindingManager::getInstance()->handleLinksetsError(pStatus, pReason, mCapabilityURL, mLinksetsCallback); +} -- cgit v1.2.3 From 640b08c58aa76d88bd603576bcc03117ac983e90 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 23 Feb 2012 18:41:23 -0800 Subject: PATH-292: Fixing an issue where clicking Apply Edits without any changes resulted in an usable floater state. --- indra/newview/llpathfindingmanager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index aafa2eaa10..7cfa07718b 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -165,7 +165,7 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLin std::string linksetsURL = getLinksetsURLForCurrentRegion(); if (linksetsURL.empty()) - {; + { status = kLinksetsRequestNotEnabled; } else @@ -191,8 +191,15 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin { LLHTTPClient::ResponderPtr responder = new LinksetsResponder(linksetsURL, pLinksetsCallback); LLSD postData = pLinksetList->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); - LLHTTPClient::put(linksetsURL, postData, responder); - status = kLinksetsRequestStarted; + if (postData.isUndefined()) + { + status = kLinksetsRequestCompleted; + } + else + { + LLHTTPClient::put(linksetsURL, postData, responder); + status = kLinksetsRequestStarted; + } } return status; -- cgit v1.2.3 From 9b06300e2c94eae83a29637073f65d4ffc73bf6d Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Sat, 25 Feb 2012 22:27:06 -0800 Subject: PATH-292: Adding the ability to view and edit pathfinding attributes of the terrain. --- indra/newview/llpathfindingmanager.cpp | 255 +++++++++++++++++++++++++++------ 1 file changed, 215 insertions(+), 40 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 7cfa07718b..3a96ed72e5 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -44,7 +44,8 @@ #define CAP_SERVICE_AGENT_STATE "AgentPreferences" #define ALTER_PERMANENT_OBJECTS_FIELD "alter_permanent_objects" -#define CAP_SERVICE_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" //--------------------------------------------------------------------------- // AgentStateResponder @@ -70,20 +71,79 @@ private: // LinksetsResponder //--------------------------------------------------------------------------- -class LinksetsResponder : public LLHTTPClient::Responder +class LinksetsResponder { public: - LinksetsResponder(const std::string &pCapabilityURL, LLPathfindingManager::linksets_callback_t pLinksetsCallback); + LinksetsResponder(LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); virtual ~LinksetsResponder(); + + void handleObjectLinksetsResult(const LLSD &pContent); + void handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); + void handleTerrainLinksetsResult(const LLSD &pContent); + void handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); + +protected: + +private: + void sendCallback(); + + typedef enum + { + kNotRequested, + kWaiting, + kReceivedGood, + kReceivedError + } EMessagingState; + + LLPathfindingManager::linksets_callback_t mLinksetsCallback; + + EMessagingState mObjectMessagingState; + EMessagingState mTerrainMessagingState; + + LLPathfindingLinksetListPtr mObjectLinksetListPtr; + LLPathfindingLinksetPtr mTerrainLinksetPtr; +}; + +typedef boost::shared_ptr LinksetsResponderPtr; + +//--------------------------------------------------------------------------- +// ObjectLinksetsResponder +//--------------------------------------------------------------------------- +class ObjectLinksetsResponder : public LLHTTPClient::Responder +{ +public: + ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); + virtual ~ObjectLinksetsResponder(); + virtual void result(const LLSD &pContent); virtual void error(U32 pStatus, const std::string &pReason); - + protected: + +private: + std::string mCapabilityURL; + LinksetsResponderPtr mLinksetsResponsderPtr; +}; + +//--------------------------------------------------------------------------- +// TerrainLinksetsResponder +//--------------------------------------------------------------------------- +class TerrainLinksetsResponder : public LLHTTPClient::Responder +{ +public: + TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); + virtual ~TerrainLinksetsResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + private: - std::string mCapabilityURL; - LLPathfindingManager::linksets_callback_t mLinksetsCallback; + std::string mCapabilityURL; + LinksetsResponderPtr mLinksetsResponsderPtr; }; //--------------------------------------------------------------------------- @@ -163,15 +223,21 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLin { ELinksetsRequestStatus status; - std::string linksetsURL = getLinksetsURLForCurrentRegion(); - if (linksetsURL.empty()) + std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); + std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); + if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { status = kLinksetsRequestNotEnabled; } else { - LLHTTPClient::ResponderPtr responder = new LinksetsResponder(linksetsURL, pLinksetsCallback); - LLHTTPClient::get(linksetsURL, responder); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, true, true)); + + LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + + LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); + LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); status = kLinksetsRequestStarted; } @@ -180,24 +246,38 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLin LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const { - ELinksetsRequestStatus status; + ELinksetsRequestStatus status = kLinksetsRequestNotEnabled; - std::string linksetsURL = getLinksetsURLForCurrentRegion(); - if (linksetsURL.empty()) + std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); + std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); + if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { status = kLinksetsRequestNotEnabled; } else { - LLHTTPClient::ResponderPtr responder = new LinksetsResponder(linksetsURL, pLinksetsCallback); - LLSD postData = pLinksetList->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); - if (postData.isUndefined()) + LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); + LLSD terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + if (objectPostData.isUndefined() && terrainPostData.isUndefined()) { status = kLinksetsRequestCompleted; } else { - LLHTTPClient::put(linksetsURL, postData, responder); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); + + if (!objectPostData.isUndefined()) + { + LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); + LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder); + } + + if (!terrainPostData.isUndefined()) + { + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); + } + status = kLinksetsRequestStarted; } } @@ -258,19 +338,6 @@ void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string setAgentState(kAgentStateError); } -void LLPathfindingManager::handleLinksetsResult(const LLSD &pContent, linksets_callback_t pLinksetsCallback) const -{ - LLPathfindingLinksetListPtr linksetListPtr(new LLPathfindingLinksetList(pContent)); - pLinksetsCallback(kLinksetsRequestCompleted, linksetListPtr); -} - -void LLPathfindingManager::handleLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL, linksets_callback_t pLinksetsCallback) const -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - LLPathfindingLinksetListPtr linksetListPtr(new LLPathfindingLinksetList()); - pLinksetsCallback(kLinksetsRequestError, linksetListPtr); -} - std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const { return getCapabilityURLForCurrentRegion(CAP_SERVICE_RETRIEVE_NAVMESH); @@ -281,9 +348,14 @@ std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); } -std::string LLPathfindingManager::getLinksetsURLForCurrentRegion() const +std::string LLPathfindingManager::getObjectLinksetsURLForCurrentRegion() const { - return getCapabilityURLForCurrentRegion(CAP_SERVICE_LINKSETS); + return getCapabilityURLForCurrentRegion(CAP_SERVICE_OBJECT_LINKSETS); +} + +std::string LLPathfindingManager::getTerrainLinksetsURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_TERRAIN_LINKSETS); } std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const @@ -334,10 +406,12 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) // LinksetsResponder //--------------------------------------------------------------------------- -LinksetsResponder::LinksetsResponder(const std::string &pCapabilityURL, LLPathfindingManager::linksets_callback_t pLinksetsCallback) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mLinksetsCallback(pLinksetsCallback) +LinksetsResponder::LinksetsResponder(LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) + : mLinksetsCallback(pLinksetsCallback), + mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), + mTerrainMessagingState(pIsTerrainRequested ? kWaiting : kNotRequested), + mObjectLinksetListPtr(), + mTerrainLinksetPtr() { } @@ -345,12 +419,113 @@ LinksetsResponder::~LinksetsResponder() { } -void LinksetsResponder::result(const LLSD &pContent) +void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent) +{ + mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent)); + + mObjectMessagingState = kReceivedGood; + if (mTerrainMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + mObjectMessagingState = kReceivedError; + if (mTerrainMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent) +{ + mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent)); + + mTerrainMessagingState = kReceivedGood; + if (mObjectMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + mTerrainMessagingState = kReceivedError; + if (mObjectMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::sendCallback() +{ + llassert(mObjectMessagingState != kWaiting); + llassert(mTerrainMessagingState != kWaiting); + LLPathfindingManager::ELinksetsRequestStatus requestStatus = + ((((mObjectMessagingState == kReceivedGood) || (mObjectMessagingState == kNotRequested)) && + ((mTerrainMessagingState == kReceivedGood) || (mTerrainMessagingState == kNotRequested))) ? + LLPathfindingManager::kLinksetsRequestCompleted : LLPathfindingManager::kLinksetsRequestError); + + if (mObjectMessagingState != kReceivedGood) + { + mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList()); + } + + if (mTerrainMessagingState == kReceivedGood) + { + mObjectLinksetListPtr->insert(std::pair(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); + } + + mLinksetsCallback(requestStatus, mObjectLinksetListPtr); +} + +//--------------------------------------------------------------------------- +// ObjectLinksetsResponder +//--------------------------------------------------------------------------- + +ObjectLinksetsResponder::ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) + : mCapabilityURL(pCapabilityURL), + mLinksetsResponsderPtr(pLinksetsResponsderPtr) +{ +} + +ObjectLinksetsResponder::~ObjectLinksetsResponder() +{ +} + +void ObjectLinksetsResponder::result(const LLSD &pContent) +{ + mLinksetsResponsderPtr->handleObjectLinksetsResult(pContent); +} + +void ObjectLinksetsResponder::error(U32 pStatus, const std::string &pReason) +{ + mLinksetsResponsderPtr->handleObjectLinksetsError(pStatus, pReason, mCapabilityURL); +} + +//--------------------------------------------------------------------------- +// TerrainLinksetsResponder +//--------------------------------------------------------------------------- + +TerrainLinksetsResponder::TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) +: mCapabilityURL(pCapabilityURL), +mLinksetsResponsderPtr(pLinksetsResponsderPtr) +{ +} + +TerrainLinksetsResponder::~TerrainLinksetsResponder() +{ +} + +void TerrainLinksetsResponder::result(const LLSD &pContent) { - LLPathfindingManager::getInstance()->handleLinksetsResult(pContent, mLinksetsCallback); + mLinksetsResponsderPtr->handleTerrainLinksetsResult(pContent); } -void LinksetsResponder::error(U32 pStatus, const std::string &pReason) +void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) { - LLPathfindingManager::getInstance()->handleLinksetsError(pStatus, pReason, mCapabilityURL, mLinksetsCallback); + mLinksetsResponsderPtr->handleTerrainLinksetsError(pStatus, pReason, mCapabilityURL); } -- cgit v1.2.3 From 1503338ddcd170871815d70d328cbbd1dfd40c82 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 27 Feb 2012 16:15:16 -0800 Subject: PATH-292: Ensuring that the terrain linkset is not visible and/or editable to a non-estate non-god agent. --- indra/newview/llpathfindingmanager.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 3a96ed72e5..5c9293a28a 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -173,6 +173,12 @@ bool LLPathfindingManager::isAllowAlterPermanent() return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); } +bool LLPathfindingManager::isAllowViewTerrainProperties() const +{ + LLViewerRegion* region = getCurrentRegion(); + return (gAgent.isGodlike() || ((region != NULL) && region->canManageEstate())); +} + LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateSignal(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); @@ -231,13 +237,18 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLin } else { - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, true, true)); + bool doRequestTerrain = isAllowViewTerrainProperties(); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, true, doRequestTerrain)); LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); - LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); - LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + + if (doRequestTerrain) + { + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + } + status = kLinksetsRequestStarted; } @@ -257,7 +268,12 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin else { LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); - LLSD terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + LLSD terrainPostData; + if (isAllowViewTerrainProperties()) + { + terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + } + if (objectPostData.isUndefined() && terrainPostData.isUndefined()) { status = kLinksetsRequestCompleted; @@ -362,7 +378,7 @@ std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::st { std::string capabilityURL(""); - LLViewerRegion* region = gAgent.getRegion(); + LLViewerRegion* region = getCurrentRegion(); if (region != NULL) { capabilityURL = region->getCapability(pCapabilityName); @@ -377,6 +393,11 @@ std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::st return capabilityURL; } +LLViewerRegion *LLPathfindingManager::getCurrentRegion() const +{ + return gAgent.getRegion(); +} + //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From a33e24413ea74aaad91d9eeaa685d1c523c5d210 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 2 Mar 2012 19:17:16 -0800 Subject: PATH-304,PATH-205: Initial reworking of the navmesh download functionality. --- indra/newview/llpathfindingmanager.cpp | 118 ++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5c9293a28a..9a36923bd5 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -33,6 +33,7 @@ #include "llhttpclient.h" #include "llagent.h" #include "llviewerregion.h" +#include "llpathfindingnavmesh.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" @@ -47,6 +48,27 @@ #define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" +//--------------------------------------------------------------------------- +// NavMeshResponder +//--------------------------------------------------------------------------- + +class NavMeshResponder : public LLHTTPClient::Responder +{ +public: + NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr); + virtual ~NavMeshResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; + U32 mNavMeshVersion; + LLPathfindingNavMeshPtr mNavMeshPtr; +}; + //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- @@ -152,6 +174,8 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), + mNavMeshMap(), + mNavMeshVersionXXX(0), mAgentStateSignal(), mAgentState(kAgentStateUnknown), mLastKnownNonErrorAgentState(kAgentStateUnknown) @@ -179,7 +203,49 @@ bool LLPathfindingManager::isAllowViewTerrainProperties() const return (gAgent.isGodlike() || ((region != NULL) && region->canManageEstate())); } -LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateSignal(agent_state_callback_t pAgentStateCallback) +LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListenerForCurrentRegion(LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForCurrentRegion(); + return navMeshPtr->registerNavMeshListener(pNavMeshCallback); +} + +void LLPathfindingManager::requestGetNavMeshForCurrentRegion() +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForCurrentRegion(); + + if (navMeshPtr->hasNavMeshVersion(mNavMeshVersionXXX)) + { + navMeshPtr->handleRefresh(); + } + else + { + LLViewerRegion *region = getCurrentRegion(); + if (region == NULL) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + std::string navMeshURL = getRetrieveNavMeshURLForCurrentRegion(); + if (navMeshURL.empty()) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + navMeshPtr->handleNavMeshStart(mNavMeshVersionXXX); + LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, mNavMeshVersionXXX, navMeshPtr); + + LLSD postData; + postData["agent_id"] = gAgent.getID(); + postData["region_id"] = region->getRegionID(); + LLHTTPClient::post(navMeshURL, postData, responder); + } + } + } +} + +LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); } @@ -301,6 +367,31 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin return status; } +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForCurrentRegion() +{ + + LLUUID regionUUID; + LLViewerRegion *region = getCurrentRegion(); + if (region != NULL) + { + regionUUID = region->getRegionID(); + } + + LLPathfindingNavMeshPtr navMeshPtr; + NavMeshMap::iterator navMeshIter = mNavMeshMap.find(regionUUID); + if (navMeshIter == mNavMeshMap.end()) + { + navMeshPtr = LLPathfindingNavMeshPtr(new LLPathfindingNavMesh(regionUUID)); + mNavMeshMap.insert(std::pair(regionUUID, navMeshPtr)); + } + else + { + navMeshPtr = navMeshIter->second; + } + + return navMeshPtr; +} + bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) { return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); @@ -398,6 +489,31 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } +//--------------------------------------------------------------------------- +// NavMeshResponder +//--------------------------------------------------------------------------- + +NavMeshResponder::NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr) + : mCapabilityURL(pCapabilityURL), + mNavMeshVersion(pNavMeshVersion), + mNavMeshPtr(pNavMeshPtr) +{ +} + +NavMeshResponder::~NavMeshResponder() +{ +} + +void NavMeshResponder::result(const LLSD &pContent) +{ + mNavMeshPtr->handleNavMeshResult(pContent, mNavMeshVersion); +} + +void NavMeshResponder::error(U32 pStatus, const std::string& pReason) +{ + mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion); +} + //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From 49477cec951a658d2014afd7ac7c3920d6844a50 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 6 Mar 2012 11:01:29 -0800 Subject: Updating the freeze/unfreeze service with the new field names. Also, still supporting the old field names until fully deprecated from all server builds. --- indra/newview/llpathfindingmanager.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5c9293a28a..a59dda74ac 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -42,7 +42,8 @@ #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" #define CAP_SERVICE_AGENT_STATE "AgentPreferences" -#define ALTER_PERMANENT_OBJECTS_FIELD "alter_permanent_objects" +#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD "alter_permanent_objects" #define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" @@ -218,7 +219,10 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState else { LLSD request; - request[ALTER_PERMANENT_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); + request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); +#ifdef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + request[DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); +#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); LLHTTPClient::post(agentStateURL, request, responder); @@ -335,9 +339,24 @@ void LLPathfindingManager::setAgentState(EAgentState pAgentState) void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) { - llassert(pContent.has(ALTER_PERMANENT_OBJECTS_FIELD)); - llassert(pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).isBoolean()); - EAgentState agentState = (pContent.get(ALTER_PERMANENT_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); +#ifndef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); +#else // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + EAgentState agentState = kAgentStateUnknown; + if (pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)) + { + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + } + else + { + llassert(pContent.has(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + agentState = (pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + } +#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) { -- cgit v1.2.3 From a0c626fe411336871505c2c414143ae4b2f73259 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 6 Mar 2012 18:40:37 -0800 Subject: PATH-205,PATH-304: More work to handle downloading of out-of-date navmeshes. --- indra/newview/llpathfindingmanager.cpp | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 7fbf9ba62c..8597498a76 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -204,15 +204,15 @@ bool LLPathfindingManager::isAllowViewTerrainProperties() const return (gAgent.isGodlike() || ((region != NULL) && region->canManageEstate())); } -LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListenerForCurrentRegion(LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback) +LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback) { - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForCurrentRegion(); + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); return navMeshPtr->registerNavMeshListener(pNavMeshCallback); } -void LLPathfindingManager::requestGetNavMeshForCurrentRegion() +void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForCurrentRegion(); + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); if (navMeshPtr->hasNavMeshVersion(mNavMeshVersionXXX)) { @@ -220,14 +220,13 @@ void LLPathfindingManager::requestGetNavMeshForCurrentRegion() } else { - LLViewerRegion *region = getCurrentRegion(); - if (region == NULL) + if (pRegion == NULL) { navMeshPtr->handleNavMeshNotEnabled(); } else { - std::string navMeshURL = getRetrieveNavMeshURLForCurrentRegion(); + std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); if (navMeshURL.empty()) { navMeshPtr->handleNavMeshNotEnabled(); @@ -239,7 +238,7 @@ void LLPathfindingManager::requestGetNavMeshForCurrentRegion() LLSD postData; postData["agent_id"] = gAgent.getID(); - postData["region_id"] = region->getRegionID(); + postData["region_id"] = pRegion->getRegionID(); LLHTTPClient::post(navMeshURL, postData, responder); } } @@ -371,14 +370,13 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin return status; } -LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForCurrentRegion() +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion *pRegion) { LLUUID regionUUID; - LLViewerRegion *region = getCurrentRegion(); - if (region != NULL) + if (pRegion != NULL) { - regionUUID = region->getRegionID(); + regionUUID = pRegion->getRegionID(); } LLPathfindingNavMeshPtr navMeshPtr; @@ -469,6 +467,11 @@ std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const return getCapabilityURLForCurrentRegion(CAP_SERVICE_RETRIEVE_NAVMESH); } +std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion *pRegion) const +{ + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_RETRIEVE_NAVMESH); +} + std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const { return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); @@ -485,19 +488,23 @@ std::string LLPathfindingManager::getTerrainLinksetsURLForCurrentRegion() const } std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const +{ + return getCapabilityURLForRegion(getCurrentRegion(), pCapabilityName); +} + +std::string LLPathfindingManager::getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const { std::string capabilityURL(""); - LLViewerRegion* region = getCurrentRegion(); - if (region != NULL) + if (pRegion != NULL) { - capabilityURL = region->getCapability(pCapabilityName); + capabilityURL = pRegion->getCapability(pCapabilityName); } if (capabilityURL.empty()) { llwarns << "cannot find capability '" << pCapabilityName << "' for current region '" - << ((region != NULL) ? region->getName() : "") << "'" << llendl; + << ((pRegion != NULL) ? pRegion->getName() : "") << "'" << llendl; } return capabilityURL; -- cgit v1.2.3 From 160a9532bad6d4d0112b888b3490d94ee34f5f13 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 7 Mar 2012 15:08:35 -0800 Subject: Removing unreferenced parameters from the post data. --- indra/newview/llpathfindingmanager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 8597498a76..cba0501ad2 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -237,8 +237,6 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, mNavMeshVersionXXX, navMeshPtr); LLSD postData; - postData["agent_id"] = gAgent.getID(); - postData["region_id"] = pRegion->getRegionID(); LLHTTPClient::post(navMeshURL, postData, responder); } } -- cgit v1.2.3 From f578181af9cbe3277374578c27487e2e72956079 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 8 Mar 2012 12:34:11 -0800 Subject: PATH-304: Adding functionality to handle the reloading of out-of-date navmeshes. --- indra/newview/llpathfindingmanager.cpp | 60 +++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index cba0501ad2..ebefebbb64 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -26,8 +26,10 @@ */ #include +#include #include "llviewerprecompiledheaders.h" +#include "llsd.h" #include "llpathfindingmanager.h" #include "llsingleton.h" #include "llhttpclient.h" @@ -36,6 +38,7 @@ #include "llpathfindingnavmesh.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" +#include "llhttpnode.h" #include #include @@ -49,6 +52,20 @@ #define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" +#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavmeshStatusUpdate" + +//--------------------------------------------------------------------------- +// LLNavMeshSimStateChangeNode +//--------------------------------------------------------------------------- + +class LLNavMeshSimStateChangeNode : public LLHTTPNode +{ +public: + virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; +}; + +LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); + //--------------------------------------------------------------------------- // NavMeshResponder //--------------------------------------------------------------------------- @@ -243,6 +260,12 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) } } +void LLPathfindingManager::handleNavMeshUpdate(const LLUUID &pRegionUUID, U32 pNavMeshVersion) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegionUUID); + navMeshPtr->handleNavMeshNewVersion(++mNavMeshVersionXXX); +} + LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); @@ -368,21 +391,14 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin return status; } -LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion *pRegion) +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) { - - LLUUID regionUUID; - if (pRegion != NULL) - { - regionUUID = pRegion->getRegionID(); - } - LLPathfindingNavMeshPtr navMeshPtr; - NavMeshMap::iterator navMeshIter = mNavMeshMap.find(regionUUID); + NavMeshMap::iterator navMeshIter = mNavMeshMap.find(pRegionUUID); if (navMeshIter == mNavMeshMap.end()) { - navMeshPtr = LLPathfindingNavMeshPtr(new LLPathfindingNavMesh(regionUUID)); - mNavMeshMap.insert(std::pair(regionUUID, navMeshPtr)); + navMeshPtr = LLPathfindingNavMeshPtr(new LLPathfindingNavMesh(pRegionUUID)); + mNavMeshMap.insert(std::pair(pRegionUUID, navMeshPtr)); } else { @@ -392,6 +408,17 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return navMeshPtr; } +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion *pRegion) +{ + LLUUID regionUUID; + if (pRegion != NULL) + { + regionUUID = pRegion->getRegionID(); + } + + return getNavMeshForRegion(regionUUID); +} + bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) { return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); @@ -513,6 +540,17 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } +//--------------------------------------------------------------------------- +// LLNavMeshSimStateChangeNode +//--------------------------------------------------------------------------- + +void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +{ + LLViewerRegion *region = gAgent.getRegion(); + U32 navMeshVersion = 0U; + LLPathfindingManager::getInstance()->handleNavMeshUpdate(region->getRegionID(), navMeshVersion); +} + //--------------------------------------------------------------------------- // NavMeshResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From b3197fc12e41bc60e3510d840c67ef98816c3ae8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 12 Mar 2012 18:48:40 -0700 Subject: PATH-304: Making the navmesh version information work for both Premium Wilderness regions (old pathfinding simulator build with missing capabilities) as well as the new pathfinding simulator builds with the version services. --- indra/newview/llpathfindingmanager.cpp | 170 +++++++++++++++++++++++++++------ 1 file changed, 140 insertions(+), 30 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index ebefebbb64..9cd3d5625c 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -30,12 +30,14 @@ #include "llviewerprecompiledheaders.h" #include "llsd.h" +#include "lluuid.h" #include "llpathfindingmanager.h" #include "llsingleton.h" #include "llhttpclient.h" #include "llagent.h" #include "llviewerregion.h" #include "llpathfindingnavmesh.h" +#include "llpathfindingnavmeshstatus.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llhttpnode.h" @@ -45,14 +47,16 @@ #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" -#define CAP_SERVICE_AGENT_STATE "AgentPreferences" +#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" + +#define CAP_SERVICE_AGENT_STATE "AgentPreferences" #define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" #define DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD "alter_permanent_objects" -#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" -#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" +#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" -#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavmeshStatusUpdate" +#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode @@ -66,6 +70,27 @@ public: LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); +//--------------------------------------------------------------------------- +// NavMeshStatusResponder +//--------------------------------------------------------------------------- + +class NavMeshStatusResponder : public LLHTTPClient::Responder +{ +public: + NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion); + virtual ~NavMeshStatusResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; + LLViewerRegion *mRegion; + LLUUID mRegionUUID; +}; + //--------------------------------------------------------------------------- // NavMeshResponder //--------------------------------------------------------------------------- @@ -193,7 +218,6 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), mNavMeshMap(), - mNavMeshVersionXXX(0), mAgentStateSignal(), mAgentState(kAgentStateUnknown), mLastKnownNonErrorAgentState(kAgentStateUnknown) @@ -206,7 +230,12 @@ LLPathfindingManager::~LLPathfindingManager() bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const { - std::string retrieveNavMeshURL = getRetrieveNavMeshURLForCurrentRegion(); + return isPathfindingEnabledForRegion(getCurrentRegion()); +} + +bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const +{ + std::string retrieveNavMeshURL = getRetrieveNavMeshURLForRegion(pRegion); return !retrieveNavMeshURL.empty(); } @@ -231,39 +260,64 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - if (navMeshPtr->hasNavMeshVersion(mNavMeshVersionXXX)) + if ((pRegion == NULL) || !isPathfindingEnabledForRegion(pRegion)) { - navMeshPtr->handleRefresh(); + navMeshPtr->handleNavMeshNotEnabled(); } else { - if (pRegion == NULL) + std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); +#ifdef DEPRECATED_UNVERSIONED_NAVMESH + if (navMeshStatusURL.empty()) { - navMeshPtr->handleNavMeshNotEnabled(); + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshPtr->getNavMeshVersion() + 1U); } else { - std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); - if (navMeshURL.empty()) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - navMeshPtr->handleNavMeshStart(mNavMeshVersionXXX); - LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, mNavMeshVersionXXX, navMeshPtr); + LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); + LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); + } +#else // DEPRECATED_UNVERSIONED_NAVMESH + llassert(!navMeshStatusURL.empty()); + LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); + LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); +#endif // DEPRECATED_UNVERSIONED_NAVMESH + } +} - LLSD postData; - LLHTTPClient::post(navMeshURL, postData, responder); - } +void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus.getVersion())) + { + navMeshPtr->handleRefresh(); + } + else + { + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus.getVersion()); } } } -void LLPathfindingManager::handleNavMeshUpdate(const LLUUID &pRegionUUID, U32 pNavMeshVersion) +void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) { - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegionUUID); - navMeshPtr->handleNavMeshNewVersion(++mNavMeshVersionXXX); + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus.getVersion()); + } } LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) @@ -391,6 +445,31 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin return status; } +void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, U32 pNavMeshVersion) +{ + if ((pRegion == NULL) || !pRegion->isAlive()) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); + + if (navMeshURL.empty()) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + navMeshPtr->handleNavMeshStart(pNavMeshVersion); + LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshVersion, navMeshPtr); + + LLSD postData; + LLHTTPClient::post(navMeshURL, postData, responder); + } + } +} + LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) { LLPathfindingNavMeshPtr navMeshPtr; @@ -487,9 +566,9 @@ void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string setAgentState(kAgentStateError); } -std::string LLPathfindingManager::getRetrieveNavMeshURLForCurrentRegion() const +std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const { - return getCapabilityURLForCurrentRegion(CAP_SERVICE_RETRIEVE_NAVMESH); + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_NAVMESH_STATUS); } std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion *pRegion) const @@ -546,9 +625,40 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { - LLViewerRegion *region = gAgent.getRegion(); - U32 navMeshVersion = 0U; - LLPathfindingManager::getInstance()->handleNavMeshUpdate(region->getRegionID(), navMeshVersion); + LLPathfindingNavMeshStatus navMeshStatus(pContext); + LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(pContext); +} + +//--------------------------------------------------------------------------- +// NavMeshStatusResponder +//--------------------------------------------------------------------------- + +NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) + : mCapabilityURL(pCapabilityURL), + mRegion(pRegion), + mRegionUUID() +{ + if (mRegion != NULL) + { + mRegionUUID = mRegion->getRegionID(); + } +} + +NavMeshStatusResponder::~NavMeshStatusResponder() +{ +} + +void NavMeshStatusResponder::result(const LLSD &pContent) +{ + LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); +} + +void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) +{ + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); } //--------------------------------------------------------------------------- -- cgit v1.2.3 From c990cc71ce124059a072c7778ac962253bacb199 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 12 Mar 2012 19:18:19 -0700 Subject: PATH-304: Adding an extra state for the pathfinding console to report that the status of the navmesh is being checked. --- indra/newview/llpathfindingmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 9cd3d5625c..9abd9fda1a 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -274,11 +274,13 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) } else { + navMeshPtr->handleNavMeshCheckVersion(); LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); } #else // DEPRECATED_UNVERSIONED_NAVMESH llassert(!navMeshStatusURL.empty()); + navMeshPtr->handleNavMeshCheckVersion(); LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); #endif // DEPRECATED_UNVERSIONED_NAVMESH @@ -297,7 +299,7 @@ void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMesh { if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus.getVersion())) { - navMeshPtr->handleRefresh(); + navMeshPtr->handleRefresh(pNavMeshStatus.getVersion()); } else { -- cgit v1.2.3 From b84db8354d992cfddfd64eb80ebd80c4b6baf3f8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 13 Mar 2012 10:23:55 -0700 Subject: PATH-304: Adding more debug messaging and correcting the camel-case of the NavMesh update message. --- indra/newview/llpathfindingmanager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 9abd9fda1a..f3b9bc4b8a 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -627,6 +627,9 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "Received NavMeshStatusUpdate: " << pContext << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE LLPathfindingNavMeshStatus navMeshStatus(pContext); LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(pContext); } @@ -652,6 +655,9 @@ NavMeshStatusResponder::~NavMeshStatusResponder() void NavMeshStatusResponder::result(const LLSD &pContent) { +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "Received requested NavMeshStatus: " << pContent << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); } -- cgit v1.2.3 From 66374e4d656ae07d4dddc010e6239267ffe94b05 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 13 Mar 2012 11:59:44 -0700 Subject: PATH-304: Proper handling of the sim-to-viewer message. --- indra/newview/llpathfindingmanager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index f3b9bc4b8a..251e330914 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -41,6 +41,7 @@ #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llhttpnode.h" +//#include "llpathfindingnavmeshzone.h" // XXX #include #include @@ -57,6 +58,7 @@ #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" +#define SIM_MESSAGE_BODY_FIELD "body" //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode @@ -628,10 +630,12 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { #ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "Received NavMeshStatusUpdate: " << pContext << llendl; + llinfos << "STINSON DEBUG: Received NavMeshStatusUpdate: " << pInput << llendl; #endif // XXX_STINSON_DEBUG_NAVMESH_ZONE - LLPathfindingNavMeshStatus navMeshStatus(pContext); - LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(pContext); + llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); + LLPathfindingNavMeshStatus navMeshStatus(pInput.get(SIM_MESSAGE_BODY_FIELD)); + LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } //--------------------------------------------------------------------------- @@ -656,7 +660,7 @@ NavMeshStatusResponder::~NavMeshStatusResponder() void NavMeshStatusResponder::result(const LLSD &pContent) { #ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "Received requested NavMeshStatus: " << pContent << llendl; + llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; #endif // XXX_STINSON_DEBUG_NAVMESH_ZONE LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); -- cgit v1.2.3 From e1aac3718192d7ce663f9134492b4a12dc1637d0 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 13 Mar 2012 16:42:07 -0700 Subject: PATH-394: First pass at handling the sim-to-viewer message reporting the change from FROZEN to UNFROZEN state. --- indra/newview/llpathfindingmanager.cpp | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 251e330914..46bfbe0bb0 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -58,6 +58,7 @@ #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" #define SIM_MESSAGE_BODY_FIELD "body" //--------------------------------------------------------------------------- @@ -72,6 +73,18 @@ public: LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); +//--------------------------------------------------------------------------- +// LLAgentStateChangeNode +//--------------------------------------------------------------------------- + +class LLAgentStateChangeNode : public LLHTTPNode +{ +public: + virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; +}; + +LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); + //--------------------------------------------------------------------------- // NavMeshStatusResponder //--------------------------------------------------------------------------- @@ -570,6 +583,15 @@ void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string setAgentState(kAgentStateError); } +void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) +{ + llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + + setAgentState(agentState); +} + std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const { return getCapabilityURLForRegion(pRegion, CAP_SERVICE_NAVMESH_STATUS); @@ -638,6 +660,20 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } +//--------------------------------------------------------------------------- +// LLAgentStateChangeNode +//--------------------------------------------------------------------------- + +void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +{ +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "STINSON DEBUG: Received AgentPreferencesUpdate: " << pInput << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE + llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); + LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); +} + //--------------------------------------------------------------------------- // NavMeshStatusResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From d4fb7c99febf07b4eb7f3a9d2eab485e356d1439 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 14 Mar 2012 14:09:36 -0700 Subject: PATH-302: Adding in status reporting for the simulator navmesh status. Separating the viewer status messaging from the simulator status. --- indra/newview/llpathfindingmanager.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 46bfbe0bb0..e3242de812 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -41,7 +41,6 @@ #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llhttpnode.h" -//#include "llpathfindingnavmeshzone.h" // XXX #include #include @@ -254,6 +253,14 @@ bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion return !retrieveNavMeshURL.empty(); } +#ifdef DEPRECATED_UNVERSIONED_NAVMESH +bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const +{ + std::string navMeshStatusURL = getNavMeshStatusURLForRegion(getCurrentRegion()); + return !navMeshStatusURL.empty(); +} +#endif // DEPRECATED_UNVERSIONED_NAVMESH + bool LLPathfindingManager::isAllowAlterPermanent() { return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); @@ -285,7 +292,9 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) #ifdef DEPRECATED_UNVERSIONED_NAVMESH if (navMeshStatusURL.empty()) { - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshPtr->getNavMeshVersion() + 1U); + LLPathfindingNavMeshStatus navMeshStatus = navMeshPtr->getNavMeshStatusXXX(); + navMeshStatus.incrementNavMeshVersionXXX(); + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshStatus); } else { @@ -312,13 +321,13 @@ void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMesh } else { - if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus.getVersion())) + if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) { - navMeshPtr->handleRefresh(pNavMeshStatus.getVersion()); + navMeshPtr->handleRefresh(pNavMeshStatus); } else { - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus.getVersion()); + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); } } } @@ -333,7 +342,7 @@ void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshS } else { - navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus.getVersion()); + navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); } } @@ -462,7 +471,7 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin return status; } -void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, U32 pNavMeshVersion) +void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) { if ((pRegion == NULL) || !pRegion->isAlive()) { @@ -478,8 +487,8 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt } else { - navMeshPtr->handleNavMeshStart(pNavMeshVersion); - LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshVersion, navMeshPtr); + navMeshPtr->handleNavMeshStart(pNavMeshStatus); + LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshStatus.getVersion(), navMeshPtr); LLSD postData; LLHTTPClient::post(navMeshURL, postData, responder); -- cgit v1.2.3 From 473da43c1bbc20245b3a74c1adc7c92f91d25807 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 27 Mar 2012 19:05:29 -0700 Subject: Refactoring the characters floater code. --- indra/newview/llpathfindingmanager.cpp | 183 ++++++++++++++++++++++++--------- 1 file changed, 132 insertions(+), 51 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e3242de812..fdff380050 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -40,6 +40,7 @@ #include "llpathfindingnavmeshstatus.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" +#include "llpathfindingcharacterlist.h" #include "llhttpnode.h" #include @@ -56,6 +57,8 @@ #define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" +#define CAP_SERVICE_CHARACTERS "CharacterProperties" + #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" #define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" #define SIM_MESSAGE_BODY_FIELD "body" @@ -225,6 +228,26 @@ private: LinksetsResponderPtr mLinksetsResponsderPtr; }; +//--------------------------------------------------------------------------- +// CharactersResponder +//--------------------------------------------------------------------------- + +class CharactersResponder : public LLHTTPClient::Responder +{ +public: + CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::characters_callback_t pCharactersCallback); + virtual ~CharactersResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + +private: + std::string mCapabilityURL; + LLPathfindingManager::characters_callback_t mCharactersCallback; +}; + //--------------------------------------------------------------------------- // LLPathfindingManager //--------------------------------------------------------------------------- @@ -311,41 +334,6 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) } } -void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); - - if (!pNavMeshStatus.isValid()) - { - navMeshPtr->handleNavMeshError(); - } - else - { - if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) - { - navMeshPtr->handleRefresh(pNavMeshStatus); - } - else - { - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); - } - } -} - -void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); - - if (!pNavMeshStatus.isValid()) - { - navMeshPtr->handleNavMeshError(); - } - else - { - navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); - } -} - LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); @@ -395,15 +383,15 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } -LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLinksets(linksets_callback_t pLinksetsCallback) const +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(linksets_callback_t pLinksetsCallback) const { - ELinksetsRequestStatus status; + ERequestStatus status; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { - status = kLinksetsRequestNotEnabled; + status = kRequestNotEnabled; } else { @@ -419,21 +407,21 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestGetLin LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); } - status = kLinksetsRequestStarted; + status = kRequestStarted; } return status; } -LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const { - ELinksetsRequestStatus status = kLinksetsRequestNotEnabled; + ERequestStatus status = kRequestNotEnabled; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { - status = kLinksetsRequestNotEnabled; + status = kRequestNotEnabled; } else { @@ -446,7 +434,7 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin if (objectPostData.isUndefined() && terrainPostData.isUndefined()) { - status = kLinksetsRequestCompleted; + status = kRequestCompleted; } else { @@ -464,13 +452,33 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); } - status = kLinksetsRequestStarted; + status = kRequestStarted; } } return status; } +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(characters_callback_t pCharactersCallback) const +{ + ERequestStatus status; + + std::string charactersURL = getCharactersURLForCurrentRegion(); + if (charactersURL.empty()) + { + status = kRequestNotEnabled; + } + else + { + LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pCharactersCallback); + LLHTTPClient::get(charactersURL, charactersResponder); + + status = kRequestStarted; + } + + return status; +} + void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) { if ((pRegion == NULL) || !pRegion->isAlive()) @@ -496,6 +504,41 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt } } +void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) + { + navMeshPtr->handleRefresh(pNavMeshStatus); + } + else + { + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); + } + } +} + +void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); + } +} + LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) { LLPathfindingNavMeshPtr navMeshPtr; @@ -626,6 +669,11 @@ std::string LLPathfindingManager::getTerrainLinksetsURLForCurrentRegion() const return getCapabilityURLForCurrentRegion(CAP_SERVICE_TERRAIN_LINKSETS); } +std::string LLPathfindingManager::getCharactersURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_CHARACTERS); +} + std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const { return getCapabilityURLForRegion(getCurrentRegion(), pCapabilityName); @@ -688,7 +736,8 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c //--------------------------------------------------------------------------- NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) - : mCapabilityURL(pCapabilityURL), + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), mRegion(pRegion), mRegionUUID() { @@ -723,7 +772,8 @@ void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) //--------------------------------------------------------------------------- NavMeshResponder::NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr) - : mCapabilityURL(pCapabilityURL), + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), mNavMeshVersion(pNavMeshVersion), mNavMeshPtr(pNavMeshPtr) { @@ -830,10 +880,10 @@ void LinksetsResponder::sendCallback() { llassert(mObjectMessagingState != kWaiting); llassert(mTerrainMessagingState != kWaiting); - LLPathfindingManager::ELinksetsRequestStatus requestStatus = + LLPathfindingManager::ERequestStatus requestStatus = ((((mObjectMessagingState == kReceivedGood) || (mObjectMessagingState == kNotRequested)) && ((mTerrainMessagingState == kReceivedGood) || (mTerrainMessagingState == kNotRequested))) ? - LLPathfindingManager::kLinksetsRequestCompleted : LLPathfindingManager::kLinksetsRequestError); + LLPathfindingManager::kRequestCompleted : LLPathfindingManager::kRequestError); if (mObjectMessagingState != kReceivedGood) { @@ -853,7 +903,8 @@ void LinksetsResponder::sendCallback() //--------------------------------------------------------------------------- ObjectLinksetsResponder::ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) - : mCapabilityURL(pCapabilityURL), + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), mLinksetsResponsderPtr(pLinksetsResponsderPtr) { } @@ -877,8 +928,9 @@ void ObjectLinksetsResponder::error(U32 pStatus, const std::string &pReason) //--------------------------------------------------------------------------- TerrainLinksetsResponder::TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) -: mCapabilityURL(pCapabilityURL), -mLinksetsResponsderPtr(pLinksetsResponsderPtr) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mLinksetsResponsderPtr(pLinksetsResponsderPtr) { } @@ -895,3 +947,32 @@ void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) { mLinksetsResponsderPtr->handleTerrainLinksetsError(pStatus, pReason, mCapabilityURL); } + +//--------------------------------------------------------------------------- +// CharactersResponder +//--------------------------------------------------------------------------- + +CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::characters_callback_t pCharactersCallback) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mCharactersCallback(pCharactersCallback) +{ +} + +CharactersResponder::~CharactersResponder() +{ +} + +void CharactersResponder::result(const LLSD &pContent) +{ + LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); + mCharactersCallback(LLPathfindingManager::kRequestCompleted, characterListPtr); +} + +void CharactersResponder::error(U32 pStatus, const std::string &pReason) +{ + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + + LLPathfindingCharacterListPtr characterListPtr; + mCharactersCallback(LLPathfindingManager::kRequestError, characterListPtr); +} -- cgit v1.2.3 From 9d22b22d962321822a6be6a23150e6d5f939cd50 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 5 Apr 2012 15:59:34 -0700 Subject: PATH-482: BUGFIX Automatically reloading the character and linksets floaters on region crossing. --- indra/newview/llpathfindingmanager.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index fdff380050..cefff175a3 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -156,7 +156,7 @@ private: class LinksetsResponder { public: - LinksetsResponder(LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); + LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); virtual ~LinksetsResponder(); void handleObjectLinksetsResult(const LLSD &pContent); @@ -177,6 +177,7 @@ private: kReceivedError } EMessagingState; + LLPathfindingManager::request_id_t mRequestId; LLPathfindingManager::linksets_callback_t mLinksetsCallback; EMessagingState mObjectMessagingState; @@ -235,7 +236,7 @@ private: class CharactersResponder : public LLHTTPClient::Responder { public: - CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::characters_callback_t pCharactersCallback); + CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback); virtual ~CharactersResponder(); virtual void result(const LLSD &pContent); @@ -245,6 +246,7 @@ protected: private: std::string mCapabilityURL; + LLPathfindingManager::request_id_t mRequestId; LLPathfindingManager::characters_callback_t mCharactersCallback; }; @@ -383,7 +385,7 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(linksets_callback_t pLinksetsCallback) const +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const { ERequestStatus status; @@ -396,7 +398,7 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(li else { bool doRequestTerrain = isAllowViewTerrainProperties(); - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, true, doRequestTerrain)); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); @@ -413,7 +415,7 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(li return status; } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const { ERequestStatus status = kRequestNotEnabled; @@ -438,7 +440,7 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(LL } else { - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); if (!objectPostData.isUndefined()) { @@ -459,7 +461,7 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(LL return status; } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(characters_callback_t pCharactersCallback) const +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const { ERequestStatus status; @@ -470,7 +472,7 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters( } else { - LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pCharactersCallback); + LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); LLHTTPClient::get(charactersURL, charactersResponder); status = kRequestStarted; @@ -822,8 +824,9 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) // LinksetsResponder //--------------------------------------------------------------------------- -LinksetsResponder::LinksetsResponder(LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) - : mLinksetsCallback(pLinksetsCallback), +LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) + : mRequestId(pRequestId), + mLinksetsCallback(pLinksetsCallback), mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), mTerrainMessagingState(pIsTerrainRequested ? kWaiting : kNotRequested), mObjectLinksetListPtr(), @@ -895,7 +898,7 @@ void LinksetsResponder::sendCallback() mObjectLinksetListPtr->insert(std::pair(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); } - mLinksetsCallback(requestStatus, mObjectLinksetListPtr); + mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); } //--------------------------------------------------------------------------- @@ -952,9 +955,10 @@ void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) // CharactersResponder //--------------------------------------------------------------------------- -CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::characters_callback_t pCharactersCallback) +CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback) : LLHTTPClient::Responder(), mCapabilityURL(pCapabilityURL), + mRequestId(pRequestId), mCharactersCallback(pCharactersCallback) { } @@ -966,7 +970,7 @@ CharactersResponder::~CharactersResponder() void CharactersResponder::result(const LLSD &pContent) { LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); - mCharactersCallback(LLPathfindingManager::kRequestCompleted, characterListPtr); + mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); } void CharactersResponder::error(U32 pStatus, const std::string &pReason) @@ -974,5 +978,5 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; LLPathfindingCharacterListPtr characterListPtr; - mCharactersCallback(LLPathfindingManager::kRequestError, characterListPtr); + mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } -- cgit v1.2.3 From a72034fa42ebaf7e2f56c4a8cb0f445f12d22fe4 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 24 Apr 2012 19:23:20 -0700 Subject: PATH-580: BUGFIX Adding functionality to detect when the region's capabilities have not yet been loading and deferring requests for the navmesh query until the capabilities are fully loaded. --- indra/newview/llpathfindingmanager.cpp | 1984 ++++++++++++++++---------------- 1 file changed, 1002 insertions(+), 982 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index cefff175a3..e754e77588 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -1,982 +1,1002 @@ -/** - * @file llpathfindingmanager.cpp - * @author William Todd Stinson - * @brief A state manager for the various pathfinding states. - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include -#include - -#include "llviewerprecompiledheaders.h" -#include "llsd.h" -#include "lluuid.h" -#include "llpathfindingmanager.h" -#include "llsingleton.h" -#include "llhttpclient.h" -#include "llagent.h" -#include "llviewerregion.h" -#include "llpathfindingnavmesh.h" -#include "llpathfindingnavmeshstatus.h" -#include "llpathfindinglinkset.h" -#include "llpathfindinglinksetlist.h" -#include "llpathfindingcharacterlist.h" -#include "llhttpnode.h" - -#include -#include - -#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" - -#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" - -#define CAP_SERVICE_AGENT_STATE "AgentPreferences" -#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" -#define DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD "alter_permanent_objects" - -#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" -#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" - -#define CAP_SERVICE_CHARACTERS "CharacterProperties" - -#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" -#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" -#define SIM_MESSAGE_BODY_FIELD "body" - -//--------------------------------------------------------------------------- -// LLNavMeshSimStateChangeNode -//--------------------------------------------------------------------------- - -class LLNavMeshSimStateChangeNode : public LLHTTPNode -{ -public: - virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; -}; - -LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); - -//--------------------------------------------------------------------------- -// LLAgentStateChangeNode -//--------------------------------------------------------------------------- - -class LLAgentStateChangeNode : public LLHTTPNode -{ -public: - virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; -}; - -LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); - -//--------------------------------------------------------------------------- -// NavMeshStatusResponder -//--------------------------------------------------------------------------- - -class NavMeshStatusResponder : public LLHTTPClient::Responder -{ -public: - NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion); - virtual ~NavMeshStatusResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - std::string mCapabilityURL; - LLViewerRegion *mRegion; - LLUUID mRegionUUID; -}; - -//--------------------------------------------------------------------------- -// NavMeshResponder -//--------------------------------------------------------------------------- - -class NavMeshResponder : public LLHTTPClient::Responder -{ -public: - NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr); - virtual ~NavMeshResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - std::string mCapabilityURL; - U32 mNavMeshVersion; - LLPathfindingNavMeshPtr mNavMeshPtr; -}; - -//--------------------------------------------------------------------------- -// AgentStateResponder -//--------------------------------------------------------------------------- - -class AgentStateResponder : public LLHTTPClient::Responder -{ -public: - AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState = LLPathfindingManager::kAgentStateUnknown); - virtual ~AgentStateResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - std::string mCapabilityURL; - LLPathfindingManager::EAgentState mRequestedAgentState; -}; - -//--------------------------------------------------------------------------- -// LinksetsResponder -//--------------------------------------------------------------------------- - -class LinksetsResponder -{ -public: - LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); - virtual ~LinksetsResponder(); - - void handleObjectLinksetsResult(const LLSD &pContent); - void handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); - void handleTerrainLinksetsResult(const LLSD &pContent); - void handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); - -protected: - -private: - void sendCallback(); - - typedef enum - { - kNotRequested, - kWaiting, - kReceivedGood, - kReceivedError - } EMessagingState; - - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::linksets_callback_t mLinksetsCallback; - - EMessagingState mObjectMessagingState; - EMessagingState mTerrainMessagingState; - - LLPathfindingLinksetListPtr mObjectLinksetListPtr; - LLPathfindingLinksetPtr mTerrainLinksetPtr; -}; - -typedef boost::shared_ptr LinksetsResponderPtr; - -//--------------------------------------------------------------------------- -// ObjectLinksetsResponder -//--------------------------------------------------------------------------- - -class ObjectLinksetsResponder : public LLHTTPClient::Responder -{ -public: - ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); - virtual ~ObjectLinksetsResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string &pReason); - -protected: - -private: - std::string mCapabilityURL; - LinksetsResponderPtr mLinksetsResponsderPtr; -}; - -//--------------------------------------------------------------------------- -// TerrainLinksetsResponder -//--------------------------------------------------------------------------- - -class TerrainLinksetsResponder : public LLHTTPClient::Responder -{ -public: - TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); - virtual ~TerrainLinksetsResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string &pReason); - -protected: - -private: - std::string mCapabilityURL; - LinksetsResponderPtr mLinksetsResponsderPtr; -}; - -//--------------------------------------------------------------------------- -// CharactersResponder -//--------------------------------------------------------------------------- - -class CharactersResponder : public LLHTTPClient::Responder -{ -public: - CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback); - virtual ~CharactersResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string &pReason); - -protected: - -private: - std::string mCapabilityURL; - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::characters_callback_t mCharactersCallback; -}; - -//--------------------------------------------------------------------------- -// LLPathfindingManager -//--------------------------------------------------------------------------- - -LLPathfindingManager::LLPathfindingManager() - : LLSingleton(), - mNavMeshMap(), - mAgentStateSignal(), - mAgentState(kAgentStateUnknown), - mLastKnownNonErrorAgentState(kAgentStateUnknown) -{ -} - -LLPathfindingManager::~LLPathfindingManager() -{ -} - -bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const -{ - return isPathfindingEnabledForRegion(getCurrentRegion()); -} - -bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const -{ - std::string retrieveNavMeshURL = getRetrieveNavMeshURLForRegion(pRegion); - return !retrieveNavMeshURL.empty(); -} - -#ifdef DEPRECATED_UNVERSIONED_NAVMESH -bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const -{ - std::string navMeshStatusURL = getNavMeshStatusURLForRegion(getCurrentRegion()); - return !navMeshStatusURL.empty(); -} -#endif // DEPRECATED_UNVERSIONED_NAVMESH - -bool LLPathfindingManager::isAllowAlterPermanent() -{ - return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); -} - -bool LLPathfindingManager::isAllowViewTerrainProperties() const -{ - LLViewerRegion* region = getCurrentRegion(); - return (gAgent.isGodlike() || ((region != NULL) && region->canManageEstate())); -} - -LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - return navMeshPtr->registerNavMeshListener(pNavMeshCallback); -} - -void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - - if ((pRegion == NULL) || !isPathfindingEnabledForRegion(pRegion)) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); -#ifdef DEPRECATED_UNVERSIONED_NAVMESH - if (navMeshStatusURL.empty()) - { - LLPathfindingNavMeshStatus navMeshStatus = navMeshPtr->getNavMeshStatusXXX(); - navMeshStatus.incrementNavMeshVersionXXX(); - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshStatus); - } - else - { - navMeshPtr->handleNavMeshCheckVersion(); - LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); - LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); - } -#else // DEPRECATED_UNVERSIONED_NAVMESH - llassert(!navMeshStatusURL.empty()); - navMeshPtr->handleNavMeshCheckVersion(); - LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); - LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); -#endif // DEPRECATED_UNVERSIONED_NAVMESH - } -} - -LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) -{ - return mAgentStateSignal.connect(pAgentStateCallback); -} - -LLPathfindingManager::EAgentState LLPathfindingManager::getAgentState() -{ - if (!isPathfindingEnabledForCurrentRegion()) - { - setAgentState(kAgentStateNotEnabled); - } - else - { - if (!isValidAgentState(mAgentState)) - { - requestGetAgentState(); - } - } - - return mAgentState; -} - -LLPathfindingManager::EAgentState LLPathfindingManager::getLastKnownNonErrorAgentState() const -{ - return mLastKnownNonErrorAgentState; -} - -void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState) -{ - llassert(isValidAgentState(pRequestedAgentState)); - std::string agentStateURL = getAgentStateURLForCurrentRegion(); - - if (agentStateURL.empty()) - { - setAgentState(kAgentStateNotEnabled); - } - else - { - LLSD request; - request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); -#ifdef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - request[DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); -#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); - LLHTTPClient::post(agentStateURL, request, responder); - } -} - -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const -{ - ERequestStatus status; - - std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); - std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); - if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) - { - status = kRequestNotEnabled; - } - else - { - bool doRequestTerrain = isAllowViewTerrainProperties(); - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); - - LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); - LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); - - if (doRequestTerrain) - { - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); - LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); - } - - status = kRequestStarted; - } - - return status; -} - -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const -{ - ERequestStatus status = kRequestNotEnabled; - - std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); - std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); - if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) - { - status = kRequestNotEnabled; - } - else - { - LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); - LLSD terrainPostData; - if (isAllowViewTerrainProperties()) - { - terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); - } - - if (objectPostData.isUndefined() && terrainPostData.isUndefined()) - { - status = kRequestCompleted; - } - else - { - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); - - if (!objectPostData.isUndefined()) - { - LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); - LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder); - } - - if (!terrainPostData.isUndefined()) - { - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); - LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); - } - - status = kRequestStarted; - } - } - - return status; -} - -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const -{ - ERequestStatus status; - - std::string charactersURL = getCharactersURLForCurrentRegion(); - if (charactersURL.empty()) - { - status = kRequestNotEnabled; - } - else - { - LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); - LLHTTPClient::get(charactersURL, charactersResponder); - - status = kRequestStarted; - } - - return status; -} - -void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - if ((pRegion == NULL) || !pRegion->isAlive()) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); - - if (navMeshURL.empty()) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - navMeshPtr->handleNavMeshStart(pNavMeshStatus); - LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshStatus.getVersion(), navMeshPtr); - - LLSD postData; - LLHTTPClient::post(navMeshURL, postData, responder); - } - } -} - -void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); - - if (!pNavMeshStatus.isValid()) - { - navMeshPtr->handleNavMeshError(); - } - else - { - if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) - { - navMeshPtr->handleRefresh(pNavMeshStatus); - } - else - { - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); - } - } -} - -void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); - - if (!pNavMeshStatus.isValid()) - { - navMeshPtr->handleNavMeshError(); - } - else - { - navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); - } -} - -LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) -{ - LLPathfindingNavMeshPtr navMeshPtr; - NavMeshMap::iterator navMeshIter = mNavMeshMap.find(pRegionUUID); - if (navMeshIter == mNavMeshMap.end()) - { - navMeshPtr = LLPathfindingNavMeshPtr(new LLPathfindingNavMesh(pRegionUUID)); - mNavMeshMap.insert(std::pair(pRegionUUID, navMeshPtr)); - } - else - { - navMeshPtr = navMeshIter->second; - } - - return navMeshPtr; -} - -LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion *pRegion) -{ - LLUUID regionUUID; - if (pRegion != NULL) - { - regionUUID = pRegion->getRegionID(); - } - - return getNavMeshForRegion(regionUUID); -} - -bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) -{ - return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); -} - -void LLPathfindingManager::requestGetAgentState() -{ - std::string agentStateURL = getAgentStateURLForCurrentRegion(); - - if (agentStateURL.empty()) - { - setAgentState(kAgentStateNotEnabled); - } - else - { - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL); - LLHTTPClient::get(agentStateURL, responder); - } -} - -void LLPathfindingManager::setAgentState(EAgentState pAgentState) -{ - mAgentState = pAgentState; - - if (mAgentState != kAgentStateError) - { - mLastKnownNonErrorAgentState = mAgentState; - } - - mAgentStateSignal(mAgentState); -} - -void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) -{ -#ifndef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); -#else // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - EAgentState agentState = kAgentStateUnknown; - if (pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)) - { - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - } - else - { - llassert(pContent.has(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - agentState = (pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - } -#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - - if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) - { - agentState = kAgentStateError; - llassert(0); - } - - setAgentState(agentState); -} - -void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - setAgentState(kAgentStateError); -} - -void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) -{ - llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - - setAgentState(agentState); -} - -std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const -{ - return getCapabilityURLForRegion(pRegion, CAP_SERVICE_NAVMESH_STATUS); -} - -std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion *pRegion) const -{ - return getCapabilityURLForRegion(pRegion, CAP_SERVICE_RETRIEVE_NAVMESH); -} - -std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const -{ - return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); -} - -std::string LLPathfindingManager::getObjectLinksetsURLForCurrentRegion() const -{ - return getCapabilityURLForCurrentRegion(CAP_SERVICE_OBJECT_LINKSETS); -} - -std::string LLPathfindingManager::getTerrainLinksetsURLForCurrentRegion() const -{ - return getCapabilityURLForCurrentRegion(CAP_SERVICE_TERRAIN_LINKSETS); -} - -std::string LLPathfindingManager::getCharactersURLForCurrentRegion() const -{ - return getCapabilityURLForCurrentRegion(CAP_SERVICE_CHARACTERS); -} - -std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const -{ - return getCapabilityURLForRegion(getCurrentRegion(), pCapabilityName); -} - -std::string LLPathfindingManager::getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const -{ - std::string capabilityURL(""); - - if (pRegion != NULL) - { - capabilityURL = pRegion->getCapability(pCapabilityName); - } - - if (capabilityURL.empty()) - { - llwarns << "cannot find capability '" << pCapabilityName << "' for current region '" - << ((pRegion != NULL) ? pRegion->getName() : "") << "'" << llendl; - } - - return capabilityURL; -} - -LLViewerRegion *LLPathfindingManager::getCurrentRegion() const -{ - return gAgent.getRegion(); -} - -//--------------------------------------------------------------------------- -// LLNavMeshSimStateChangeNode -//--------------------------------------------------------------------------- - -void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const -{ -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received NavMeshStatusUpdate: " << pInput << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE - llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); - llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); - LLPathfindingNavMeshStatus navMeshStatus(pInput.get(SIM_MESSAGE_BODY_FIELD)); - LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); -} - -//--------------------------------------------------------------------------- -// LLAgentStateChangeNode -//--------------------------------------------------------------------------- - -void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const -{ -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received AgentPreferencesUpdate: " << pInput << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE - llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); - llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); - LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); -} - -//--------------------------------------------------------------------------- -// NavMeshStatusResponder -//--------------------------------------------------------------------------- - -NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mRegion(pRegion), - mRegionUUID() -{ - if (mRegion != NULL) - { - mRegionUUID = mRegion->getRegionID(); - } -} - -NavMeshStatusResponder::~NavMeshStatusResponder() -{ -} - -void NavMeshStatusResponder::result(const LLSD &pContent) -{ -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE - LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); -} - -void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) -{ - llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); -} - -//--------------------------------------------------------------------------- -// NavMeshResponder -//--------------------------------------------------------------------------- - -NavMeshResponder::NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mNavMeshVersion(pNavMeshVersion), - mNavMeshPtr(pNavMeshPtr) -{ -} - -NavMeshResponder::~NavMeshResponder() -{ -} - -void NavMeshResponder::result(const LLSD &pContent) -{ - mNavMeshPtr->handleNavMeshResult(pContent, mNavMeshVersion); -} - -void NavMeshResponder::error(U32 pStatus, const std::string& pReason) -{ - mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion); -} - -//--------------------------------------------------------------------------- -// AgentStateResponder -//--------------------------------------------------------------------------- - -AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mRequestedAgentState(pRequestedAgentState) -{ -} - -AgentStateResponder::~AgentStateResponder() -{ -} - -void AgentStateResponder::result(const LLSD &pContent) -{ - LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mRequestedAgentState); -} - -void AgentStateResponder::error(U32 pStatus, const std::string &pReason) -{ - LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); -} - -//--------------------------------------------------------------------------- -// LinksetsResponder -//--------------------------------------------------------------------------- - -LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) - : mRequestId(pRequestId), - mLinksetsCallback(pLinksetsCallback), - mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), - mTerrainMessagingState(pIsTerrainRequested ? kWaiting : kNotRequested), - mObjectLinksetListPtr(), - mTerrainLinksetPtr() -{ -} - -LinksetsResponder::~LinksetsResponder() -{ -} - -void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent) -{ - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent)); - - mObjectMessagingState = kReceivedGood; - if (mTerrainMessagingState != kWaiting) - { - sendCallback(); - } -} - -void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - mObjectMessagingState = kReceivedError; - if (mTerrainMessagingState != kWaiting) - { - sendCallback(); - } -} - -void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent) -{ - mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent)); - - mTerrainMessagingState = kReceivedGood; - if (mObjectMessagingState != kWaiting) - { - sendCallback(); - } -} - -void LinksetsResponder::handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) -{ - mTerrainMessagingState = kReceivedError; - if (mObjectMessagingState != kWaiting) - { - sendCallback(); - } -} - -void LinksetsResponder::sendCallback() -{ - llassert(mObjectMessagingState != kWaiting); - llassert(mTerrainMessagingState != kWaiting); - LLPathfindingManager::ERequestStatus requestStatus = - ((((mObjectMessagingState == kReceivedGood) || (mObjectMessagingState == kNotRequested)) && - ((mTerrainMessagingState == kReceivedGood) || (mTerrainMessagingState == kNotRequested))) ? - LLPathfindingManager::kRequestCompleted : LLPathfindingManager::kRequestError); - - if (mObjectMessagingState != kReceivedGood) - { - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList()); - } - - if (mTerrainMessagingState == kReceivedGood) - { - mObjectLinksetListPtr->insert(std::pair(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); - } - - mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); -} - -//--------------------------------------------------------------------------- -// ObjectLinksetsResponder -//--------------------------------------------------------------------------- - -ObjectLinksetsResponder::ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mLinksetsResponsderPtr(pLinksetsResponsderPtr) -{ -} - -ObjectLinksetsResponder::~ObjectLinksetsResponder() -{ -} - -void ObjectLinksetsResponder::result(const LLSD &pContent) -{ - mLinksetsResponsderPtr->handleObjectLinksetsResult(pContent); -} - -void ObjectLinksetsResponder::error(U32 pStatus, const std::string &pReason) -{ - mLinksetsResponsderPtr->handleObjectLinksetsError(pStatus, pReason, mCapabilityURL); -} - -//--------------------------------------------------------------------------- -// TerrainLinksetsResponder -//--------------------------------------------------------------------------- - -TerrainLinksetsResponder::TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mLinksetsResponsderPtr(pLinksetsResponsderPtr) -{ -} - -TerrainLinksetsResponder::~TerrainLinksetsResponder() -{ -} - -void TerrainLinksetsResponder::result(const LLSD &pContent) -{ - mLinksetsResponsderPtr->handleTerrainLinksetsResult(pContent); -} - -void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) -{ - mLinksetsResponsderPtr->handleTerrainLinksetsError(pStatus, pReason, mCapabilityURL); -} - -//--------------------------------------------------------------------------- -// CharactersResponder -//--------------------------------------------------------------------------- - -CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mRequestId(pRequestId), - mCharactersCallback(pCharactersCallback) -{ -} - -CharactersResponder::~CharactersResponder() -{ -} - -void CharactersResponder::result(const LLSD &pContent) -{ - LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); - mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); -} - -void CharactersResponder::error(U32 pStatus, const std::string &pReason) -{ - llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - - LLPathfindingCharacterListPtr characterListPtr; - mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); -} +/** + * @file llpathfindingmanager.cpp + * @author William Todd Stinson + * @brief A state manager for the various pathfinding states. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include +#include + +#include "llviewerprecompiledheaders.h" +#include "llsd.h" +#include "lluuid.h" +#include "llpathfindingmanager.h" +#include "llsingleton.h" +#include "llhttpclient.h" +#include "llagent.h" +#include "llviewerregion.h" +#include "llpathfindingnavmesh.h" +#include "llpathfindingnavmeshstatus.h" +#include "llpathfindinglinkset.h" +#include "llpathfindinglinksetlist.h" +#include "llpathfindingcharacterlist.h" +#include "llhttpnode.h" + +#include +#include + +#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" + +#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" + +#define CAP_SERVICE_AGENT_STATE "AgentPreferences" +#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD "alter_permanent_objects" + +#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" + +#define CAP_SERVICE_CHARACTERS "CharacterProperties" + +#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" +#define SIM_MESSAGE_BODY_FIELD "body" + +//--------------------------------------------------------------------------- +// LLNavMeshSimStateChangeNode +//--------------------------------------------------------------------------- + +class LLNavMeshSimStateChangeNode : public LLHTTPNode +{ +public: + virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; +}; + +LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); + +//--------------------------------------------------------------------------- +// LLAgentStateChangeNode +//--------------------------------------------------------------------------- + +class LLAgentStateChangeNode : public LLHTTPNode +{ +public: + virtual void post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const; +}; + +LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); + +//--------------------------------------------------------------------------- +// NavMeshStatusResponder +//--------------------------------------------------------------------------- + +class NavMeshStatusResponder : public LLHTTPClient::Responder +{ +public: + NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion); + virtual ~NavMeshStatusResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; + LLViewerRegion *mRegion; + LLUUID mRegionUUID; +}; + +//--------------------------------------------------------------------------- +// NavMeshResponder +//--------------------------------------------------------------------------- + +class NavMeshResponder : public LLHTTPClient::Responder +{ +public: + NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr); + virtual ~NavMeshResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; + U32 mNavMeshVersion; + LLPathfindingNavMeshPtr mNavMeshPtr; +}; + +//--------------------------------------------------------------------------- +// AgentStateResponder +//--------------------------------------------------------------------------- + +class AgentStateResponder : public LLHTTPClient::Responder +{ +public: + AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState = LLPathfindingManager::kAgentStateUnknown); + virtual ~AgentStateResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; + LLPathfindingManager::EAgentState mRequestedAgentState; +}; + +//--------------------------------------------------------------------------- +// LinksetsResponder +//--------------------------------------------------------------------------- + +class LinksetsResponder +{ +public: + LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); + virtual ~LinksetsResponder(); + + void handleObjectLinksetsResult(const LLSD &pContent); + void handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); + void handleTerrainLinksetsResult(const LLSD &pContent); + void handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL); + +protected: + +private: + void sendCallback(); + + typedef enum + { + kNotRequested, + kWaiting, + kReceivedGood, + kReceivedError + } EMessagingState; + + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::linksets_callback_t mLinksetsCallback; + + EMessagingState mObjectMessagingState; + EMessagingState mTerrainMessagingState; + + LLPathfindingLinksetListPtr mObjectLinksetListPtr; + LLPathfindingLinksetPtr mTerrainLinksetPtr; +}; + +typedef boost::shared_ptr LinksetsResponderPtr; + +//--------------------------------------------------------------------------- +// ObjectLinksetsResponder +//--------------------------------------------------------------------------- + +class ObjectLinksetsResponder : public LLHTTPClient::Responder +{ +public: + ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); + virtual ~ObjectLinksetsResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + +private: + std::string mCapabilityURL; + LinksetsResponderPtr mLinksetsResponsderPtr; +}; + +//--------------------------------------------------------------------------- +// TerrainLinksetsResponder +//--------------------------------------------------------------------------- + +class TerrainLinksetsResponder : public LLHTTPClient::Responder +{ +public: + TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr); + virtual ~TerrainLinksetsResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + +private: + std::string mCapabilityURL; + LinksetsResponderPtr mLinksetsResponsderPtr; +}; + +//--------------------------------------------------------------------------- +// CharactersResponder +//--------------------------------------------------------------------------- + +class CharactersResponder : public LLHTTPClient::Responder +{ +public: + CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback); + virtual ~CharactersResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string &pReason); + +protected: + +private: + std::string mCapabilityURL; + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::characters_callback_t mCharactersCallback; +}; + +//--------------------------------------------------------------------------- +// LLPathfindingManager +//--------------------------------------------------------------------------- + +LLPathfindingManager::LLPathfindingManager() + : LLSingleton(), + mNavMeshMap(), + mAgentStateSignal(), + mAgentState(kAgentStateUnknown), + mLastKnownNonErrorAgentState(kAgentStateUnknown) +{ +} + +LLPathfindingManager::~LLPathfindingManager() +{ +} + +bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const +{ + return isPathfindingEnabledForRegion(getCurrentRegion()); +} + +bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const +{ + std::string retrieveNavMeshURL = getRetrieveNavMeshURLForRegion(pRegion); + return !retrieveNavMeshURL.empty(); +} + +#ifdef DEPRECATED_UNVERSIONED_NAVMESH +bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const +{ + std::string navMeshStatusURL = getNavMeshStatusURLForRegion(getCurrentRegion()); + return !navMeshStatusURL.empty(); +} +#endif // DEPRECATED_UNVERSIONED_NAVMESH + +bool LLPathfindingManager::isAllowAlterPermanent() +{ + return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); +} + +bool LLPathfindingManager::isAllowViewTerrainProperties() const +{ + LLViewerRegion* region = getCurrentRegion(); + return (gAgent.isGodlike() || ((region != NULL) && region->canManageEstate())); +} + +LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); + return navMeshPtr->registerNavMeshListener(pNavMeshCallback); +} + +void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); + + if (pRegion == NULL) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else if (!pRegion->capabilitiesReceived()) + { + navMeshPtr->handleNavMeshWaitForRegionLoad(); + pRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetNavMeshForRegion, this, _1)); + } + else if (!isPathfindingEnabledForRegion(pRegion)) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); +#ifdef DEPRECATED_UNVERSIONED_NAVMESH + if (navMeshStatusURL.empty()) + { + LLPathfindingNavMeshStatus navMeshStatus = navMeshPtr->getNavMeshStatusXXX(); + navMeshStatus.incrementNavMeshVersionXXX(); + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshStatus); + } + else + { + navMeshPtr->handleNavMeshCheckVersion(); + LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); + LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); + } +#else // DEPRECATED_UNVERSIONED_NAVMESH + llassert(!navMeshStatusURL.empty()); + navMeshPtr->handleNavMeshCheckVersion(); + LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); + LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); +#endif // DEPRECATED_UNVERSIONED_NAVMESH + } +} + +LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) +{ + return mAgentStateSignal.connect(pAgentStateCallback); +} + +LLPathfindingManager::EAgentState LLPathfindingManager::getAgentState() +{ + if (!isPathfindingEnabledForCurrentRegion()) + { + setAgentState(kAgentStateNotEnabled); + } + else + { + if (!isValidAgentState(mAgentState)) + { + requestGetAgentState(); + } + } + + return mAgentState; +} + +LLPathfindingManager::EAgentState LLPathfindingManager::getLastKnownNonErrorAgentState() const +{ + return mLastKnownNonErrorAgentState; +} + +void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState) +{ + llassert(isValidAgentState(pRequestedAgentState)); + std::string agentStateURL = getAgentStateURLForCurrentRegion(); + + if (agentStateURL.empty()) + { + setAgentState(kAgentStateNotEnabled); + } + else + { + LLSD request; + request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); +#ifdef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + request[DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); +#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); + LLHTTPClient::post(agentStateURL, request, responder); + } +} + +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +{ + ERequestStatus status; + + std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); + std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); + if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) + { + status = kRequestNotEnabled; + } + else + { + bool doRequestTerrain = isAllowViewTerrainProperties(); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); + + LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); + LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); + + if (doRequestTerrain) + { + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + } + + status = kRequestStarted; + } + + return status; +} + +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +{ + ERequestStatus status = kRequestNotEnabled; + + std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); + std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); + if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) + { + status = kRequestNotEnabled; + } + else + { + LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); + LLSD terrainPostData; + if (isAllowViewTerrainProperties()) + { + terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + } + + if (objectPostData.isUndefined() && terrainPostData.isUndefined()) + { + status = kRequestCompleted; + } + else + { + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); + + if (!objectPostData.isUndefined()) + { + LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); + LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder); + } + + if (!terrainPostData.isUndefined()) + { + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); + } + + status = kRequestStarted; + } + } + + return status; +} + +LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const +{ + ERequestStatus status; + + std::string charactersURL = getCharactersURLForCurrentRegion(); + if (charactersURL.empty()) + { + status = kRequestNotEnabled; + } + else + { + LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); + LLHTTPClient::get(charactersURL, charactersResponder); + + status = kRequestStarted; + } + + return status; +} + +void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + if ((pRegion == NULL) || !pRegion->isAlive()) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); + + if (navMeshURL.empty()) + { + navMeshPtr->handleNavMeshNotEnabled(); + } + else + { + navMeshPtr->handleNavMeshStart(pNavMeshStatus); + LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshStatus.getVersion(), navMeshPtr); + + LLSD postData; + LLHTTPClient::post(navMeshURL, postData, responder); + } + } +} + +void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID) +{ + LLViewerRegion *currentRegion = getCurrentRegion(); + + if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) + { + requestGetNavMeshForRegion(currentRegion); + } +} + +void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) + { + navMeshPtr->handleRefresh(pNavMeshStatus); + } + else + { + sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); + } + } +} + +void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + + if (!pNavMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + } + else + { + navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); + } +} + +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) +{ + LLPathfindingNavMeshPtr navMeshPtr; + NavMeshMap::iterator navMeshIter = mNavMeshMap.find(pRegionUUID); + if (navMeshIter == mNavMeshMap.end()) + { + navMeshPtr = LLPathfindingNavMeshPtr(new LLPathfindingNavMesh(pRegionUUID)); + mNavMeshMap.insert(std::pair(pRegionUUID, navMeshPtr)); + } + else + { + navMeshPtr = navMeshIter->second; + } + + return navMeshPtr; +} + +LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion *pRegion) +{ + LLUUID regionUUID; + if (pRegion != NULL) + { + regionUUID = pRegion->getRegionID(); + } + + return getNavMeshForRegion(regionUUID); +} + +bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) +{ + return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); +} + +void LLPathfindingManager::requestGetAgentState() +{ + std::string agentStateURL = getAgentStateURLForCurrentRegion(); + + if (agentStateURL.empty()) + { + setAgentState(kAgentStateNotEnabled); + } + else + { + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL); + LLHTTPClient::get(agentStateURL, responder); + } +} + +void LLPathfindingManager::setAgentState(EAgentState pAgentState) +{ + mAgentState = pAgentState; + + if (mAgentState != kAgentStateError) + { + mLastKnownNonErrorAgentState = mAgentState; + } + + mAgentStateSignal(mAgentState); +} + +void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) +{ +#ifndef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); +#else // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + EAgentState agentState = kAgentStateUnknown; + if (pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)) + { + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + } + else + { + llassert(pContent.has(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + agentState = (pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + } +#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD + + if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) + { + agentState = kAgentStateError; + llassert(0); + } + + setAgentState(agentState); +} + +void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + setAgentState(kAgentStateError); +} + +void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) +{ + llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); + llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); + EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); + + setAgentState(agentState); +} + +std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const +{ + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_NAVMESH_STATUS); +} + +std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion *pRegion) const +{ + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_RETRIEVE_NAVMESH); +} + +std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); +} + +std::string LLPathfindingManager::getObjectLinksetsURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_OBJECT_LINKSETS); +} + +std::string LLPathfindingManager::getTerrainLinksetsURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_TERRAIN_LINKSETS); +} + +std::string LLPathfindingManager::getCharactersURLForCurrentRegion() const +{ + return getCapabilityURLForCurrentRegion(CAP_SERVICE_CHARACTERS); +} + +std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const +{ + return getCapabilityURLForRegion(getCurrentRegion(), pCapabilityName); +} + +std::string LLPathfindingManager::getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const +{ + std::string capabilityURL(""); + + if (pRegion != NULL) + { + capabilityURL = pRegion->getCapability(pCapabilityName); + } + + if (capabilityURL.empty()) + { + llwarns << "cannot find capability '" << pCapabilityName << "' for current region '" + << ((pRegion != NULL) ? pRegion->getName() : "") << "'" << llendl; + } + + return capabilityURL; +} + +LLViewerRegion *LLPathfindingManager::getCurrentRegion() const +{ + return gAgent.getRegion(); +} + +//--------------------------------------------------------------------------- +// LLNavMeshSimStateChangeNode +//--------------------------------------------------------------------------- + +void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +{ +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "STINSON DEBUG: Received NavMeshStatusUpdate: " << pInput << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE + llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); + LLPathfindingNavMeshStatus navMeshStatus(pInput.get(SIM_MESSAGE_BODY_FIELD)); + LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); +} + +//--------------------------------------------------------------------------- +// LLAgentStateChangeNode +//--------------------------------------------------------------------------- + +void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +{ +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "STINSON DEBUG: Received AgentPreferencesUpdate: " << pInput << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE + llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); + LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); +} + +//--------------------------------------------------------------------------- +// NavMeshStatusResponder +//--------------------------------------------------------------------------- + +NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mRegion(pRegion), + mRegionUUID() +{ + if (mRegion != NULL) + { + mRegionUUID = mRegion->getRegionID(); + } +} + +NavMeshStatusResponder::~NavMeshStatusResponder() +{ +} + +void NavMeshStatusResponder::result(const LLSD &pContent) +{ +#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE + llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; +#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE + LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); +} + +void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) +{ + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); +} + +//--------------------------------------------------------------------------- +// NavMeshResponder +//--------------------------------------------------------------------------- + +NavMeshResponder::NavMeshResponder(const std::string &pCapabilityURL, U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mNavMeshVersion(pNavMeshVersion), + mNavMeshPtr(pNavMeshPtr) +{ +} + +NavMeshResponder::~NavMeshResponder() +{ +} + +void NavMeshResponder::result(const LLSD &pContent) +{ + mNavMeshPtr->handleNavMeshResult(pContent, mNavMeshVersion); +} + +void NavMeshResponder::error(U32 pStatus, const std::string& pReason) +{ + mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion); +} + +//--------------------------------------------------------------------------- +// AgentStateResponder +//--------------------------------------------------------------------------- + +AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mRequestedAgentState(pRequestedAgentState) +{ +} + +AgentStateResponder::~AgentStateResponder() +{ +} + +void AgentStateResponder::result(const LLSD &pContent) +{ + LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mRequestedAgentState); +} + +void AgentStateResponder::error(U32 pStatus, const std::string &pReason) +{ + LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); +} + +//--------------------------------------------------------------------------- +// LinksetsResponder +//--------------------------------------------------------------------------- + +LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) + : mRequestId(pRequestId), + mLinksetsCallback(pLinksetsCallback), + mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), + mTerrainMessagingState(pIsTerrainRequested ? kWaiting : kNotRequested), + mObjectLinksetListPtr(), + mTerrainLinksetPtr() +{ +} + +LinksetsResponder::~LinksetsResponder() +{ +} + +void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent) +{ + mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent)); + + mObjectMessagingState = kReceivedGood; + if (mTerrainMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + mObjectMessagingState = kReceivedError; + if (mTerrainMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent) +{ + mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent)); + + mTerrainMessagingState = kReceivedGood; + if (mObjectMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::handleTerrainLinksetsError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + mTerrainMessagingState = kReceivedError; + if (mObjectMessagingState != kWaiting) + { + sendCallback(); + } +} + +void LinksetsResponder::sendCallback() +{ + llassert(mObjectMessagingState != kWaiting); + llassert(mTerrainMessagingState != kWaiting); + LLPathfindingManager::ERequestStatus requestStatus = + ((((mObjectMessagingState == kReceivedGood) || (mObjectMessagingState == kNotRequested)) && + ((mTerrainMessagingState == kReceivedGood) || (mTerrainMessagingState == kNotRequested))) ? + LLPathfindingManager::kRequestCompleted : LLPathfindingManager::kRequestError); + + if (mObjectMessagingState != kReceivedGood) + { + mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList()); + } + + if (mTerrainMessagingState == kReceivedGood) + { + mObjectLinksetListPtr->insert(std::pair(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); + } + + mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); +} + +//--------------------------------------------------------------------------- +// ObjectLinksetsResponder +//--------------------------------------------------------------------------- + +ObjectLinksetsResponder::ObjectLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mLinksetsResponsderPtr(pLinksetsResponsderPtr) +{ +} + +ObjectLinksetsResponder::~ObjectLinksetsResponder() +{ +} + +void ObjectLinksetsResponder::result(const LLSD &pContent) +{ + mLinksetsResponsderPtr->handleObjectLinksetsResult(pContent); +} + +void ObjectLinksetsResponder::error(U32 pStatus, const std::string &pReason) +{ + mLinksetsResponsderPtr->handleObjectLinksetsError(pStatus, pReason, mCapabilityURL); +} + +//--------------------------------------------------------------------------- +// TerrainLinksetsResponder +//--------------------------------------------------------------------------- + +TerrainLinksetsResponder::TerrainLinksetsResponder(const std::string &pCapabilityURL, LinksetsResponderPtr pLinksetsResponsderPtr) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mLinksetsResponsderPtr(pLinksetsResponsderPtr) +{ +} + +TerrainLinksetsResponder::~TerrainLinksetsResponder() +{ +} + +void TerrainLinksetsResponder::result(const LLSD &pContent) +{ + mLinksetsResponsderPtr->handleTerrainLinksetsResult(pContent); +} + +void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) +{ + mLinksetsResponsderPtr->handleTerrainLinksetsError(pStatus, pReason, mCapabilityURL); +} + +//--------------------------------------------------------------------------- +// CharactersResponder +//--------------------------------------------------------------------------- + +CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL), + mRequestId(pRequestId), + mCharactersCallback(pCharactersCallback) +{ +} + +CharactersResponder::~CharactersResponder() +{ +} + +void CharactersResponder::result(const LLSD &pContent) +{ + LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); + mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); +} + +void CharactersResponder::error(U32 pStatus, const std::string &pReason) +{ + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + + LLPathfindingCharacterListPtr characterListPtr; + mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); +} + -- cgit v1.2.3 From 932921766740655de84108970095ca17d24c5829 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 27 Apr 2012 17:08:33 -0700 Subject: PATH-585: Adding an initial notification for when a server-side automatic unfreeze occurs. --- indra/newview/llpathfindingmanager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e754e77588..59cfc398f2 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -42,6 +42,9 @@ #include "llpathfindinglinksetlist.h" #include "llpathfindingcharacterlist.h" #include "llhttpnode.h" +#include "llnotificationsutil.h" +#include "lltrans.h" +#include "llweb.h" #include #include @@ -663,6 +666,17 @@ void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); setAgentState(agentState); + + LLSD substitutions, payload; + LLNotificationsUtil::add("AutomaticAgentStateUnfreeze", substitutions, payload, boost::bind(&LLPathfindingManager::handleAgentStateUserNotification, this, _1, _2)); +} + +void LLPathfindingManager::handleAgentStateUserNotification(const LLSD &pNotification, const LLSD &pResponse) +{ + if (LLNotificationsUtil::getSelectedOption(pNotification, pResponse) == 1) + { + LLWeb::loadURL(LLTrans::getString("Pathfinding_Wiki_URL")); + } } std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const -- cgit v1.2.3 From 852377c676bc3a8183073e41357499f06f40fb1b Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 1 May 2012 14:22:58 -0700 Subject: Switching the functionality of the linksets and character request handling to no longer return values directly, but rather to report status only through the callbacks. --- indra/newview/llpathfindingmanager.cpp | 38 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 59cfc398f2..8ce2e71c63 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -397,18 +397,20 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const { - ERequestStatus status; + LLPathfindingLinksetListPtr emptyLinksetListPtr; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { - status = kRequestNotEnabled; + pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); } else { + pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); + bool doRequestTerrain = isAllowViewTerrainProperties(); LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); @@ -420,22 +422,18 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetLinksets(re LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); } - - status = kRequestStarted; } - - return status; } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const { - ERequestStatus status = kRequestNotEnabled; + LLPathfindingLinksetListPtr emptyLinksetListPtr; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) { - status = kRequestNotEnabled; + pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); } else { @@ -448,10 +446,12 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(re if (objectPostData.isUndefined() && terrainPostData.isUndefined()) { - status = kRequestCompleted; + pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr); } else { + pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); if (!objectPostData.isUndefined()) @@ -465,32 +465,26 @@ LLPathfindingManager::ERequestStatus LLPathfindingManager::requestSetLinksets(re LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); } - - status = kRequestStarted; } } - - return status; } -LLPathfindingManager::ERequestStatus LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const +void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const { - ERequestStatus status; + LLPathfindingCharacterListPtr emptyCharacterListPtr; std::string charactersURL = getCharactersURLForCurrentRegion(); if (charactersURL.empty()) { - status = kRequestNotEnabled; + pCharactersCallback(pRequestId, kRequestNotEnabled, emptyCharacterListPtr); } else { + pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); + LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); LLHTTPClient::get(charactersURL, charactersResponder); - - status = kRequestStarted; } - - return status; } void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) -- cgit v1.2.3 From 84d8b320a2dff7a7d34e04d1f5c7fd38d148e5c7 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 1 May 2012 14:55:53 -0700 Subject: PATH-580: Ensuring that the characters and linksets capability services are properly deferred requested in the case that a regions capabilities have not been fully received at initial request time. --- indra/newview/llpathfindingmanager.cpp | 81 +++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 17 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 8ce2e71c63..e01466569e 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -400,27 +400,40 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const { LLPathfindingLinksetListPtr emptyLinksetListPtr; + LLViewerRegion *currentRegion = getCurrentRegion(); - std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); - std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); - if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) + if (currentRegion == NULL) { pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); } - else + else if (!currentRegion->capabilitiesReceived()) { pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); + currentRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetLinksetsForRegion, this, _1, pRequestId, pLinksetsCallback)); + } + else + { + std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); + std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); + if (objectLinksetsURL.empty() || terrainLinksetsURL.empty()) + { + pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); + } + else + { + pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); - bool doRequestTerrain = isAllowViewTerrainProperties(); - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); + bool doRequestTerrain = isAllowViewTerrainProperties(); + LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); - LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); - LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); + LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr); + LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); - if (doRequestTerrain) - { - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); - LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + if (doRequestTerrain) + { + LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr); + LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + } } } } @@ -473,17 +486,31 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, charact { LLPathfindingCharacterListPtr emptyCharacterListPtr; - std::string charactersURL = getCharactersURLForCurrentRegion(); - if (charactersURL.empty()) + LLViewerRegion *currentRegion = getCurrentRegion(); + + if (currentRegion == NULL) { pCharactersCallback(pRequestId, kRequestNotEnabled, emptyCharacterListPtr); } - else + else if (!currentRegion->capabilitiesReceived()) { pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); + currentRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetCharactersForRegion, this, _1, pRequestId, pCharactersCallback)); + } + else + { + std::string charactersURL = getCharactersURLForCurrentRegion(); + if (charactersURL.empty()) + { + pCharactersCallback(pRequestId, kRequestNotEnabled, emptyCharacterListPtr); + } + else + { + pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); - LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); - LLHTTPClient::get(charactersURL, charactersResponder); + LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); + LLHTTPClient::get(charactersURL, charactersResponder); + } } } @@ -522,6 +549,26 @@ void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegi } } +void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +{ + LLViewerRegion *currentRegion = getCurrentRegion(); + + if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) + { + requestGetLinksets(pRequestId, pLinksetsCallback); + } +} + +void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const +{ + LLViewerRegion *currentRegion = getCurrentRegion(); + + if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) + { + requestGetCharacters(pRequestId, pCharactersCallback); + } +} + void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); -- cgit v1.2.3 From 3c2be426e5e905076d00b9492c0e66c8b31caf19 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 18:47:12 -0700 Subject: First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated. --- indra/newview/llpathfindingmanager.cpp | 100 ++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 45 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e01466569e..b8b9dff51c 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -25,30 +25,35 @@ * $/LicenseInfo$ */ +#include "llviewerprecompiledheaders.h" + +#include "llpathfindingmanager.h" + #include #include -#include "llviewerprecompiledheaders.h" -#include "llsd.h" -#include "lluuid.h" -#include "llpathfindingmanager.h" -#include "llsingleton.h" -#include "llhttpclient.h" +#include +#include + #include "llagent.h" -#include "llviewerregion.h" +#include "llhttpclient.h" +#include "llhttpnode.h" +#include "llnotificationsutil.h" +#include "llpathfindingcharacter.h" +#include "llpathfindingcharacterlist.h" +#include "llpathfindinglinkset.h" +#include "llpathfindinglinksetlist.h" #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" -#include "llpathfindinglinkset.h" +#include "llpathfindingobject.h" #include "llpathfindinglinksetlist.h" -#include "llpathfindingcharacterlist.h" -#include "llhttpnode.h" -#include "llnotificationsutil.h" +#include "llsingleton.h" +#include "llsd.h" #include "lltrans.h" +#include "lluuid.h" +#include "llviewerregion.h" #include "llweb.h" -#include -#include - #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" #define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" @@ -159,7 +164,7 @@ private: class LinksetsResponder { public: - LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); + LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); virtual ~LinksetsResponder(); void handleObjectLinksetsResult(const LLSD &pContent); @@ -180,14 +185,14 @@ private: kReceivedError } EMessagingState; - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::linksets_callback_t mLinksetsCallback; + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::object_request_callback_t mLinksetsCallback; - EMessagingState mObjectMessagingState; - EMessagingState mTerrainMessagingState; + EMessagingState mObjectMessagingState; + EMessagingState mTerrainMessagingState; - LLPathfindingLinksetListPtr mObjectLinksetListPtr; - LLPathfindingLinksetPtr mTerrainLinksetPtr; + LLPathfindingObjectListPtr mObjectLinksetListPtr; + LLPathfindingObjectPtr mTerrainLinksetPtr; }; typedef boost::shared_ptr LinksetsResponderPtr; @@ -239,7 +244,7 @@ private: class CharactersResponder : public LLHTTPClient::Responder { public: - CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback); + CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback); virtual ~CharactersResponder(); virtual void result(const LLSD &pContent); @@ -248,9 +253,9 @@ public: protected: private: - std::string mCapabilityURL; - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::characters_callback_t mCharactersCallback; + std::string mCapabilityURL; + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::object_request_callback_t mCharactersCallback; }; //--------------------------------------------------------------------------- @@ -397,9 +402,9 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } -void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { - LLPathfindingLinksetListPtr emptyLinksetListPtr; + LLPathfindingObjectListPtr emptyLinksetListPtr; LLViewerRegion *currentRegion = getCurrentRegion(); if (currentRegion == NULL) @@ -438,9 +443,9 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_ } } -void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const { - LLPathfindingLinksetListPtr emptyLinksetListPtr; + LLPathfindingObjectListPtr emptyLinksetListPtr; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); @@ -448,13 +453,19 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin { pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); } - else + else if ((pLinksetListPtr == NULL) || pLinksetListPtr->isEmpty()) { - LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); + pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr); + } + else + { + const LLPathfindingLinksetList *linksetList = dynamic_cast(pLinksetListPtr.get()); + + LLSD objectPostData = linksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); LLSD terrainPostData; if (isAllowViewTerrainProperties()) { - terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + terrainPostData = linksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); } if (objectPostData.isUndefined() && terrainPostData.isUndefined()) @@ -482,9 +493,9 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin } } -void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const +void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const { - LLPathfindingCharacterListPtr emptyCharacterListPtr; + LLPathfindingObjectListPtr emptyCharacterListPtr; LLViewerRegion *currentRegion = getCurrentRegion(); @@ -549,7 +560,7 @@ void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegi } } -void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -559,7 +570,7 @@ void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pReg } } -void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const +void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -898,7 +909,7 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) // LinksetsResponder //--------------------------------------------------------------------------- -LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) +LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) : mRequestId(pRequestId), mLinksetsCallback(pLinksetsCallback), mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), @@ -914,7 +925,7 @@ LinksetsResponder::~LinksetsResponder() void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent) { - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent)); + mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList(pContent)); mObjectMessagingState = kReceivedGood; if (mTerrainMessagingState != kWaiting) @@ -935,7 +946,7 @@ void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent) { - mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent)); + mTerrainLinksetPtr = LLPathfindingObjectPtr(new LLPathfindingLinkset(pContent)); mTerrainMessagingState = kReceivedGood; if (mObjectMessagingState != kWaiting) @@ -964,12 +975,12 @@ void LinksetsResponder::sendCallback() if (mObjectMessagingState != kReceivedGood) { - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList()); + mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList()); } if (mTerrainMessagingState == kReceivedGood) { - mObjectLinksetListPtr->insert(std::pair(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); + mObjectLinksetListPtr->update(mTerrainLinksetPtr); } mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); @@ -1029,7 +1040,7 @@ void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) // CharactersResponder //--------------------------------------------------------------------------- -CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback) +CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback) : LLHTTPClient::Responder(), mCapabilityURL(pCapabilityURL), mRequestId(pRequestId), @@ -1043,7 +1054,7 @@ CharactersResponder::~CharactersResponder() void CharactersResponder::result(const LLSD &pContent) { - LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList(pContent)); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); } @@ -1051,7 +1062,6 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) { llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - LLPathfindingCharacterListPtr characterListPtr; + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } - -- cgit v1.2.3 From 3352a1eac15f752535b636866eeb966ec3900c62 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 19:39:08 -0700 Subject: Cleaning up some unreferenced headers and classes definitions from previous refactoring. --- indra/newview/llpathfindingmanager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index b8b9dff51c..e282a3e2f4 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -30,7 +30,7 @@ #include "llpathfindingmanager.h" #include -#include +#include #include #include @@ -39,14 +39,12 @@ #include "llhttpclient.h" #include "llhttpnode.h" #include "llnotificationsutil.h" -#include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" #include "llpathfindingobject.h" -#include "llpathfindinglinksetlist.h" #include "llsingleton.h" #include "llsd.h" #include "lltrans.h" -- cgit v1.2.3 From d25c05547ecfaec1167c7e9f0a2b42a6d27e51a4 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 6 Jun 2012 19:19:29 -0700 Subject: Performing a test regarding the recent failures of our LLHTTPClient::get services. This changeset should be undone. --- indra/newview/llpathfindingmanager.cpp | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e282a3e2f4..85a315a3e7 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -93,6 +93,25 @@ public: LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); +//--------------------------------------------------------------------------- +// StinsonResponder +//--------------------------------------------------------------------------- + +class StinsonResponder : public LLHTTPClient::Responder +{ +public: + StinsonResponder(const std::string &pCapabilityURL); + virtual ~StinsonResponder(); + + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +protected: + +private: + std::string mCapabilityURL; +}; + //--------------------------------------------------------------------------- // NavMeshStatusResponder //--------------------------------------------------------------------------- @@ -519,6 +538,10 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); LLHTTPClient::get(charactersURL, charactersResponder); + + std::string googleURL = "http://www.google.com/"; + LLHTTPClient::ResponderPtr stinsonResponder = new StinsonResponder(googleURL); + LLHTTPClient::get(googleURL, stinsonResponder); } } } @@ -802,6 +825,30 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } +//--------------------------------------------------------------------------- +// StinsonResponder +//--------------------------------------------------------------------------- + +StinsonResponder::StinsonResponder(const std::string &pCapabilityURL) + : LLHTTPClient::Responder(), + mCapabilityURL(pCapabilityURL) +{ +} + +StinsonResponder::~StinsonResponder() +{ +} + +void StinsonResponder::result(const LLSD &pContent) +{ + llinfos << "STINSON DEBUG: success to URL '" << mCapabilityURL << "' with content " << pContent << llendl; +} + +void StinsonResponder::error(U32 pStatus, const std::string& pReason) +{ + llwarns << "STINSON DEBUG: error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; +} + //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- -- cgit v1.2.3 From 9cac312f57391792e9fce380c2c38ae4060ae1d7 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 10:55:18 -0700 Subject: Backed out changeset: 18b06d44c5a3 --- indra/newview/llpathfindingmanager.cpp | 47 ---------------------------------- 1 file changed, 47 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 85a315a3e7..e282a3e2f4 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -93,25 +93,6 @@ public: LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); -//--------------------------------------------------------------------------- -// StinsonResponder -//--------------------------------------------------------------------------- - -class StinsonResponder : public LLHTTPClient::Responder -{ -public: - StinsonResponder(const std::string &pCapabilityURL); - virtual ~StinsonResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - std::string mCapabilityURL; -}; - //--------------------------------------------------------------------------- // NavMeshStatusResponder //--------------------------------------------------------------------------- @@ -538,10 +519,6 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback); LLHTTPClient::get(charactersURL, charactersResponder); - - std::string googleURL = "http://www.google.com/"; - LLHTTPClient::ResponderPtr stinsonResponder = new StinsonResponder(googleURL); - LLHTTPClient::get(googleURL, stinsonResponder); } } } @@ -825,30 +802,6 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } -//--------------------------------------------------------------------------- -// StinsonResponder -//--------------------------------------------------------------------------- - -StinsonResponder::StinsonResponder(const std::string &pCapabilityURL) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL) -{ -} - -StinsonResponder::~StinsonResponder() -{ -} - -void StinsonResponder::result(const LLSD &pContent) -{ - llinfos << "STINSON DEBUG: success to URL '" << mCapabilityURL << "' with content " << pContent << llendl; -} - -void StinsonResponder::error(U32 pStatus, const std::string& pReason) -{ - llwarns << "STINSON DEBUG: error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; -} - //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- -- cgit v1.2.3 From ff7223fafef58d9f8025e97fee87cf7911d93ccf Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 14:45:59 -0700 Subject: PATH-706: Removing enforcement on frozen/unfrozen state from the linksets floater. Also, removing handlers for agent state change. --- indra/newview/llpathfindingmanager.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e282a3e2f4..5e2a9e1213 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -292,11 +292,6 @@ bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegion } #endif // DEPRECATED_UNVERSIONED_NAVMESH -bool LLPathfindingManager::isAllowAlterPermanent() -{ - return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); -} - bool LLPathfindingManager::isAllowViewTerrainProperties() const { LLViewerRegion* region = getCurrentRegion(); -- cgit v1.2.3 From b912c27bf44a45e607adc3b5c94d3fd8a9bbf53e Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 16:40:53 -0700 Subject: PATH-711: Implementing Leo's changes for the pathfinding console. --- indra/newview/llpathfindingmanager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5e2a9e1213..ae1c228c69 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -45,6 +45,7 @@ #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" #include "llpathfindingobject.h" +#include "llpathinglib.h" #include "llsingleton.h" #include "llsd.h" #include "lltrans.h" @@ -273,6 +274,14 @@ LLPathfindingManager::~LLPathfindingManager() { } +void LLPathfindingManager::initSystem() +{ + if (LLPathingLib::getInstance() == NULL) + { + LLPathingLib::initSystem(); + } +} + bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const { return isPathfindingEnabledForRegion(getCurrentRegion()); @@ -292,6 +301,11 @@ bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegion } #endif // DEPRECATED_UNVERSIONED_NAVMESH +bool LLPathfindingManager::isPathfindingDebugEnabled() const +{ + return (LLPathingLib::getInstance() != NULL); +} + bool LLPathfindingManager::isAllowViewTerrainProperties() const { LLViewerRegion* region = getCurrentRegion(); -- cgit v1.2.3 From e738e704b88d64b8a0183f94045d229d9f498bd1 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 17:03:15 -0700 Subject: PATH-714: Removing the DEPRECATED_UNVERSIONED_NAVMESH as the viewer no longer has to support the Premium Wilderness regions on the old server code. --- indra/newview/llpathfindingmanager.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index ae1c228c69..1c3800eed6 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -293,14 +293,6 @@ bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion return !retrieveNavMeshURL.empty(); } -#ifdef DEPRECATED_UNVERSIONED_NAVMESH -bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const -{ - std::string navMeshStatusURL = getNavMeshStatusURLForRegion(getCurrentRegion()); - return !navMeshStatusURL.empty(); -} -#endif // DEPRECATED_UNVERSIONED_NAVMESH - bool LLPathfindingManager::isPathfindingDebugEnabled() const { return (LLPathingLib::getInstance() != NULL); @@ -338,25 +330,10 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) else { std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); -#ifdef DEPRECATED_UNVERSIONED_NAVMESH - if (navMeshStatusURL.empty()) - { - LLPathfindingNavMeshStatus navMeshStatus = navMeshPtr->getNavMeshStatusXXX(); - navMeshStatus.incrementNavMeshVersionXXX(); - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, navMeshStatus); - } - else - { - navMeshPtr->handleNavMeshCheckVersion(); - LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); - LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); - } -#else // DEPRECATED_UNVERSIONED_NAVMESH llassert(!navMeshStatusURL.empty()); navMeshPtr->handleNavMeshCheckVersion(); LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); -#endif // DEPRECATED_UNVERSIONED_NAVMESH } } -- cgit v1.2.3 From 3108d4d180df16dab7b87c01334cf466ef88d349 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 18:38:06 -0700 Subject: PATH-726: Removing the DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD as the viewer no longer has to support the Premium Wilderness regions on the old server code. --- indra/newview/llpathfindingmanager.cpp | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 1c3800eed6..9893121980 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -59,7 +59,6 @@ #define CAP_SERVICE_AGENT_STATE "AgentPreferences" #define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" -#define DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD "alter_permanent_objects" #define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" #define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" @@ -377,9 +376,6 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState { LLSD request; request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); -#ifdef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - request[DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); -#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); LLHTTPClient::post(agentStateURL, request, responder); @@ -661,24 +657,9 @@ void LLPathfindingManager::setAgentState(EAgentState pAgentState) void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) { -#ifndef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); -#else // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - EAgentState agentState = kAgentStateUnknown; - if (pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)) - { - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - } - else - { - llassert(pContent.has(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - agentState = (pContent.get(DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - } -#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) { -- cgit v1.2.3 From 42f3648814923edad8a040620cb3db233597cbb9 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 18:59:51 -0700 Subject: PATH-705: First pass at removing the agent state functionality. WIP -- still need to remove XXX_STINSON_AGENT_STATE_DELETE_ME ifdef'ed code. --- indra/newview/llpathfindingmanager.cpp | 125 +++++++-------------------------- 1 file changed, 25 insertions(+), 100 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 9893121980..f54c9892df 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -53,22 +53,24 @@ #include "llviewerregion.h" #include "llweb.h" -#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" +#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" -#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" +#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" -#define CAP_SERVICE_AGENT_STATE "AgentPreferences" -#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" -#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" -#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" - -#define CAP_SERVICE_CHARACTERS "CharacterProperties" +#define CAP_SERVICE_CHARACTERS "CharacterProperties" #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" -#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" #define SIM_MESSAGE_BODY_FIELD "body" +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME +#define CAP_SERVICE_AGENT_STATE "AgentPreferences" +#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME + //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode //--------------------------------------------------------------------------- @@ -81,6 +83,7 @@ public: LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- @@ -92,6 +95,7 @@ public: }; LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // NavMeshStatusResponder @@ -135,6 +139,7 @@ private: LLPathfindingNavMeshPtr mNavMeshPtr; }; +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- @@ -154,6 +159,7 @@ private: std::string mCapabilityURL; LLPathfindingManager::EAgentState mRequestedAgentState; }; +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // LinksetsResponder @@ -262,10 +268,7 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), - mNavMeshMap(), - mAgentStateSignal(), - mAgentState(kAgentStateUnknown), - mLastKnownNonErrorAgentState(kAgentStateUnknown) + mNavMeshMap() { } @@ -336,51 +339,12 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) } } +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); } - -LLPathfindingManager::EAgentState LLPathfindingManager::getAgentState() -{ - if (!isPathfindingEnabledForCurrentRegion()) - { - setAgentState(kAgentStateNotEnabled); - } - else - { - if (!isValidAgentState(mAgentState)) - { - requestGetAgentState(); - } - } - - return mAgentState; -} - -LLPathfindingManager::EAgentState LLPathfindingManager::getLastKnownNonErrorAgentState() const -{ - return mLastKnownNonErrorAgentState; -} - -void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState) -{ - llassert(isValidAgentState(pRequestedAgentState)); - std::string agentStateURL = getAgentStateURLForCurrentRegion(); - - if (agentStateURL.empty()) - { - setAgentState(kAgentStateNotEnabled); - } - else - { - LLSD request; - request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast(pRequestedAgentState == kAgentStateUnfrozen); - - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); - LLHTTPClient::post(agentStateURL, request, responder); - } -} +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { @@ -623,18 +587,13 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return getNavMeshForRegion(regionUUID); } -bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) -{ - return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); -} - +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME void LLPathfindingManager::requestGetAgentState() { std::string agentStateURL = getAgentStateURLForCurrentRegion(); if (agentStateURL.empty()) { - setAgentState(kAgentStateNotEnabled); } else { @@ -643,58 +602,25 @@ void LLPathfindingManager::requestGetAgentState() } } -void LLPathfindingManager::setAgentState(EAgentState pAgentState) -{ - mAgentState = pAgentState; - - if (mAgentState != kAgentStateError) - { - mLastKnownNonErrorAgentState = mAgentState; - } - - mAgentStateSignal(mAgentState); -} - void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) { llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState)) + if ((agentState != pRequestedAgentState)) { agentState = kAgentStateError; llassert(0); } - - setAgentState(agentState); } void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - setAgentState(kAgentStateError); } +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME -void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) -{ - llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - - setAgentState(agentState); - - LLSD substitutions, payload; - LLNotificationsUtil::add("AutomaticAgentStateUnfreeze", substitutions, payload, boost::bind(&LLPathfindingManager::handleAgentStateUserNotification, this, _1, _2)); -} - -void LLPathfindingManager::handleAgentStateUserNotification(const LLSD &pNotification, const LLSD &pResponse) -{ - if (LLNotificationsUtil::getSelectedOption(pNotification, pResponse) == 1) - { - LLWeb::loadURL(LLTrans::getString("Pathfinding_Wiki_URL")); - } -} std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const { @@ -706,11 +632,6 @@ std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion return getCapabilityURLForRegion(pRegion, CAP_SERVICE_RETRIEVE_NAVMESH); } -std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const -{ - return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE); -} - std::string LLPathfindingManager::getObjectLinksetsURLForCurrentRegion() const { return getCapabilityURLForCurrentRegion(CAP_SERVICE_OBJECT_LINKSETS); @@ -769,6 +690,7 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- @@ -782,6 +704,7 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); } +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // NavMeshStatusResponder @@ -845,6 +768,7 @@ void NavMeshResponder::error(U32 pStatus, const std::string& pReason) mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion); } +#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- @@ -869,6 +793,7 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) { LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); } +#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // LinksetsResponder -- cgit v1.2.3 From de1e1db9600a03ab5b0dc3f04a5bdcee30632f05 Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 13 Jun 2012 10:50:46 -0400 Subject: WIP for path-702. --- indra/newview/llpathfindingmanager.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index f54c9892df..6d0629698a 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -52,6 +52,7 @@ #include "lluuid.h" #include "llviewerregion.h" #include "llweb.h" +#include "llpanelnavmeshrebake.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -268,7 +269,7 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), - mNavMeshMap() + mNavMeshMap(),mShowNavMeshRebake(false) { } @@ -315,7 +316,15 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - + //prep#s#test + LLView* rootp = LLUI::getRootView(); + LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); + LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); + panel_nmr_container->addChild( panel_namesh_rebake ); + panel_nmr_container->setVisible( TRUE ); + panel_namesh_rebake->reparent( rootp ); + LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); + //prep#e if (pRegion == NULL) { navMeshPtr->handleNavMeshNotEnabled(); @@ -955,3 +964,4 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } + -- cgit v1.2.3 From d7b9af3ab398aedde1229e081c2b245c20a3c6d5 Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 13 Jun 2012 11:08:07 -0400 Subject: path-724: xml navmesh rebake button --- indra/newview/llpathfindingmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 6d0629698a..278269b2fa 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -318,7 +318,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); //prep#s#test LLView* rootp = LLUI::getRootView(); - LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); + LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); panel_nmr_container->addChild( panel_namesh_rebake ); panel_nmr_container->setVisible( TRUE ); -- cgit v1.2.3 From 7d5c4d20b9f99b3e7d5781433ed6046678292627 Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 13 Jun 2012 13:30:26 -0400 Subject: WIP: path-722. Posting and responders for navmesh rebaking --- indra/newview/llpathfindingmanager.cpp | 95 ++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 10 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 278269b2fa..fc296a4b83 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -162,6 +162,23 @@ private: }; #endif // XXX_STINSON_AGENT_STATE_DELETE_ME +//--------------------------------------------------------------------------- +// NavMeshRebakeResponder +//--------------------------------------------------------------------------- +class NavMeshRebakeResponder : public LLHTTPClient::Responder +{ +public: + NavMeshRebakeResponder( const std::string &pCapabilityURL ); + virtual ~NavMeshRebakeResponder(); + + virtual void result( const LLSD &pContent ); + virtual void error( U32 pStatus, const std::string& pReason ); + +protected: + +private: + std::string mCapabilityURL; +}; //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- @@ -269,7 +286,7 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), - mNavMeshMap(),mShowNavMeshRebake(false) + mNavMeshMap(), mShowNavMeshRebake(false) { } @@ -316,15 +333,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - //prep#s#test - LLView* rootp = LLUI::getRootView(); - LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); - LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); - panel_nmr_container->addChild( panel_namesh_rebake ); - panel_nmr_container->setVisible( TRUE ); - panel_namesh_rebake->reparent( rootp ); - LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); - //prep#e + if (pRegion == NULL) { navMeshPtr->handleNavMeshNotEnabled(); @@ -684,6 +693,50 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } +void LLPathfindingManager::displayNavMeshRebakePanel() +{ + LLView* rootp = LLUI::getRootView(); + LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); + LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); + panel_nmr_container->addChild( panel_namesh_rebake ); + panel_nmr_container->setVisible( TRUE ); + panel_namesh_rebake->reparent( rootp ); + LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); +} + +void LLPathfindingManager::hideNavMeshRebakePanel() +{ + LLPanelNavMeshRebake::getInstance()->setVisible( FALSE ); +} + +void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) +{ + +} + +void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; +} +//prep# +void LLPathfindingManager::triggerNavMeshRebuild() +{ + LLSD mPostData; + std::string url = getNavMeshStatusURLForRegion( getCurrentRegion() ); + + if ( url.empty() ) + { + //prep#fix#error? + } + else + { + LLSD mPostData; + mPostData["command"] = "rebuild"; + LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder( url ); + LLHTTPClient::post( url, mPostData, responder ); + } + +} //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode //--------------------------------------------------------------------------- @@ -804,6 +857,28 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) } #endif // XXX_STINSON_AGENT_STATE_DELETE_ME +//--------------------------------------------------------------------------- +// navmesh rebake responder +//--------------------------------------------------------------------------- +NavMeshRebakeResponder::NavMeshRebakeResponder(const std::string &pCapabilityURL ) +: LLHTTPClient::Responder() +, mCapabilityURL( pCapabilityURL ) +{ +} + +NavMeshRebakeResponder::~NavMeshRebakeResponder() +{ +} + +void NavMeshRebakeResponder::result(const LLSD &pContent) +{ + LLPathfindingManager::getInstance()->handleNavMeshRebakeResult( pContent ); +} + +void NavMeshRebakeResponder::error(U32 pStatus, const std::string &pReason) +{ + LLPathfindingManager::getInstance()->handleNavMeshRebakeError( pStatus, pReason, mCapabilityURL ); +} //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From 9767b5a026ba1b442ad1aa438f5957375a997c14 Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 13 Jun 2012 15:31:44 -0400 Subject: Path-722: Reset buttons to default state. --- indra/newview/llpathfindingmanager.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index fc296a4b83..7ce34fcfcb 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -333,7 +333,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - + if (pRegion == NULL) { navMeshPtr->handleNavMeshNotEnabled(); @@ -702,31 +702,30 @@ void LLPathfindingManager::displayNavMeshRebakePanel() panel_nmr_container->setVisible( TRUE ); panel_namesh_rebake->reparent( rootp ); LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); + LLPanelNavMeshRebake::getInstance()->resetButtonStates(); } -void LLPathfindingManager::hideNavMeshRebakePanel() +void LLPathfindingManager::hideNavMeshRebakePanel() { LLPanelNavMeshRebake::getInstance()->setVisible( FALSE ); } -void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) +void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) { - + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; } -void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) +void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) { - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + hideNavMeshRebakePanel(); } -//prep# + void LLPathfindingManager::triggerNavMeshRebuild() { - LLSD mPostData; std::string url = getNavMeshStatusURLForRegion( getCurrentRegion() ); - if ( url.empty() ) { - //prep#fix#error? + llwarns << "Error with request due to nonexistent URL"< Date: Thu, 14 Jun 2012 16:58:11 -0400 Subject: WIP: path-722. Some agent_state_updates come through (god mode), region crossings, cleanup logic is a TBD, etc.. --- indra/newview/llpathfindingmanager.cpp | 100 ++++++++++++++++----------------- 1 file changed, 49 insertions(+), 51 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 7ce34fcfcb..16283282fb 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -53,6 +53,7 @@ #include "llviewerregion.h" #include "llweb.h" #include "llpanelnavmeshrebake.h" +#include "llenvmanager.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -66,11 +67,9 @@ #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" #define SIM_MESSAGE_BODY_FIELD "body" -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME -#define CAP_SERVICE_AGENT_STATE "AgentPreferences" -#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" -#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentPreferencesUpdate" -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME +#define CAP_SERVICE_AGENT_STATE "AgentState" +#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentStateUpdate" //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode @@ -84,11 +83,10 @@ public: LLHTTPRegistration gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME + //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- - class LLAgentStateChangeNode : public LLHTTPNode { public: @@ -96,7 +94,6 @@ public: }; LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // NavMeshStatusResponder @@ -140,7 +137,6 @@ private: LLPathfindingNavMeshPtr mNavMeshPtr; }; -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- @@ -148,7 +144,7 @@ private: class AgentStateResponder : public LLHTTPClient::Responder { public: - AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState = LLPathfindingManager::kAgentStateUnknown); + AgentStateResponder(const std::string &pCapabilityURL); virtual ~AgentStateResponder(); virtual void result(const LLSD &pContent); @@ -158,9 +154,8 @@ protected: private: std::string mCapabilityURL; - LLPathfindingManager::EAgentState mRequestedAgentState; }; -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME + //--------------------------------------------------------------------------- // NavMeshRebakeResponder @@ -286,12 +281,27 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), - mNavMeshMap(), mShowNavMeshRebake(false) + mNavMeshMap(), + mShowNavMeshRebake(false), + mCrossingSlot() { + if ( !mCrossingSlot.connected() ) + { + mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); + } +} + +void LLPathfindingManager::onRegionBoundaryCrossed() +{ + displayNavMeshRebakePanel(); } LLPathfindingManager::~LLPathfindingManager() -{ +{ + if (mCrossingSlot.connected()) + { + mCrossingSlot.disconnect(); + } } void LLPathfindingManager::initSystem() @@ -357,12 +367,11 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) } } -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) { return mAgentStateSignal.connect(pAgentStateCallback); } -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME + void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { @@ -605,39 +614,31 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return getNavMeshForRegion(regionUUID); } -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME void LLPathfindingManager::requestGetAgentState() { - std::string agentStateURL = getAgentStateURLForCurrentRegion(); + std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); - if (agentStateURL.empty()) - { - } - else + if ( !agentStateURL.empty() ) { - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL); - LLHTTPClient::get(agentStateURL, responder); + LLHTTPClient::ResponderPtr responder = new AgentStateResponder( agentStateURL ); + LLHTTPClient::get( agentStateURL, responder ); } } -void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState) -{ - llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD)); - llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean()); - EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen); - - if ((agentState != pRequestedAgentState)) - { - agentState = kAgentStateError; - llassert(0); - } +void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent) +{ + displayNavMeshRebakePanel(); } void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; } -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME + +std::string LLPathfindingManager::getAgentStateURLForCurrentRegion(LLViewerRegion *pRegion) const +{ + return getCapabilityURLForRegion( pRegion, CAP_SERVICE_AGENT_STATE ); +} std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const @@ -750,21 +751,19 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus); } -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received AgentPreferencesUpdate: " << pInput << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE - llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); - llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); - LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); + LLPathfindingManager::getInstance()->handleAgentStateUpdate(); +} + +void LLPathfindingManager::handleAgentStateUpdate() +{ + displayNavMeshRebakePanel(); } -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // NavMeshStatusResponder @@ -828,15 +827,13 @@ void NavMeshResponder::error(U32 pStatus, const std::string& pReason) mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion); } -#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME //--------------------------------------------------------------------------- // AgentStateResponder //--------------------------------------------------------------------------- -AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL, LLPathfindingManager::EAgentState pRequestedAgentState) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL), - mRequestedAgentState(pRequestedAgentState) +AgentStateResponder::AgentStateResponder(const std::string &pCapabilityURL) +: LLHTTPClient::Responder() +, mCapabilityURL(pCapabilityURL) { } @@ -846,14 +843,14 @@ AgentStateResponder::~AgentStateResponder() void AgentStateResponder::result(const LLSD &pContent) { - LLPathfindingManager::getInstance()->handleAgentStateResult(pContent, mRequestedAgentState); + LLPathfindingManager::getInstance()->handleAgentStateResult(pContent); } void AgentStateResponder::error(U32 pStatus, const std::string &pReason) { LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); } -#endif // XXX_STINSON_AGENT_STATE_DELETE_ME + //--------------------------------------------------------------------------- // navmesh rebake responder @@ -877,6 +874,7 @@ void NavMeshRebakeResponder::error(U32 pStatus, const std::string &pReason) { LLPathfindingManager::getInstance()->handleNavMeshRebakeError( pStatus, pReason, mCapabilityURL ); } + //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From 72a2538f74fb78d031a8e41c6ca2b8f22c75dac2 Mon Sep 17 00:00:00 2001 From: prep Date: Fri, 15 Jun 2012 13:27:38 -0400 Subject: Fixed bug where rebake navmesh would get drawn ontop of loading screen. --- indra/newview/llpathfindingmanager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 16283282fb..a77d6bcc4c 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -285,10 +285,7 @@ LLPathfindingManager::LLPathfindingManager() mShowNavMeshRebake(false), mCrossingSlot() { - if ( !mCrossingSlot.connected() ) - { - mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); - } + } void LLPathfindingManager::onRegionBoundaryCrossed() @@ -616,6 +613,11 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion void LLPathfindingManager::requestGetAgentState() { + if ( !mCrossingSlot.connected() ) + { + mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); + } + std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); if ( !agentStateURL.empty() ) -- cgit v1.2.3 From b59a82fc8ea5a23a886d3eb5d3c27b7c1d97d8d6 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 18 Jun 2012 17:21:42 -0700 Subject: PATH-705: Creating a path to pull in the state of the current region navmesh without downloading the navmesh binary. --- indra/newview/llpathfindingmanager.cpp | 118 ++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 23 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index a77d6bcc4c..674a96a439 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -102,7 +102,7 @@ LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode class NavMeshStatusResponder : public LLHTTPClient::Responder { public: - NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion); + NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion, bool pIsGetStatusOnly); virtual ~NavMeshStatusResponder(); virtual void result(const LLSD &pContent); @@ -114,6 +114,7 @@ private: std::string mCapabilityURL; LLViewerRegion *mRegion; LLUUID mRegionUUID; + bool mIsGetStatusOnly; }; //--------------------------------------------------------------------------- @@ -282,23 +283,30 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), mNavMeshMap(), - mShowNavMeshRebake(false), - mCrossingSlot() + mCrossingSlot(), + mAgentStateSignal(), + mNavMeshSlot() { - } void LLPathfindingManager::onRegionBoundaryCrossed() { + if (mNavMeshSlot.connected()) + { + mNavMeshSlot.disconnect(); + } + LLViewerRegion *currentRegion = getCurrentRegion(); + if (currentRegion != NULL) + { + mNavMeshSlot = registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPathfindingManager::handleNavMeshStatus, this, _1, _2)); + requestGetNavMeshForRegion(currentRegion, true); + } displayNavMeshRebakePanel(); } LLPathfindingManager::~LLPathfindingManager() { - if (mCrossingSlot.connected()) - { - mCrossingSlot.disconnect(); - } + quitSystem(); } void LLPathfindingManager::initSystem() @@ -307,6 +315,40 @@ void LLPathfindingManager::initSystem() { LLPathingLib::initSystem(); } + + if ( !mCrossingSlot.connected() ) + { + mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); + } + + if (mNavMeshSlot.connected()) + { + mNavMeshSlot.disconnect(); + } + LLViewerRegion *currentRegion = getCurrentRegion(); + if (currentRegion != NULL) + { + mNavMeshSlot = registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPathfindingManager::handleNavMeshStatus, this, _1, _2)); + requestGetNavMeshForRegion(currentRegion, true); + } +} + +void LLPathfindingManager::quitSystem() +{ + if (mNavMeshSlot.connected()) + { + mNavMeshSlot.disconnect(); + } + + if (mCrossingSlot.connected()) + { + mCrossingSlot.disconnect(); + } + + if (LLPathingLib::getInstance() != NULL) + { + LLPathingLib::quitSystem(); + } } bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const @@ -337,7 +379,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen return navMeshPtr->registerNavMeshListener(pNavMeshCallback); } -void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) +void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, bool pIsGetStatusOnly) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); @@ -348,7 +390,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) else if (!pRegion->capabilitiesReceived()) { navMeshPtr->handleNavMeshWaitForRegionLoad(); - pRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetNavMeshForRegion, this, _1)); + pRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetNavMeshForRegion, this, _1, pIsGetStatusOnly)); } else if (!isPathfindingEnabledForRegion(pRegion)) { @@ -359,7 +401,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); llassert(!navMeshStatusURL.empty()); navMeshPtr->handleNavMeshCheckVersion(); - LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); + LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion, pIsGetStatusOnly); LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); } } @@ -518,13 +560,13 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt } } -void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID) +void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID, bool pIsGetStatusOnly) { LLViewerRegion *currentRegion = getCurrentRegion(); if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) { - requestGetNavMeshForRegion(currentRegion); + requestGetNavMeshForRegion(currentRegion, pIsGetStatusOnly); } } @@ -548,7 +590,7 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR } } -void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion) +void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); @@ -562,6 +604,10 @@ void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMesh { navMeshPtr->handleRefresh(pNavMeshStatus); } + else if (pIsGetStatusOnly) + { + navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); + } else { sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); @@ -613,11 +659,6 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion void LLPathfindingManager::requestGetAgentState() { - if ( !mCrossingSlot.connected() ) - { - mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); - } - std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); if ( !agentStateURL.empty() ) @@ -696,6 +737,36 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } +void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshRequestStatus pRequestStatus, const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + if (!pNavMeshStatus.isValid()) + { + llinfos << "STINSON DEBUG: navmesh status is invalid" << llendl; + } + else + { + switch (pNavMeshStatus.getStatus()) + { + case LLPathfindingNavMeshStatus::kPending : + llinfos << "STINSON DEBUG: navmesh status is kPending" << llendl; + break; + case LLPathfindingNavMeshStatus::kBuilding : + llinfos << "STINSON DEBUG: navmesh status is kBuilding" << llendl; + break; + case LLPathfindingNavMeshStatus::kComplete : + llinfos << "STINSON DEBUG: navmesh status is kComplete" << llendl; + break; + case LLPathfindingNavMeshStatus::kRepending : + llinfos << "STINSON DEBUG: navmesh status is kRepending" << llendl; + break; + default : + llinfos << "STINSON DEBUG: navmesh status is default" << llendl; + llassert(0); + break; + } + } +} + void LLPathfindingManager::displayNavMeshRebakePanel() { LLView* rootp = LLUI::getRootView(); @@ -771,11 +842,12 @@ void LLPathfindingManager::handleAgentStateUpdate() // NavMeshStatusResponder //--------------------------------------------------------------------------- -NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) +NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion, bool pIsGetStatusOnly) : LLHTTPClient::Responder(), mCapabilityURL(pCapabilityURL), mRegion(pRegion), - mRegionUUID() + mRegionUUID(), + mIsGetStatusOnly(pIsGetStatusOnly) { if (mRegion != NULL) { @@ -793,14 +865,14 @@ void NavMeshStatusResponder::result(const LLSD &pContent) llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; #endif // XXX_STINSON_DEBUG_NAVMESH_ZONE LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly); } void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) { llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); + LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly); } //--------------------------------------------------------------------------- -- cgit v1.2.3 From 15d7f3867cc0e88258a032f6bd99daed73b1e135 Mon Sep 17 00:00:00 2001 From: prep Date: Tue, 19 Jun 2012 10:40:03 -0400 Subject: Don't display the rebake navmesh button while SL splash screen is up --- indra/newview/llpathfindingmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 674a96a439..209176fc0b 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -54,6 +54,7 @@ #include "llweb.h" #include "llpanelnavmeshrebake.h" #include "llenvmanager.h" +#include "llstartup.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -835,7 +836,8 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c void LLPathfindingManager::handleAgentStateUpdate() { - displayNavMeshRebakePanel(); + //Don't trigger if we are still loading in + if ( LLStartUp::getStartupState() == STATE_STARTED) { displayNavMeshRebakePanel(); } } //--------------------------------------------------------------------------- -- cgit v1.2.3 From eb341068de59c86101aa4fd4031b6cdd7e4bbdc2 Mon Sep 17 00:00:00 2001 From: prep Date: Tue, 19 Jun 2012 10:55:02 -0400 Subject: Path-722: After a successful rebake the rebake navmesh button is reenabled --- indra/newview/llpathfindingmanager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 209176fc0b..f49942ee97 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -756,6 +756,7 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq break; case LLPathfindingNavMeshStatus::kComplete : llinfos << "STINSON DEBUG: navmesh status is kComplete" << llendl; + displayNavMeshRebakePanel(); break; case LLPathfindingNavMeshStatus::kRepending : llinfos << "STINSON DEBUG: navmesh status is kRepending" << llendl; -- cgit v1.2.3 From 6711e6584aa0aa5f17f76a557524725857fbf2ba Mon Sep 17 00:00:00 2001 From: prep Date: Tue, 19 Jun 2012 15:09:22 -0400 Subject: path-722: handling the case where region entry or teleporting would cause the rebake button to be drawn ontop of splash screen. --- indra/newview/llpathfindingmanager.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index f49942ee97..d1a249edc5 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -302,7 +302,6 @@ void LLPathfindingManager::onRegionBoundaryCrossed() mNavMeshSlot = registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPathfindingManager::handleNavMeshStatus, this, _1, _2)); requestGetNavMeshForRegion(currentRegion, true); } - displayNavMeshRebakePanel(); } LLPathfindingManager::~LLPathfindingManager() @@ -771,14 +770,17 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq void LLPathfindingManager::displayNavMeshRebakePanel() { - LLView* rootp = LLUI::getRootView(); - LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); - LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); - panel_nmr_container->addChild( panel_namesh_rebake ); - panel_nmr_container->setVisible( TRUE ); - panel_namesh_rebake->reparent( rootp ); - LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); - LLPanelNavMeshRebake::getInstance()->resetButtonStates(); + if ( LLStartUp::getStartupState() == STATE_STARTED && gAgent.getTeleportState() == LLAgent::TELEPORT_NONE ) + { + LLView* rootp = LLUI::getRootView(); + LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); + LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); + panel_nmr_container->addChild( panel_namesh_rebake ); + panel_nmr_container->setVisible( TRUE ); + panel_namesh_rebake->reparent( rootp ); + LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); + LLPanelNavMeshRebake::getInstance()->resetButtonStates(); + } } void LLPathfindingManager::hideNavMeshRebakePanel() -- cgit v1.2.3 From e4aa2038812c2cf2cfed1b17a437ba620929f84f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 19 Jun 2012 17:20:24 -0700 Subject: PATH-702: Positioning the rebake navmesh button to align with the Stand/StopFlying buttons. Also, parenting the buttons to the toolbar UI elements. --- indra/newview/llpathfindingmanager.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index d1a249edc5..d4c689e30d 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -770,22 +770,12 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq void LLPathfindingManager::displayNavMeshRebakePanel() { - if ( LLStartUp::getStartupState() == STATE_STARTED && gAgent.getTeleportState() == LLAgent::TELEPORT_NONE ) - { - LLView* rootp = LLUI::getRootView(); - LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); - LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); - panel_nmr_container->addChild( panel_namesh_rebake ); - panel_nmr_container->setVisible( TRUE ); - panel_namesh_rebake->reparent( rootp ); - LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); - LLPanelNavMeshRebake::getInstance()->resetButtonStates(); - } + LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_Available); } void LLPathfindingManager::hideNavMeshRebakePanel() { - LLPanelNavMeshRebake::getInstance()->setVisible( FALSE ); + LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_NotAvailable); } void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) -- cgit v1.2.3 From f5a5e687b77b70958e2ebb5a21ae4c4de2bc1bd8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 19 Jun 2012 18:13:47 -0700 Subject: PATH-702: Tying the status of the rebake button to the status of the navmesh for the current region. --- indra/newview/llpathfindingmanager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index d4c689e30d..6dffe2f459 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -54,7 +54,9 @@ #include "llweb.h" #include "llpanelnavmeshrebake.h" #include "llenvmanager.h" +#if 0 #include "llstartup.h" +#endif #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -670,7 +672,9 @@ void LLPathfindingManager::requestGetAgentState() void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent) { +#if 0 displayNavMeshRebakePanel(); +#endif } void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) @@ -755,7 +759,6 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq break; case LLPathfindingNavMeshStatus::kComplete : llinfos << "STINSON DEBUG: navmesh status is kComplete" << llendl; - displayNavMeshRebakePanel(); break; case LLPathfindingNavMeshStatus::kRepending : llinfos << "STINSON DEBUG: navmesh status is kRepending" << llendl; @@ -768,6 +771,7 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq } } +#if 0 void LLPathfindingManager::displayNavMeshRebakePanel() { LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_Available); @@ -777,6 +781,7 @@ void LLPathfindingManager::hideNavMeshRebakePanel() { LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_NotAvailable); } +#endif void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) { @@ -785,7 +790,10 @@ void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::stri void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) { + +#if 0 hideNavMeshRebakePanel(); +#endif } void LLPathfindingManager::triggerNavMeshRebuild() @@ -830,7 +838,9 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c void LLPathfindingManager::handleAgentStateUpdate() { //Don't trigger if we are still loading in +#if 0 if ( LLStartUp::getStartupState() == STATE_STARTED) { displayNavMeshRebakePanel(); } +#endif } //--------------------------------------------------------------------------- -- cgit v1.2.3 From 37f3a016fcc8b1cf92cdb4c546b1ab25546a527a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 19 Jun 2012 18:29:49 -0700 Subject: Removing unused methods and members from the pathfinding manager. --- indra/newview/llpathfindingmanager.cpp | 74 +--------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 6dffe2f459..912b264c41 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -286,26 +286,10 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), mNavMeshMap(), - mCrossingSlot(), - mAgentStateSignal(), - mNavMeshSlot() + mAgentStateSignal() { } -void LLPathfindingManager::onRegionBoundaryCrossed() -{ - if (mNavMeshSlot.connected()) - { - mNavMeshSlot.disconnect(); - } - LLViewerRegion *currentRegion = getCurrentRegion(); - if (currentRegion != NULL) - { - mNavMeshSlot = registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPathfindingManager::handleNavMeshStatus, this, _1, _2)); - requestGetNavMeshForRegion(currentRegion, true); - } -} - LLPathfindingManager::~LLPathfindingManager() { quitSystem(); @@ -317,36 +301,10 @@ void LLPathfindingManager::initSystem() { LLPathingLib::initSystem(); } - - if ( !mCrossingSlot.connected() ) - { - mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this)); - } - - if (mNavMeshSlot.connected()) - { - mNavMeshSlot.disconnect(); - } - LLViewerRegion *currentRegion = getCurrentRegion(); - if (currentRegion != NULL) - { - mNavMeshSlot = registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPathfindingManager::handleNavMeshStatus, this, _1, _2)); - requestGetNavMeshForRegion(currentRegion, true); - } } void LLPathfindingManager::quitSystem() { - if (mNavMeshSlot.connected()) - { - mNavMeshSlot.disconnect(); - } - - if (mCrossingSlot.connected()) - { - mCrossingSlot.disconnect(); - } - if (LLPathingLib::getInstance() != NULL) { LLPathingLib::quitSystem(); @@ -741,36 +699,6 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } -void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshRequestStatus pRequestStatus, const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - if (!pNavMeshStatus.isValid()) - { - llinfos << "STINSON DEBUG: navmesh status is invalid" << llendl; - } - else - { - switch (pNavMeshStatus.getStatus()) - { - case LLPathfindingNavMeshStatus::kPending : - llinfos << "STINSON DEBUG: navmesh status is kPending" << llendl; - break; - case LLPathfindingNavMeshStatus::kBuilding : - llinfos << "STINSON DEBUG: navmesh status is kBuilding" << llendl; - break; - case LLPathfindingNavMeshStatus::kComplete : - llinfos << "STINSON DEBUG: navmesh status is kComplete" << llendl; - break; - case LLPathfindingNavMeshStatus::kRepending : - llinfos << "STINSON DEBUG: navmesh status is kRepending" << llendl; - break; - default : - llinfos << "STINSON DEBUG: navmesh status is default" << llendl; - llassert(0); - break; - } - } -} - #if 0 void LLPathfindingManager::displayNavMeshRebakePanel() { -- cgit v1.2.3 From b98cbe00fe885cebebe1ec5fd123c969b5d2c29f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 19 Jun 2012 19:06:25 -0700 Subject: PATH-702: Refining the behavior of the rebuild navmesh button after it is pushed, and removing unused code. --- indra/newview/llpathfindingmanager.cpp | 90 ++++++++++++---------------------- 1 file changed, 31 insertions(+), 59 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 912b264c41..7675d500da 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -54,9 +54,6 @@ #include "llweb.h" #include "llpanelnavmeshrebake.h" #include "llenvmanager.h" -#if 0 -#include "llstartup.h" -#endif #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -167,17 +164,19 @@ private: class NavMeshRebakeResponder : public LLHTTPClient::Responder { public: - NavMeshRebakeResponder( const std::string &pCapabilityURL ); + NavMeshRebakeResponder(const std::string &pCapabilityURL, LLPathfindingManager::rebake_navmesh_callback_t pRebakeNavMeshCallback); virtual ~NavMeshRebakeResponder(); - virtual void result( const LLSD &pContent ); - virtual void error( U32 pStatus, const std::string& pReason ); + virtual void result(const LLSD &pContent); + virtual void error(U32 pStatus, const std::string& pReason); protected: private: - std::string mCapabilityURL; + std::string mCapabilityURL; + LLPathfindingManager::rebake_navmesh_callback_t mRebakeNavMeshCallback; }; + //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- @@ -495,6 +494,19 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ } } +void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebakeNavMeshCallback) +{ + std::string navMeshStatusURL = getNavMeshStatusURLForCurrentRegion(); + llassert(!navMeshStatusURL.empty()) + if (!navMeshStatusURL.empty()) + { + LLSD mPostData; + mPostData["command"] = "rebuild"; + LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder(navMeshStatusURL, pRebakeNavMeshCallback); + LLHTTPClient::post(navMeshStatusURL, mPostData, responder); + } +} + void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) { if ((pRegion == NULL) || !pRegion->isAlive()) @@ -630,9 +642,6 @@ void LLPathfindingManager::requestGetAgentState() void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent) { -#if 0 - displayNavMeshRebakePanel(); -#endif } void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) @@ -642,9 +651,13 @@ void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string std::string LLPathfindingManager::getAgentStateURLForCurrentRegion(LLViewerRegion *pRegion) const { - return getCapabilityURLForRegion( pRegion, CAP_SERVICE_AGENT_STATE ); + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_AGENT_STATE); } +std::string LLPathfindingManager::getNavMeshStatusURLForCurrentRegion() const +{ + return getNavMeshStatusURLForRegion(getCurrentRegion()); +} std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const { @@ -699,46 +712,6 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } -#if 0 -void LLPathfindingManager::displayNavMeshRebakePanel() -{ - LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_Available); -} - -void LLPathfindingManager::hideNavMeshRebakePanel() -{ - LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_NotAvailable); -} -#endif - -void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; -} - -void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) -{ - -#if 0 - hideNavMeshRebakePanel(); -#endif -} - -void LLPathfindingManager::triggerNavMeshRebuild() -{ - std::string url = getNavMeshStatusURLForRegion( getCurrentRegion() ); - if ( url.empty() ) - { - llwarns << "Error with request due to nonexistent URL"<handleNavMeshRebakeResult( pContent ); + mRebakeNavMeshCallback(true); } void NavMeshRebakeResponder::error(U32 pStatus, const std::string &pReason) { - LLPathfindingManager::getInstance()->handleNavMeshRebakeError( pStatus, pReason, mCapabilityURL ); + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + mRebakeNavMeshCallback(false); } //--------------------------------------------------------------------------- -- cgit v1.2.3 From 37e6aa609f2ccd49e6225bad5186ec6ba49b9cb7 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 19 Jun 2012 20:09:35 -0700 Subject: PATH-723: Pulling in whether the user has access to view the rebake navmesh button or not. --- indra/newview/llpathfindingmanager.cpp | 109 +++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 40 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 7675d500da..44a491b0b5 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -55,21 +55,22 @@ #include "llpanelnavmeshrebake.h" #include "llenvmanager.h" -#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" +#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" -#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" +#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" -#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" -#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" +#define CAP_SERVICE_OBJECT_LINKSETS "ObjectNavMeshProperties" +#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties" -#define CAP_SERVICE_CHARACTERS "CharacterProperties" +#define CAP_SERVICE_CHARACTERS "CharacterProperties" -#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" -#define SIM_MESSAGE_BODY_FIELD "body" +#define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentStateUpdate" +#define SIM_MESSAGE_BODY_FIELD "body" -#define CAP_SERVICE_AGENT_STATE "AgentState" -#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" -#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentStateUpdate" +#define CAP_SERVICE_AGENT_STATE "AgentState" + +#define AGENT_STATE_CAN_REBAKE_REGION_FIELD "can_modify_navmesh" //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode @@ -154,7 +155,7 @@ public: protected: private: - std::string mCapabilityURL; + std::string mCapabilityURL; }; @@ -494,6 +495,34 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ } } +void LLPathfindingManager::requestGetAgentState() +{ + LLViewerRegion *currentRegion = getCurrentRegion(); + + if (currentRegion == NULL) + { + mAgentStateSignal(FALSE); + } + else + { + if (!currentRegion->capabilitiesReceived()) + { + currentRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetAgentStateForRegion, this, _1)); + } + else if (!isPathfindingEnabledForRegion(currentRegion)) + { + mAgentStateSignal(FALSE); + } + else + { + std::string agentStateURL = getAgentStateURLForRegion(currentRegion); + llassert(!agentStateURL.empty()); + LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL); + LLHTTPClient::get(agentStateURL, responder); + } + } +} + void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebakeNavMeshCallback) { std::string navMeshStatusURL = getNavMeshStatusURLForCurrentRegion(); @@ -532,6 +561,16 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt } } +void LLPathfindingManager::handleDeferredGetAgentStateForRegion(const LLUUID &pRegionUUID) +{ + LLViewerRegion *currentRegion = getCurrentRegion(); + + if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) + { + requestGetAgentState(); + } +} + void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID, bool pIsGetStatusOnly) { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -601,6 +640,11 @@ void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshS } } +void LLPathfindingManager::handleAgentState(BOOL pCanRebakeRegion) +{ + mAgentStateSignal(pCanRebakeRegion); +} + LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(const LLUUID &pRegionUUID) { LLPathfindingNavMeshPtr navMeshPtr; @@ -629,27 +673,7 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return getNavMeshForRegion(regionUUID); } -void LLPathfindingManager::requestGetAgentState() -{ - std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); - - if ( !agentStateURL.empty() ) - { - LLHTTPClient::ResponderPtr responder = new AgentStateResponder( agentStateURL ); - LLHTTPClient::get( agentStateURL, responder ); - } -} - -void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent) -{ -} - -void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; -} - -std::string LLPathfindingManager::getAgentStateURLForCurrentRegion(LLViewerRegion *pRegion) const +std::string LLPathfindingManager::getAgentStateURLForRegion(LLViewerRegion *pRegion) const { return getCapabilityURLForRegion(pRegion, CAP_SERVICE_AGENT_STATE); } @@ -733,12 +757,13 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { - LLPathfindingManager::getInstance()->handleAgentStateUpdate(); -} - -void LLPathfindingManager::handleAgentStateUpdate() -{ - //Don't trigger if we are still loading in + llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).has(AGENT_STATE_CAN_REBAKE_REGION_FIELD)); + llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).isBoolean()); + BOOL canRebakeRegion = pInput.get(SIM_MESSAGE_BODY_FIELD).get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).asBoolean(); + + LLPathfindingManager::getInstance()->handleAgentState(canRebakeRegion); } //--------------------------------------------------------------------------- @@ -820,12 +845,16 @@ AgentStateResponder::~AgentStateResponder() void AgentStateResponder::result(const LLSD &pContent) { - LLPathfindingManager::getInstance()->handleAgentStateResult(pContent); + llassert(pContent.has(AGENT_STATE_CAN_REBAKE_REGION_FIELD)); + llassert(pContent.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).isBoolean()); + BOOL canRebakeRegion = pContent.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).asBoolean(); + LLPathfindingManager::getInstance()->handleAgentState(canRebakeRegion); } void AgentStateResponder::error(U32 pStatus, const std::string &pReason) { - LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); + llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + LLPathfindingManager::getInstance()->handleAgentState(FALSE); } -- cgit v1.2.3 From fb1fa8434a1a84105f67e72fdf72d300be2951bb Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 20 Jun 2012 19:46:28 -0700 Subject: PATH-761: Implementing the new design for the pathfinding view floater. --- indra/newview/llpathfindingmanager.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 44a491b0b5..44dab04583 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -322,11 +322,6 @@ bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion return !retrieveNavMeshURL.empty(); } -bool LLPathfindingManager::isPathfindingDebugEnabled() const -{ - return (LLPathingLib::getInstance() != NULL); -} - bool LLPathfindingManager::isAllowViewTerrainProperties() const { LLViewerRegion* region = getCurrentRegion(); -- cgit v1.2.3 From 7cc44fb7fe40706e2017343d76ed226f477dad8d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 22 Jun 2012 18:15:56 -0700 Subject: PATH-759: Removing XXX_STINSON_DEBUG_NAVMESH_ZONE ifdefs. --- indra/newview/llpathfindingmanager.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 44dab04583..a01874296d 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -737,9 +737,6 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received NavMeshStatusUpdate: " << pInput << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE llassert(pInput.has(SIM_MESSAGE_BODY_FIELD)); llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap()); LLPathfindingNavMeshStatus navMeshStatus(pInput.get(SIM_MESSAGE_BODY_FIELD)); @@ -784,9 +781,6 @@ NavMeshStatusResponder::~NavMeshStatusResponder() void NavMeshStatusResponder::result(const LLSD &pContent) { -#ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; -#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly); } -- cgit v1.2.3 From c9fea8b43cfb50d1e8406ea87f47c51daea7cef1 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 18:17:56 -0700 Subject: PATH-718: Disabling the view/test menu in the case of a stubbed llphysicsextensions library. --- indra/newview/llpathfindingmanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index a01874296d..bafcf57944 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -311,6 +311,11 @@ void LLPathfindingManager::quitSystem() } } +bool LLPathfindingManager::isPathfindingViewEnabled() const +{ + return (LLPathingLib::getInstance() != NULL); +} + bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const { return isPathfindingEnabledForRegion(getCurrentRegion()); -- cgit v1.2.3 From 78910cf3016fc55eaf8214640b348df0f8bcdeda Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:04:19 -0700 Subject: Updating the header licensing comments. --- indra/newview/llpathfindingmanager.cpp | 53 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index bafcf57944..019ddbfe96 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -1,29 +1,30 @@ -/** - * @file llpathfindingmanager.cpp - * @author William Todd Stinson - * @brief A state manager for the various pathfinding states. - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ +/** +* @file llpathfindingmanager.cpp +* @brief Implementation of llpathfindingmanager +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + #include "llviewerprecompiledheaders.h" -- cgit v1.2.3 From a818cd4f7336ed9b33dacd91fcaf5239a8be813d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:22:17 -0700 Subject: Renaming the rebake navmesh panel class. --- indra/newview/llpathfindingmanager.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 019ddbfe96..90199a9cae 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -53,7 +53,6 @@ #include "lluuid.h" #include "llviewerregion.h" #include "llweb.h" -#include "llpanelnavmeshrebake.h" #include "llenvmanager.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" -- cgit v1.2.3 From 685a672b74550ca0dbf8a816257c84c9c44fd34d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 28 Jun 2012 15:37:55 -0700 Subject: Cleaning up new files in preparation for merge into viewer-release. --- indra/newview/llpathfindingmanager.cpp | 47 ++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'indra/newview/llpathfindingmanager.cpp') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 90199a9cae..2dd01e931e 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -33,7 +33,9 @@ #include #include +#include #include +#include #include #include "llagent.h" @@ -53,7 +55,6 @@ #include "lluuid.h" #include "llviewerregion.h" #include "llweb.h" -#include "llenvmanager.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -366,12 +367,6 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b } } -LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) -{ - return mAgentStateSignal.connect(pAgentStateCallback); -} - - void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { LLPathfindingObjectListPtr emptyLinksetListPtr; @@ -495,6 +490,11 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ } } +LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback) +{ + return mAgentStateSignal.connect(pAgentStateCallback); +} + void LLPathfindingManager::requestGetAgentState() { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -525,14 +525,24 @@ void LLPathfindingManager::requestGetAgentState() void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebakeNavMeshCallback) { - std::string navMeshStatusURL = getNavMeshStatusURLForCurrentRegion(); - llassert(!navMeshStatusURL.empty()) - if (!navMeshStatusURL.empty()) + LLViewerRegion *currentRegion = getCurrentRegion(); + + if (currentRegion == NULL) + { + pRebakeNavMeshCallback(false); + } + else if (!isPathfindingEnabledForRegion(currentRegion)) { - LLSD mPostData; - mPostData["command"] = "rebuild"; + pRebakeNavMeshCallback(false); + } + else + { + std::string navMeshStatusURL = getNavMeshStatusURLForCurrentRegion(); + llassert(!navMeshStatusURL.empty()); + LLSD postData; + postData["command"] = "rebuild"; LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder(navMeshStatusURL, pRebakeNavMeshCallback); - LLHTTPClient::post(navMeshStatusURL, mPostData, responder); + LLHTTPClient::post(navMeshStatusURL, postData, responder); } } @@ -673,11 +683,6 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return getNavMeshForRegion(regionUUID); } -std::string LLPathfindingManager::getAgentStateURLForRegion(LLViewerRegion *pRegion) const -{ - return getCapabilityURLForRegion(pRegion, CAP_SERVICE_AGENT_STATE); -} - std::string LLPathfindingManager::getNavMeshStatusURLForCurrentRegion() const { return getNavMeshStatusURLForRegion(getCurrentRegion()); @@ -708,6 +713,11 @@ std::string LLPathfindingManager::getCharactersURLForCurrentRegion() const return getCapabilityURLForCurrentRegion(CAP_SERVICE_CHARACTERS); } +std::string LLPathfindingManager::getAgentStateURLForRegion(LLViewerRegion *pRegion) const +{ + return getCapabilityURLForRegion(pRegion, CAP_SERVICE_AGENT_STATE); +} + std::string LLPathfindingManager::getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const { return getCapabilityURLForRegion(getCurrentRegion(), pCapabilityName); @@ -1037,4 +1047,3 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } - -- cgit v1.2.3