summaryrefslogtreecommitdiff
path: root/indra/newview/llpathfindingmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpathfindingmanager.cpp')
-rw-r--r--indra/newview/llpathfindingmanager.cpp309
1 files changed, 142 insertions, 167 deletions
diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp
index e282a3e2f4..a77d6bcc4c 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:
@@ -142,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);
@@ -152,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
//---------------------------------------------------------------------------
@@ -263,14 +282,31 @@ private:
LLPathfindingManager::LLPathfindingManager()
: LLSingleton<LLPathfindingManager>(),
mNavMeshMap(),
- mAgentStateSignal(),
- mAgentState(kAgentStateUnknown),
- mLastKnownNonErrorAgentState(kAgentStateUnknown)
+ mShowNavMeshRebake(false),
+ mCrossingSlot()
{
+
+}
+
+void LLPathfindingManager::onRegionBoundaryCrossed()
+{
+ displayNavMeshRebakePanel();
}
LLPathfindingManager::~LLPathfindingManager()
+{
+ if (mCrossingSlot.connected())
+ {
+ mCrossingSlot.disconnect();
+ }
+}
+
+void LLPathfindingManager::initSystem()
{
+ if (LLPathingLib::getInstance() == NULL)
+ {
+ LLPathingLib::initSystem();
+ }
}
bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const
@@ -284,17 +320,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
@@ -329,25 +357,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
}
}
@@ -356,49 +369,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
{
@@ -641,93 +611,37 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion
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
+ if ( !mCrossingSlot.connected() )
{
- LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL);
- LLHTTPClient::get(agentStateURL, responder);
+ mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this));
}
-}
-void LLPathfindingManager::setAgentState(EAgentState pAgentState)
-{
- mAgentState = pAgentState;
+ std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() );
- if (mAgentState != kAgentStateError)
+ if ( !agentStateURL.empty() )
{
- mLastKnownNonErrorAgentState = mAgentState;
+ LLHTTPClient::ResponderPtr responder = new AgentStateResponder( agentStateURL );
+ LLHTTPClient::get( agentStateURL, responder );
}
-
- 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
{
@@ -739,11 +653,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);
@@ -787,6 +696,48 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const
return gAgent.getRegion();
}
+void LLPathfindingManager::displayNavMeshRebakePanel()
+{
+ 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();
+}
+
+void LLPathfindingManager::hideNavMeshRebakePanel()
+{
+ LLPanelNavMeshRebake::getInstance()->setVisible( FALSE );
+}
+
+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 )
+{
+ hideNavMeshRebakePanel();
+}
+
+void LLPathfindingManager::triggerNavMeshRebuild()
+{
+ 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 );
+ }
+}
//---------------------------------------------------------------------------
// LLNavMeshSimStateChangeNode
//---------------------------------------------------------------------------
@@ -808,12 +759,12 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte
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();
}
//---------------------------------------------------------------------------
@@ -882,10 +833,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)
{
}
@@ -895,7 +845,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)
@@ -903,6 +853,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
//---------------------------------------------------------------------------
@@ -1063,3 +1037,4 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason)
LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList());
mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr);
}
+