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.cpp169
1 files changed, 164 insertions, 5 deletions
diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp
index a59dda74ac..ebefebbb64 100644
--- a/indra/newview/llpathfindingmanager.cpp
+++ b/indra/newview/llpathfindingmanager.cpp
@@ -26,15 +26,19 @@
*/
#include <string>
+#include <vector>
#include "llviewerprecompiledheaders.h"
+#include "llsd.h"
#include "llpathfindingmanager.h"
#include "llsingleton.h"
#include "llhttpclient.h"
#include "llagent.h"
#include "llviewerregion.h"
+#include "llpathfindingnavmesh.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
+#include "llhttpnode.h"
#include <boost/function.hpp>
#include <boost/signals2.hpp>
@@ -48,6 +52,41 @@
#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<LLNavMeshSimStateChangeNode> gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE);
+
+//---------------------------------------------------------------------------
+// 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
//---------------------------------------------------------------------------
@@ -153,6 +192,8 @@ private:
LLPathfindingManager::LLPathfindingManager()
: LLSingleton<LLPathfindingManager>(),
+ mNavMeshMap(),
+ mNavMeshVersionXXX(0),
mAgentStateSignal(),
mAgentState(kAgentStateUnknown),
mLastKnownNonErrorAgentState(kAgentStateUnknown)
@@ -180,7 +221,52 @@ 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::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 (navMeshPtr->hasNavMeshVersion(mNavMeshVersionXXX))
+ {
+ navMeshPtr->handleRefresh();
+ }
+ else
+ {
+ if (pRegion == NULL)
+ {
+ navMeshPtr->handleNavMeshNotEnabled();
+ }
+ else
+ {
+ std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion);
+ if (navMeshURL.empty())
+ {
+ navMeshPtr->handleNavMeshNotEnabled();
+ }
+ else
+ {
+ navMeshPtr->handleNavMeshStart(mNavMeshVersionXXX);
+ LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, mNavMeshVersionXXX, navMeshPtr);
+
+ LLSD postData;
+ LLHTTPClient::post(navMeshURL, postData, responder);
+ }
+ }
+ }
+}
+
+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);
}
@@ -305,6 +391,34 @@ LLPathfindingManager::ELinksetsRequestStatus LLPathfindingManager::requestSetLin
return status;
}
+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<LLUUID, LLPathfindingNavMeshPtr>(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));
@@ -378,6 +492,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);
@@ -395,18 +514,22 @@ 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() : "<null>") << "'" << llendl;
+ << ((pRegion != NULL) ? pRegion->getName() : "<null>") << "'" << llendl;
}
return capabilityURL;
@@ -418,6 +541,42 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const
}
//---------------------------------------------------------------------------
+// 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
+//---------------------------------------------------------------------------
+
+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
//---------------------------------------------------------------------------