diff options
-rw-r--r-- | indra/newview/llpanelnavmeshrebake.cpp | 82 | ||||
-rw-r--r-- | indra/newview/llpanelnavmeshrebake.h | 38 | ||||
-rw-r--r-- | indra/newview/llpathfindingmanager.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llpathfindingmanager.h | 4 |
4 files changed, 112 insertions, 24 deletions
diff --git a/indra/newview/llpanelnavmeshrebake.cpp b/indra/newview/llpanelnavmeshrebake.cpp index e1c1548de1..608bfbf776 100644 --- a/indra/newview/llpanelnavmeshrebake.cpp +++ b/indra/newview/llpanelnavmeshrebake.cpp @@ -30,17 +30,23 @@ #include "llpanelnavmeshrebake.h" #include <boost/bind.hpp> +#include <boost/signals2.hpp> +#include "llagent.h" #include "llbutton.h" +#include "llenvmanager.h" #include "llhandle.h" #include "llhints.h" #include "llpanel.h" #include "llpathfindingmanager.h" +#include "llpathfindingnavmesh.h" +#include "llpathfindingnavmeshstatus.h" #include "lltoolbar.h" #include "lltoolbarview.h" #include "lltoolmgr.h" #include "lltooltip.h" #include "llview.h" +#include "llviewerregion.h" LLPanelNavMeshRebake* LLPanelNavMeshRebake::getInstance() { @@ -48,13 +54,6 @@ LLPanelNavMeshRebake* LLPanelNavMeshRebake::getInstance() return panel; } -void LLPanelNavMeshRebake::setMode(ERebakeNavMeshMode pRebakeNavMeshMode) -{ - mNavMeshRebakeButton->setVisible(pRebakeNavMeshMode == kRebakeNavMesh_Available); - mNavMeshBakingButton->setVisible(pRebakeNavMeshMode == kRebakeNavMesh_RequestSent); - setVisible(pRebakeNavMeshMode != kRebakeNavMesh_NotAvailable); -} - BOOL LLPanelNavMeshRebake::postBuild() { //Rebake initiated @@ -68,6 +67,13 @@ BOOL LLPanelNavMeshRebake::postBuild() setMode(kRebakeNavMesh_Default); + createNavMeshStatusListenerForCurrentRegion(); + + if ( !mRegionCrossingSlot.connected() ) + { + mRegionCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLPanelNavMeshRebake::handleRegionBoundaryCrossed, this)); + } + return LLPanel::postBuild(); } @@ -91,7 +97,9 @@ BOOL LLPanelNavMeshRebake::handleToolTip( S32 x, S32 y, MASK mask ) LLPanelNavMeshRebake::LLPanelNavMeshRebake() : mNavMeshRebakeButton( NULL ), - mNavMeshBakingButton( NULL ) + mNavMeshBakingButton( NULL ), + mNavMeshSlot(), + mRegionCrossingSlot() { // make sure we have the only instance of this class static bool b = true; @@ -111,6 +119,13 @@ LLPanelNavMeshRebake* LLPanelNavMeshRebake::getPanel() return panel; } +void LLPanelNavMeshRebake::setMode(ERebakeNavMeshMode pRebakeNavMeshMode) +{ + mNavMeshRebakeButton->setVisible(pRebakeNavMeshMode == kRebakeNavMesh_Available); + mNavMeshBakingButton->setVisible(pRebakeNavMeshMode == kRebakeNavMesh_RequestSent); + setVisible(pRebakeNavMeshMode != kRebakeNavMesh_NotAvailable); +} + void LLPanelNavMeshRebake::onNavMeshRebakeClick() { #if 0 @@ -121,6 +136,55 @@ void LLPanelNavMeshRebake::onNavMeshRebakeClick() LLPathfindingManager::getInstance()->triggerNavMeshRebuild(); } +void LLPanelNavMeshRebake::handleNavMeshStatus(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + ERebakeNavMeshMode rebakeNavMeshMode = kRebakeNavMesh_Default; + if (pNavMeshStatus.isValid()) + { + switch (pNavMeshStatus.getStatus()) + { + case LLPathfindingNavMeshStatus::kPending : + rebakeNavMeshMode = kRebakeNavMesh_Available; + break; + case LLPathfindingNavMeshStatus::kBuilding : + rebakeNavMeshMode = kRebakeNavMesh_NotAvailable; + break; + case LLPathfindingNavMeshStatus::kComplete : + rebakeNavMeshMode = kRebakeNavMesh_NotAvailable; + break; + case LLPathfindingNavMeshStatus::kRepending : + rebakeNavMeshMode = kRebakeNavMesh_Available; + break; + default : + rebakeNavMeshMode = kRebakeNavMesh_Default; + llassert(0); + break; + } + } + + setMode(rebakeNavMeshMode); +} + +void LLPanelNavMeshRebake::handleRegionBoundaryCrossed() +{ + createNavMeshStatusListenerForCurrentRegion(); +} + +void LLPanelNavMeshRebake::createNavMeshStatusListenerForCurrentRegion() +{ + if (mNavMeshSlot.connected()) + { + mNavMeshSlot.disconnect(); + } + + LLViewerRegion *currentRegion = gAgent.getRegion(); + if (currentRegion != NULL) + { + mNavMeshSlot = LLPathfindingManager::getInstance()->registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLPanelNavMeshRebake::handleNavMeshStatus, this, _2)); + LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(currentRegion, true); + } +} + void LLPanelNavMeshRebake::updatePosition() { S32 y_pos = 0; @@ -143,7 +207,7 @@ void LLPanelNavMeshRebake::updatePosition() panel_ssf_container->setOrigin(0, y_pos); } - S32 x_pos = bottom_tb_center-getRect().getWidth()/2 - left_tb_width + 113 /*width of stand/fly button */ + 10; + S32 x_pos = bottom_tb_center-getRect().getWidth()/2 - left_tb_width + 113 /* width of stand/fly button */ + 10 /* margin */; setOrigin( x_pos, 0); } diff --git a/indra/newview/llpanelnavmeshrebake.h b/indra/newview/llpanelnavmeshrebake.h index 0a3f3bea93..39af298aa8 100644 --- a/indra/newview/llpanelnavmeshrebake.h +++ b/indra/newview/llpanelnavmeshrebake.h @@ -28,10 +28,15 @@ #ifndef LL_NAVMESHREBAKE_H #define LL_NAVMESHREBAKE_H +#include <boost/bind.hpp> +#include <boost/signals2.hpp> + #include "llhandle.h" #include "llpanel.h" +#include "llpathfindingnavmesh.h" class LLButton; +class LLPathfindingNavMeshStatus; class LLView; class LLPanelNavMeshRebake : public LLPanel @@ -40,19 +45,8 @@ class LLPanelNavMeshRebake : public LLPanel LOG_CLASS(LLPanelNavMeshRebake); public: - - typedef enum - { - kRebakeNavMesh_Available, - kRebakeNavMesh_RequestSent, - kRebakeNavMesh_NotAvailable, - kRebakeNavMesh_Default = kRebakeNavMesh_NotAvailable - } ERebakeNavMeshMode; - static LLPanelNavMeshRebake* getInstance(); - void setMode(ERebakeNavMeshMode pRebakeNavMeshMode); - virtual BOOL postBuild(); virtual void draw(); @@ -61,16 +55,34 @@ public: protected: private: + typedef enum + { + kRebakeNavMesh_Available, + kRebakeNavMesh_RequestSent, + kRebakeNavMesh_NotAvailable, + kRebakeNavMesh_Default = kRebakeNavMesh_NotAvailable + } ERebakeNavMeshMode; + LLPanelNavMeshRebake(); virtual ~LLPanelNavMeshRebake(); static LLPanelNavMeshRebake* getPanel(); + void setMode(ERebakeNavMeshMode pRebakeNavMeshMode); + void onNavMeshRebakeClick(); + + void handleNavMeshStatus(const LLPathfindingNavMeshStatus &pNavMeshStatus); + void handleRegionBoundaryCrossed(); + + void createNavMeshStatusListenerForCurrentRegion(); + void updatePosition(); - LLButton* mNavMeshRebakeButton; - LLButton* mNavMeshBakingButton; + LLButton* mNavMeshRebakeButton; + LLButton* mNavMeshBakingButton; + LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot; + boost::signals2::connection mRegionCrossingSlot; }; #endif //LL_NAVMESHREBAKE_H diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index d4c689e30d..6dffe2f459 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -54,7 +54,9 @@ #include "llweb.h" #include "llpanelnavmeshrebake.h" #include "llenvmanager.h" +#if 0 #include "llstartup.h" +#endif #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -670,7 +672,9 @@ void LLPathfindingManager::requestGetAgentState() void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent) { +#if 0 displayNavMeshRebakePanel(); +#endif } void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL) @@ -755,7 +759,6 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq break; case LLPathfindingNavMeshStatus::kComplete : llinfos << "STINSON DEBUG: navmesh status is kComplete" << llendl; - displayNavMeshRebakePanel(); break; case LLPathfindingNavMeshStatus::kRepending : llinfos << "STINSON DEBUG: navmesh status is kRepending" << llendl; @@ -768,6 +771,7 @@ void LLPathfindingManager::handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshReq } } +#if 0 void LLPathfindingManager::displayNavMeshRebakePanel() { LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_Available); @@ -777,6 +781,7 @@ void LLPathfindingManager::hideNavMeshRebakePanel() { LLPanelNavMeshRebake::getInstance()->setMode(LLPanelNavMeshRebake::kRebakeNavMesh_NotAvailable); } +#endif void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) { @@ -785,7 +790,10 @@ void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::stri void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) { + +#if 0 hideNavMeshRebakePanel(); +#endif } void LLPathfindingManager::triggerNavMeshRebuild() @@ -830,7 +838,9 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c void LLPathfindingManager::handleAgentStateUpdate() { //Don't trigger if we are still loading in +#if 0 if ( LLStartUp::getStartupState() == STATE_STARTED) { displayNavMeshRebakePanel(); } +#endif } //--------------------------------------------------------------------------- diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index dafe75216f..21467a0cf8 100644 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -97,7 +97,6 @@ public: void triggerNavMeshRebuild(); void onRegionBoundaryCrossed(); void requestGetAgentState(); - void hideNavMeshRebakePanel(); protected: @@ -128,7 +127,10 @@ private: void handleNavMeshStatus(LLPathfindingNavMesh::ENavMeshRequestStatus pRequestStatus, const LLPathfindingNavMeshStatus &pNavMeshStatus); +#if 0 void displayNavMeshRebakePanel(); + void hideNavMeshRebakePanel(); +#endif void handleAgentStateResult(const LLSD &pContent ); void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL); |