Skip to content
Snippets Groups Projects
Commit b59a82fc authored by Todd Stinson's avatar Todd Stinson
Browse files

PATH-705: Creating a path to pull in the state of the current region navmesh...

PATH-705: Creating a path to pull in the state of the current region navmesh without downloading the navmesh binary.
parent 329b9852
No related branches found
No related tags found
No related merge requests found
...@@ -102,7 +102,7 @@ LLHTTPRegistration<LLAgentStateChangeNode> gHTTPRegistrationAgentStateChangeNode ...@@ -102,7 +102,7 @@ LLHTTPRegistration<LLAgentStateChangeNode> gHTTPRegistrationAgentStateChangeNode
class NavMeshStatusResponder : public LLHTTPClient::Responder class NavMeshStatusResponder : public LLHTTPClient::Responder
{ {
public: public:
NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion); NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion, bool pIsGetStatusOnly);
virtual ~NavMeshStatusResponder(); virtual ~NavMeshStatusResponder();
virtual void result(const LLSD &pContent); virtual void result(const LLSD &pContent);
...@@ -114,6 +114,7 @@ class NavMeshStatusResponder : public LLHTTPClient::Responder ...@@ -114,6 +114,7 @@ class NavMeshStatusResponder : public LLHTTPClient::Responder
std::string mCapabilityURL; std::string mCapabilityURL;
LLViewerRegion *mRegion; LLViewerRegion *mRegion;
LLUUID mRegionUUID; LLUUID mRegionUUID;
bool mIsGetStatusOnly;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -282,23 +283,30 @@ class CharactersResponder : public LLHTTPClient::Responder ...@@ -282,23 +283,30 @@ class CharactersResponder : public LLHTTPClient::Responder
LLPathfindingManager::LLPathfindingManager() LLPathfindingManager::LLPathfindingManager()
: LLSingleton<LLPathfindingManager>(), : LLSingleton<LLPathfindingManager>(),
mNavMeshMap(), mNavMeshMap(),
mShowNavMeshRebake(false), mCrossingSlot(),
mCrossingSlot() mAgentStateSignal(),
mNavMeshSlot()
{ {
} }
void LLPathfindingManager::onRegionBoundaryCrossed() 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(); displayNavMeshRebakePanel();
} }
LLPathfindingManager::~LLPathfindingManager() LLPathfindingManager::~LLPathfindingManager()
{ {
if (mCrossingSlot.connected()) quitSystem();
{
mCrossingSlot.disconnect();
}
} }
void LLPathfindingManager::initSystem() void LLPathfindingManager::initSystem()
...@@ -307,6 +315,40 @@ void LLPathfindingManager::initSystem() ...@@ -307,6 +315,40 @@ void LLPathfindingManager::initSystem()
{ {
LLPathingLib::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 bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const
...@@ -337,7 +379,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen ...@@ -337,7 +379,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen
return navMeshPtr->registerNavMeshListener(pNavMeshCallback); return navMeshPtr->registerNavMeshListener(pNavMeshCallback);
} }
void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, bool pIsGetStatusOnly)
{ {
LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion);
...@@ -348,7 +390,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) ...@@ -348,7 +390,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion)
else if (!pRegion->capabilitiesReceived()) else if (!pRegion->capabilitiesReceived())
{ {
navMeshPtr->handleNavMeshWaitForRegionLoad(); navMeshPtr->handleNavMeshWaitForRegionLoad();
pRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetNavMeshForRegion, this, _1)); pRegion->setCapabilitiesReceivedCallback(boost::bind(&LLPathfindingManager::handleDeferredGetNavMeshForRegion, this, _1, pIsGetStatusOnly));
} }
else if (!isPathfindingEnabledForRegion(pRegion)) else if (!isPathfindingEnabledForRegion(pRegion))
{ {
...@@ -359,7 +401,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) ...@@ -359,7 +401,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion)
std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion);
llassert(!navMeshStatusURL.empty()); llassert(!navMeshStatusURL.empty());
navMeshPtr->handleNavMeshCheckVersion(); navMeshPtr->handleNavMeshCheckVersion();
LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion); LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion, pIsGetStatusOnly);
LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder);
} }
} }
...@@ -518,13 +560,13 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt ...@@ -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(); LLViewerRegion *currentRegion = getCurrentRegion();
if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID)) if ((currentRegion != NULL) && (currentRegion->getRegionID() == pRegionUUID))
{ {
requestGetNavMeshForRegion(currentRegion); requestGetNavMeshForRegion(currentRegion, pIsGetStatusOnly);
} }
} }
...@@ -548,7 +590,7 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR ...@@ -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()); LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID());
...@@ -562,6 +604,10 @@ void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMesh ...@@ -562,6 +604,10 @@ void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMesh
{ {
navMeshPtr->handleRefresh(pNavMeshStatus); navMeshPtr->handleRefresh(pNavMeshStatus);
} }
else if (pIsGetStatusOnly)
{
navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus);
}
else else
{ {
sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus);
...@@ -613,11 +659,6 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion ...@@ -613,11 +659,6 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion
void LLPathfindingManager::requestGetAgentState() void LLPathfindingManager::requestGetAgentState()
{ {
if ( !mCrossingSlot.connected() )
{
mCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPathfindingManager::onRegionBoundaryCrossed, this));
}
std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() ); std::string agentStateURL = getAgentStateURLForCurrentRegion( getCurrentRegion() );
if ( !agentStateURL.empty() ) if ( !agentStateURL.empty() )
...@@ -696,6 +737,36 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const ...@@ -696,6 +737,36 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const
return gAgent.getRegion(); 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() void LLPathfindingManager::displayNavMeshRebakePanel()
{ {
LLView* rootp = LLUI::getRootView(); LLView* rootp = LLUI::getRootView();
...@@ -771,11 +842,12 @@ void LLPathfindingManager::handleAgentStateUpdate() ...@@ -771,11 +842,12 @@ void LLPathfindingManager::handleAgentStateUpdate()
// NavMeshStatusResponder // NavMeshStatusResponder
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion) NavMeshStatusResponder::NavMeshStatusResponder(const std::string &pCapabilityURL, LLViewerRegion *pRegion, bool pIsGetStatusOnly)
: LLHTTPClient::Responder(), : LLHTTPClient::Responder(),
mCapabilityURL(pCapabilityURL), mCapabilityURL(pCapabilityURL),
mRegion(pRegion), mRegion(pRegion),
mRegionUUID() mRegionUUID(),
mIsGetStatusOnly(pIsGetStatusOnly)
{ {
if (mRegion != NULL) if (mRegion != NULL)
{ {
...@@ -793,14 +865,14 @@ void NavMeshStatusResponder::result(const LLSD &pContent) ...@@ -793,14 +865,14 @@ void NavMeshStatusResponder::result(const LLSD &pContent)
llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl; llinfos << "STINSON DEBUG: Received requested NavMeshStatus: " << pContent << llendl;
#endif // XXX_STINSON_DEBUG_NAVMESH_ZONE #endif // XXX_STINSON_DEBUG_NAVMESH_ZONE
LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent); LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, pContent);
LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly);
} }
void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason) void NavMeshStatusResponder::error(U32 pStatus, const std::string& pReason)
{ {
llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl;
LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID);
LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion); LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -63,6 +63,7 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager> ...@@ -63,6 +63,7 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
virtual ~LLPathfindingManager(); virtual ~LLPathfindingManager();
void initSystem(); void initSystem();
void quitSystem();
bool isPathfindingEnabledForCurrentRegion() const; bool isPathfindingEnabledForCurrentRegion() const;
bool isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const; bool isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const;
...@@ -72,7 +73,7 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager> ...@@ -72,7 +73,7 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
bool isAllowViewTerrainProperties() const; bool isAllowViewTerrainProperties() const;
LLPathfindingNavMesh::navmesh_slot_t registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback); LLPathfindingNavMesh::navmesh_slot_t registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback);
void requestGetNavMeshForRegion(LLViewerRegion *pRegion); void requestGetNavMeshForRegion(LLViewerRegion *pRegion, bool pIsGetStatusOnly);
typedef U32 request_id_t; typedef U32 request_id_t;
typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingObjectListPtr)> object_request_callback_t; typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingObjectListPtr)> object_request_callback_t;
...@@ -89,9 +90,6 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager> ...@@ -89,9 +90,6 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
typedef boost::signals2::signal< void () > agent_state_signal_t; typedef boost::signals2::signal< void () > agent_state_signal_t;
typedef boost::signals2::connection agent_state_slot_t; typedef boost::signals2::connection agent_state_slot_t;
agent_state_slot_t mCrossingSlot;
agent_state_signal_t mAgentStateSignal;
agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback); agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback);
void handleNavMeshRebakeResult( const LLSD &pContent ); void handleNavMeshRebakeResult( const LLSD &pContent );
...@@ -105,11 +103,11 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager> ...@@ -105,11 +103,11 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
private: private:
void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus); void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus);
void handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID); void handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID, bool pIsGetStatusOnly);
void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const;
void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion); void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly);
void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus);
void handleAgentStateUpdate(); void handleAgentStateUpdate();
...@@ -127,17 +125,17 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager> ...@@ -127,17 +125,17 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
std::string getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const; std::string getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const;
LLViewerRegion *getCurrentRegion() const; LLViewerRegion *getCurrentRegion() const;
void handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshRequestStatus pRequestStatus, const LLPathfindingNavMeshStatus &pNavMeshStatus);
void displayNavMeshRebakePanel(); void displayNavMeshRebakePanel();
void hideNavMeshRebakePanel(); void hideNavMeshRebakePanel();
void handleAgentStateResult(const LLSD &pContent ); void handleAgentStateResult(const LLSD &pContent );
void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL); void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL);
NavMeshMap mNavMeshMap;
NavMeshMap mNavMeshMap; agent_state_slot_t mCrossingSlot;
agent_state_signal_t mAgentStateSignal;
//prep#stinson# set this flag instead of directly showing/hiding the rebake panel LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot;
BOOL mShowNavMeshRebake;
}; };
......
...@@ -393,7 +393,7 @@ void LLPathfindingNavMeshZone::NavMeshLocation::refresh() ...@@ -393,7 +393,7 @@ void LLPathfindingNavMeshZone::NavMeshLocation::refresh()
else else
{ {
llassert(mRegionUUID == region->getRegionID()); llassert(mRegionUUID == region->getRegionID());
LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(region); LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(region, false);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment