summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorTodd Stinson <stinson@lindenlab.com>2012-06-19 20:09:35 -0700
committerTodd Stinson <stinson@lindenlab.com>2012-06-19 20:09:35 -0700
commit37e6aa609f2ccd49e6225bad5186ec6ba49b9cb7 (patch)
tree5f2020a8e3b81a65884486b18875b24acf1a4a50 /indra
parentb98cbe00fe885cebebe1ec5fd123c969b5d2c29f (diff)
PATH-723: Pulling in whether the user has access to view the rebake navmesh button or not.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpanelnavmeshrebake.cpp24
-rw-r--r--indra/newview/llpanelnavmeshrebake.h12
-rw-r--r--indra/newview/llpathfindingmanager.cpp109
-rw-r--r--indra/newview/llpathfindingmanager.h19
-rw-r--r--indra/newview/llstartup.cpp1
5 files changed, 102 insertions, 63 deletions
diff --git a/indra/newview/llpanelnavmeshrebake.cpp b/indra/newview/llpanelnavmeshrebake.cpp
index 0cc0d6c50a..283d6dfff5 100644
--- a/indra/newview/llpanelnavmeshrebake.cpp
+++ b/indra/newview/llpanelnavmeshrebake.cpp
@@ -76,6 +76,12 @@ BOOL LLPanelNavMeshRebake::postBuild()
mRegionCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPanelNavMeshRebake::handleRegionBoundaryCrossed, this));
}
+ if (!mAgentStateSlot.connected())
+ {
+ mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLPanelNavMeshRebake::handleAgentState, this, _1));
+ }
+ LLPathfindingManager::getInstance()->requestGetAgentState();
+
return LLPanel::postBuild();
}
@@ -98,10 +104,12 @@ BOOL LLPanelNavMeshRebake::handleToolTip( S32 x, S32 y, MASK mask )
}
LLPanelNavMeshRebake::LLPanelNavMeshRebake()
- : mNavMeshRebakeButton( NULL ),
+ : mCanRebakeRegion(TRUE),
+ mNavMeshRebakeButton( NULL ),
mNavMeshBakingButton( NULL ),
mNavMeshSlot(),
- mRegionCrossingSlot()
+ mRegionCrossingSlot(),
+ mAgentStateSlot()
{
// make sure we have the only instance of this class
static bool b = true;
@@ -130,15 +138,16 @@ void LLPanelNavMeshRebake::setMode(ERebakeNavMeshMode pRebakeNavMeshMode)
void LLPanelNavMeshRebake::onNavMeshRebakeClick()
{
-#if 0
- mNavMeshRebakeButton->setVisible( FALSE );
- mNavMeshBakingButton->setVisible( TRUE );
- mNavMeshBakingButton->setForcePressedState( TRUE );
-#endif
setMode(kRebakeNavMesh_RequestSent);
LLPathfindingManager::getInstance()->requestRebakeNavMesh(boost::bind(&LLPanelNavMeshRebake::handleRebakeNavMeshResponse, this, _1));
}
+void LLPanelNavMeshRebake::handleAgentState(BOOL pCanRebakeRegion)
+{
+ mCanRebakeRegion = pCanRebakeRegion;
+ llinfos << "STINSON DEBUG: canRebakeRegion => " << (pCanRebakeRegion ? "TRUE" : "FALSE") << llendl;
+}
+
void LLPanelNavMeshRebake::handleRebakeNavMeshResponse(bool pResponseStatus)
{
setMode(pResponseStatus ? kRebakeNavMesh_NotAvailable : kRebakeNavMesh_Available);
@@ -176,6 +185,7 @@ void LLPanelNavMeshRebake::handleNavMeshStatus(const LLPathfindingNavMeshStatus
void LLPanelNavMeshRebake::handleRegionBoundaryCrossed()
{
createNavMeshStatusListenerForCurrentRegion();
+ LLPathfindingManager::getInstance()->requestGetAgentState();
}
void LLPanelNavMeshRebake::createNavMeshStatusListenerForCurrentRegion()
diff --git a/indra/newview/llpanelnavmeshrebake.h b/indra/newview/llpanelnavmeshrebake.h
index 2c573f4c04..f4653ea458 100644
--- a/indra/newview/llpanelnavmeshrebake.h
+++ b/indra/newview/llpanelnavmeshrebake.h
@@ -33,6 +33,7 @@
#include "llhandle.h"
#include "llpanel.h"
+#include "llpathfindingmanager.h"
#include "llpathfindingnavmesh.h"
class LLButton;
@@ -72,6 +73,7 @@ private:
void onNavMeshRebakeClick();
+ void handleAgentState(BOOL pCanRebakeRegion);
void handleRebakeNavMeshResponse(bool pResponseStatus);
void handleNavMeshStatus(const LLPathfindingNavMeshStatus &pNavMeshStatus);
void handleRegionBoundaryCrossed();
@@ -80,10 +82,12 @@ private:
void updatePosition();
- LLButton* mNavMeshRebakeButton;
- LLButton* mNavMeshBakingButton;
- LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot;
- boost::signals2::connection mRegionCrossingSlot;
+ BOOL mCanRebakeRegion;
+ LLButton* mNavMeshRebakeButton;
+ LLButton* mNavMeshBakingButton;
+ LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot;
+ boost::signals2::connection mRegionCrossingSlot;
+ LLPathfindingManager::agent_state_slot_t mAgentStateSlot;
};
#endif //LL_NAVMESHREBAKE_H
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);
}
diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h
index f77877af08..38e100f74b 100644
--- a/indra/newview/llpathfindingmanager.h
+++ b/indra/newview/llpathfindingmanager.h
@@ -49,6 +49,8 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
{
friend class LLNavMeshSimStateChangeNode;
friend class NavMeshStatusResponder;
+ friend class LLAgentStateChangeNode;
+ friend class AgentStateResponder;
public:
typedef std::map<LLUUID, LLPathfindingNavMeshPtr> NavMeshMap;
@@ -83,12 +85,9 @@ public:
void requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
- friend class LLAgentStateChangeNode;
- friend class AgentStateResponder;
-
- typedef boost::function< void () > agent_state_callback_t;
- typedef boost::signals2::signal< void () > agent_state_signal_t;
- typedef boost::signals2::connection agent_state_slot_t;
+ typedef boost::function<void (BOOL)> agent_state_callback_t;
+ typedef boost::signals2::signal<void (BOOL)> agent_state_signal_t;
+ typedef boost::signals2::connection agent_state_slot_t;
agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback);
void requestGetAgentState();
@@ -101,6 +100,7 @@ protected:
private:
void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus);
+ void handleDeferredGetAgentStateForRegion(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 handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
@@ -108,7 +108,7 @@ private:
void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly);
void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus);
- void handleAgentStateUpdate();
+ void handleAgentState(BOOL pCanRebakeRegion);
LLPathfindingNavMeshPtr getNavMeshForRegion(const LLUUID &pRegionUUID);
LLPathfindingNavMeshPtr getNavMeshForRegion(LLViewerRegion *pRegion);
@@ -119,14 +119,11 @@ private:
std::string getObjectLinksetsURLForCurrentRegion() const;
std::string getTerrainLinksetsURLForCurrentRegion() const;
std::string getCharactersURLForCurrentRegion() const;
- std::string getAgentStateURLForCurrentRegion(LLViewerRegion *pRegion) const;
+ std::string getAgentStateURLForRegion(LLViewerRegion *pRegion) const;
std::string getCapabilityURLForCurrentRegion(const std::string &pCapabilityName) const;
std::string getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const;
LLViewerRegion *getCurrentRegion() const;
- void handleAgentStateResult(const LLSD &pContent );
- void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL);
-
NavMeshMap mNavMeshMap;
agent_state_signal_t mAgentStateSignal;
};
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index b995a45a75..a2b4aec201 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2167,7 +2167,6 @@ bool idle_startup()
llassert(LLPathfindingManager::getInstance() != NULL);
LLPathfindingManager::getInstance()->initSystem();
- LLPathfindingManager::getInstance()->requestGetAgentState();
return TRUE;
}