diff options
| author | Matthew Breindel (Falcon) <falcon@lindenlab.com> | 2012-06-15 00:28:12 +0000 |
|---|---|---|
| committer | Matthew Breindel (Falcon) <falcon@lindenlab.com> | 2012-06-15 00:28:12 +0000 |
| commit | e76fe073df81d4fd2b25d09f7c0ccd0566c2e966 (patch) | |
| tree | b9270197dc7b0c6bc06f0ea44c991d5cbf9be865 /indra/newview/llpathfindingmanager.cpp | |
| parent | 8b2ad982d72ade6db7ae45758171fa7b5e30a42a (diff) | |
| parent | f6153ab73508ad972827950e0276dfd2a8e79bf1 (diff) | |
Merge
Diffstat (limited to 'indra/newview/llpathfindingmanager.cpp')
| -rw-r--r-- | indra/newview/llpathfindingmanager.cpp | 358 |
1 files changed, 142 insertions, 216 deletions
diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 85a315a3e7..16283282fb 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -45,30 +45,32 @@ #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" #include "llpathfindingobject.h" +#include "llpathinglib.h" #include "llsingleton.h" #include "llsd.h" #include "lltrans.h" #include "lluuid.h" #include "llviewerregion.h" #include "llweb.h" +#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_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 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" +#define CAP_SERVICE_AGENT_STATE "AgentState" +#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects" +#define SIM_MESSAGE_AGENT_STATE_UPDATE "/message/AgentStateUpdate" + //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode //--------------------------------------------------------------------------- @@ -81,10 +83,10 @@ public: LLHTTPRegistration<LLNavMeshSimStateChangeNode> gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE); + //--------------------------------------------------------------------------- // LLAgentStateChangeNode //--------------------------------------------------------------------------- - class LLAgentStateChangeNode : public LLHTTPNode { public: @@ -94,25 +96,6 @@ public: LLHTTPRegistration<LLAgentStateChangeNode> 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 //--------------------------------------------------------------------------- @@ -161,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); @@ -171,9 +154,26 @@ protected: private: std::string mCapabilityURL; - LLPathfindingManager::EAgentState mRequestedAgentState; }; + +//--------------------------------------------------------------------------- +// 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 //--------------------------------------------------------------------------- @@ -282,14 +282,34 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton<LLPathfindingManager>(), mNavMeshMap(), - mAgentStateSignal(), - mAgentState(kAgentStateUnknown), - mLastKnownNonErrorAgentState(kAgentStateUnknown) + 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() { + if (LLPathingLib::getInstance() == NULL) + { + LLPathingLib::initSystem(); + } } bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const @@ -303,17 +323,9 @@ bool LLPathfindingManager::isPathfindingEnabledForRegion(LLViewerRegion *pRegion return !retrieveNavMeshURL.empty(); } -#ifdef DEPRECATED_UNVERSIONED_NAVMESH -bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const +bool LLPathfindingManager::isPathfindingDebugEnabled() const { - std::string navMeshStatusURL = getNavMeshStatusURLForRegion(getCurrentRegion()); - return !navMeshStatusURL.empty(); -} -#endif // DEPRECATED_UNVERSIONED_NAVMESH - -bool LLPathfindingManager::isAllowAlterPermanent() -{ - return (!isPathfindingEnabledForCurrentRegion() || (getAgentState() == kAgentStateUnfrozen)); + return (LLPathingLib::getInstance() != NULL); } bool LLPathfindingManager::isAllowViewTerrainProperties() const @@ -348,25 +360,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 } } @@ -375,49 +372,6 @@ LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStat 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<LLSD::Boolean>(pRequestedAgentState == kAgentStateUnfrozen); -#ifdef DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - request[DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD] = static_cast<LLSD::Boolean>(pRequestedAgentState == kAgentStateUnfrozen); -#endif // DEPRECATED_ALTER_NAVMESH_OBJECTS_FIELD - - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState); - LLHTTPClient::post(agentStateURL, request, responder); - } -} void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { @@ -538,10 +492,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); } } } @@ -664,93 +614,32 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion return getNavMeshForRegion(regionUUID); } -bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState) -{ - return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen)); -} - void LLPathfindingManager::requestGetAgentState() { - std::string agentStateURL = getAgentStateURLForCurrentRegion(); + std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); - if (agentStateURL.empty()) - { - setAgentState(kAgentStateNotEnabled); - } - 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::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::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; - setAgentState(kAgentStateError); } -void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent) +std::string LLPathfindingManager::getAgentStateURLForCurrentRegion(LLViewerRegion *pRegion) const { - 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)); + return getCapabilityURLForRegion( pRegion, CAP_SERVICE_AGENT_STATE ); } -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 { @@ -762,11 +651,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); @@ -810,57 +694,75 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } -//--------------------------------------------------------------------------- -// LLNavMeshSimStateChangeNode -//--------------------------------------------------------------------------- - -void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +void LLPathfindingManager::displayNavMeshRebakePanel() { -#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); + LLView* rootp = LLUI::getRootView(); + LLPanel* panel_nmr_container = rootp->getChild<LLPanel>("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(); } -//--------------------------------------------------------------------------- -// StinsonResponder -//--------------------------------------------------------------------------- - -StinsonResponder::StinsonResponder(const std::string &pCapabilityURL) - : LLHTTPClient::Responder(), - mCapabilityURL(pCapabilityURL) +void LLPathfindingManager::hideNavMeshRebakePanel() { + LLPanelNavMeshRebake::getInstance()->setVisible( FALSE ); } -StinsonResponder::~StinsonResponder() +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 StinsonResponder::result(const LLSD &pContent) +void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) { - llinfos << "STINSON DEBUG: success to URL '" << mCapabilityURL << "' with content " << pContent << llendl; + hideNavMeshRebakePanel(); } -void StinsonResponder::error(U32 pStatus, const std::string& pReason) +void LLPathfindingManager::triggerNavMeshRebuild() { - llwarns << "STINSON DEBUG: error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + std::string url = getNavMeshStatusURLForRegion( getCurrentRegion() ); + if ( url.empty() ) + { + llwarns << "Error with request due to nonexistent URL"<<llendl; + } + else + { + LLSD mPostData; + mPostData["command"] = "rebuild"; + LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder( url ); + LLHTTPClient::post( url, mPostData, responder ); + } } - //--------------------------------------------------------------------------- -// LLAgentStateChangeNode +// LLNavMeshSimStateChangeNode //--------------------------------------------------------------------------- -void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const +void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, const LLSD &pInput) const { #ifdef XXX_STINSON_DEBUG_NAVMESH_ZONE - llinfos << "STINSON DEBUG: Received AgentPreferencesUpdate: " << pInput << llendl; + 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()); - LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD)); + 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 +{ + LLPathfindingManager::getInstance()->handleAgentStateUpdate(); +} + +void LLPathfindingManager::handleAgentStateUpdate() +{ + displayNavMeshRebakePanel(); } //--------------------------------------------------------------------------- @@ -929,10 +831,9 @@ void NavMeshResponder::error(U32 pStatus, const std::string& pReason) // 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) { } @@ -942,7 +843,7 @@ 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) @@ -950,6 +851,30 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL); } + +//--------------------------------------------------------------------------- +// 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 //--------------------------------------------------------------------------- @@ -1110,3 +1035,4 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } + |
