From 4e9d9ebe8a480ffdd9e069388c1e9845477f5f66 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 4 Apr 2012 17:19:57 -0700 Subject: PATH-445,PATH-452: Adding functionality to reload the navmesh on region boundary crossing. Also, correcting how the region boundary crossing is detected to make it more accurate. --- indra/newview/llfloaterpathfindingconsole.cpp | 46 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'indra/newview/llfloaterpathfindingconsole.cpp') diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp index 1f73f10b9b..d1606cbd49 100644 --- a/indra/newview/llfloaterpathfindingconsole.cpp +++ b/indra/newview/llfloaterpathfindingconsole.cpp @@ -48,6 +48,7 @@ #include "llviewercontrol.h" #include "llpathfindingnavmeshzone.h" #include "llpathfindingmanager.h" +#include "llenvmanager.h" #include "LLPathingLib.h" @@ -157,7 +158,6 @@ BOOL LLFloaterPathfindingConsole::postBuild() void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) { LLFloater::onOpen(pKey); - setHeartBeat( true ); //make sure we have a pathing system if ( !LLPathingLib::getInstance() ) { @@ -177,10 +177,7 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) } mIsNavMeshUpdating = false; - mNavMeshZone.initialize(); - - mNavMeshZone.enable(); - mNavMeshZone.refresh(); + initializeNavMeshZoneForCurrentRegion(); } if (!mAgentStateSlot.connected()) @@ -188,12 +185,22 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLFloaterPathfindingConsole::onAgentStateCB, this, _1)); } + if (!mRegionBoundarySlot.connected()) + { + mRegionBoundarySlot = LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterPathfindingConsole::onRegionBoundaryCross, this)); + } + setAgentState(LLPathfindingManager::getInstance()->getAgentState()); updatePathTestStatus(); } void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) { + if (mRegionBoundarySlot.connected()) + { + mRegionBoundarySlot.disconnect(); + } + if (mAgentStateSlot.connected()) { mAgentStateSlot.disconnect(); @@ -210,7 +217,6 @@ void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) } LLFloater::onClose(pIsAppQuitting); - setHeartBeat( false ); setConsoleState(kConsoleStateUnknown); //Reset all the checkboxes to default mShowNavMeshCheckBox->set( false ); @@ -529,11 +535,11 @@ LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed) mNavMeshZone(), mIsNavMeshUpdating(false), mAgentStateSlot(), + mRegionBoundarySlot(), mConsoleState(kConsoleStateUnknown), mPathData(), mHasStartPoint(false), - mHasEndPoint(false), - mHeartBeat( false ) + mHasEndPoint(false) { mSelfHandle.bind(this); } @@ -673,6 +679,11 @@ void LLFloaterPathfindingConsole::onAgentStateCB(LLPathfindingManager::EAgentSta setAgentState(pAgentState); } +void LLFloaterPathfindingConsole::onRegionBoundaryCross() +{ + initializeNavMeshZoneForCurrentRegion(); +} + void LLFloaterPathfindingConsole::setConsoleState(EConsoleState pConsoleState) { mConsoleState = pConsoleState; @@ -868,6 +879,14 @@ std::string LLFloaterPathfindingConsole::getSimulatorStatusText() const return simulatorStatusText; } +void LLFloaterPathfindingConsole::initializeNavMeshZoneForCurrentRegion() +{ + mNavMeshZone.disable(); + mNavMeshZone.initialize(); + mNavMeshZone.enable(); + mNavMeshZone.refresh(); +} + void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentState pAgentState) { switch (LLPathfindingManager::getInstance()->getLastKnownNonErrorAgentState()) @@ -1001,15 +1020,6 @@ U32 LLFloaterPathfindingConsole::getRenderShapeFlags() return mShapeRenderFlags; } -void LLFloaterPathfindingConsole::regionCrossingOccured() -{ - std::string statusText(""); - LLStyle::Params styleParams; - styleParams.color = LLUIColorTable::instance().getColor("DrYellow"); - statusText = getString("navmesh_update_needed"); - mPathfindingViewerStatus->setText((LLStringExplicit)statusText, styleParams); -} - void LLFloaterPathfindingConsole::fillInColorsForNavMeshVisualization() { @@ -1070,5 +1080,3 @@ void LLFloaterPathfindingConsole::fillInColorsForNavMeshVisualization() LLPathingLib::getInstance()->setNavMeshColors( colors ); } - - -- cgit v1.2.3