diff options
Diffstat (limited to 'indra/newview/llfloaterpathfindingconsole.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingconsole.cpp | 333 |
1 files changed, 180 insertions, 153 deletions
diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp index 5ac79668d2..6824e629c9 100644 --- a/indra/newview/llfloaterpathfindingconsole.cpp +++ b/indra/newview/llfloaterpathfindingconsole.cpp @@ -33,6 +33,7 @@ #include "llsd.h"
#include "llhandle.h"
#include "llagent.h"
+#include "llpanel.h"
#include "llbutton.h"
#include "llradiogroup.h"
#include "llsliderctrl.h"
@@ -40,12 +41,12 @@ #include "lltextbase.h"
#include "lltabcontainer.h"
#include "llcombobox.h"
-#include "llnavmeshstation.h"
#include "llfloaterreg.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "llviewercamera.h"
#include "llviewercontrol.h"
+#include "llpathfindingnavmeshzone.h"
#include "llpathfindingmanager.h"
#include "LLPathingLib.h"
@@ -63,9 +64,6 @@ #define XUI_TEST_TAB_INDEX 1
-const int CURRENT_REGION = 99;
-const int MAX_OBSERVERS = 10;
-
LLHandle<LLFloaterPathfindingConsole> LLFloaterPathfindingConsole::sInstanceHandle;
//---------------------------------------------------------------------------
@@ -104,6 +102,12 @@ BOOL LLFloaterPathfindingConsole::postBuild() mEditTestTabContainer = findChild<LLTabContainer>("edit_test_tab_container");
llassert(mEditTestTabContainer != NULL);
+ mEditTab = findChild<LLPanel>("edit_panel");
+ llassert(mEditTab != NULL);
+
+ mTestTab = findChild<LLPanel>("test_panel");
+ llassert(mTestTab != NULL);
+
mUnfreezeLabel = findChild<LLTextBase>("unfreeze_label");
llassert(mUnfreezeLabel != NULL);
@@ -157,87 +161,27 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) }
if ( LLPathingLib::getInstance() == NULL )
{
- std::string str = getString("navmesh_library_not_implemented");
- LLStyle::Params styleParams;
- styleParams.color = LLUIColorTable::instance().getColor("DrYellow");
- mPathfindingStatus->setText((LLStringExplicit)str, styleParams);
- llwarns <<"Errror: cannout find pathing library implementation."<<llendl;
+ setConsoleState(kConsoleStateLibraryNotImplemented);
+ llwarns <<"Errror: cannot find pathing library implementation."<<llendl;
}
else
{
- LLPathingLib::getInstance()->cleanupResidual();
-
- mCurrentMDO = 0;
- mNavMeshCnt = 0;
-
- //make sure the region is essentially enabled for navmesh support
- std::string capability = "RetrieveNavMeshSrc";
-
- LLViewerRegion* pCurrentRegion = gAgent.getRegion();
- std::vector<LLViewerRegion*> regions;
- regions.push_back( pCurrentRegion );
- std::vector<int> shiftDirections;
- shiftDirections.push_back( CURRENT_REGION );
-
- mNeighboringRegion = gSavedSettings.getU32("RetrieveNeighboringRegion");
- if ( mNeighboringRegion != CURRENT_REGION )
- {
- //User wants to pull in a neighboring region
- std::vector<S32> availableRegions;
- pCurrentRegion->getNeighboringRegionsStatus( availableRegions );
- //Is the desired region in the available list
- std::vector<S32>::iterator foundElem = std::find(availableRegions.begin(),availableRegions.end(),mNeighboringRegion);
- if ( foundElem != availableRegions.end() )
- {
- LLViewerRegion* pCurrentRegion = gAgent.getRegion();
- std::vector<LLViewerRegion*> regionPtrs;
- pCurrentRegion->getNeighboringRegions( regionPtrs );
- regions.push_back( regionPtrs[mNeighboringRegion] );
- shiftDirections.push_back( mNeighboringRegion );
- }
- }
-
-
- //If the navmesh shift ops and the total region counts do not match - use the current region, only.
- if ( shiftDirections.size() != regions.size() )
+ if (!mNavMeshZoneSlot.connected())
{
- shiftDirections.clear();regions.clear();
- regions.push_back( pCurrentRegion );
- shiftDirections.push_back( CURRENT_REGION );
+ mNavMeshZoneSlot = mNavMeshZone.registerNavMeshZoneListener(boost::bind(&LLFloaterPathfindingConsole::onNavMeshZoneCB, this, _1));
}
- int regionCnt = regions.size();
- mNavMeshCnt = regionCnt;
+ mNavMeshZone.initialize();
- for ( int i=0; i<regionCnt; ++i )
- {
- std::string url = regions[i]->getCapability( capability );
-
- if ( !url.empty() )
- {
- std::string str = getString("navmesh_fetch_inprogress");
- mPathfindingStatus->setText((LLStringExplicit)str);
- LLNavMeshStation::getInstance()->setNavMeshDownloadURL( url );
- int dir = shiftDirections[i];
- LLNavMeshStation::getInstance()->downloadNavMeshSrc( mNavMeshDownloadObserver[mCurrentMDO].getObserverHandle(), dir );
- ++mCurrentMDO;
- }
- else
- {
- --mNavMeshCnt;
- std::string str = getString("navmesh_region_not_enabled");
- LLStyle::Params styleParams;
- styleParams.color = LLUIColorTable::instance().getColor("DrYellow");
- mPathfindingStatus->setText((LLStringExplicit)str, styleParams);
- llinfos<<"Region has does not required caps of type ["<<capability<<"]"<<llendl;
- }
- }
+ mNavMeshZone.enable();
+ mNavMeshZone.refresh();
}
if (!mAgentStateSlot.connected())
{
- LLPathfindingManager::getInstance()->registerAgentStateSignal(boost::bind(&LLFloaterPathfindingConsole::onAgentStateCB, this, _1));
+ mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLFloaterPathfindingConsole::onAgentStateCB, this, _1));
}
+
setAgentState(LLPathfindingManager::getInstance()->getAgentState());
updatePathTestStatus();
}
@@ -248,9 +192,20 @@ void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) {
mAgentStateSlot.disconnect();
}
- if ( LLPathingLib::getInstance() ) { LLPathingLib::getInstance()->cleanupResidual(); }
+
+ if (mNavMeshZoneSlot.connected())
+ {
+ mNavMeshZoneSlot.disconnect();
+ }
+
+ if (LLPathingLib::getInstance() != NULL)
+ {
+ mNavMeshZone.disable();
+ }
+
LLFloater::onClose(pIsAppQuitting);
setHeartBeat( false );
+ setConsoleState(kConsoleStateUnknown);
}
BOOL LLFloaterPathfindingConsole::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down)
@@ -496,24 +451,6 @@ void LLFloaterPathfindingConsole::setCharacterType(ECharacterType pCharacterType mCharacterTypeRadioGroup->setValue(radioGroupValue);
}
-void LLFloaterPathfindingConsole::setHasNavMeshReceived()
-{
- std::string str = getString("navmesh_fetch_complete_available");
- mPathfindingStatus->setText((LLStringExplicit)str);
- //check to see if all regions are done loading and they are then stitch the navmeshes together
- --mNavMeshCnt;
- if ( mNavMeshCnt == 0 )
- {
- LLPathingLib::getInstance()->stitchNavMeshes( gSavedSettings.getBOOL("EnableVBOForNavMeshVisualization") );
- }
-}
-
-void LLFloaterPathfindingConsole::setHasNoNavMesh()
-{
- std::string str = getString("navmesh_fetch_complete_none");
- mPathfindingStatus->setText((LLStringExplicit)str);
-}
-
LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed)
: LLFloater(pSeed),
mSelfHandle(),
@@ -527,6 +464,8 @@ LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed) mPathfindingStatus(NULL),
mViewCharactersButton(NULL),
mEditTestTabContainer(NULL),
+ mEditTab(NULL),
+ mTestTab(NULL),
mUnfreezeLabel(NULL),
mUnfreezeButton(NULL),
mLinksetsLabel(NULL),
@@ -537,38 +476,22 @@ LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed) mCharacterTypeRadioGroup(NULL),
mPathTestingStatus(NULL),
mClearPathButton(NULL),
+ mNavMeshZoneSlot(),
+ mNavMeshZone(),
mAgentStateSlot(),
- mNavMeshCnt(0),
+ mConsoleState(kConsoleStateUnknown),
+ mPathData(),
mHasStartPoint(false),
mHasEndPoint(false),
- mNeighboringRegion( CURRENT_REGION ),
mHeartBeat( false )
{
mSelfHandle.bind(this);
-
- for (int i=0;i<MAX_OBSERVERS;++i)
- {
- mNavMeshDownloadObserver[i].setPathfindingConsole(this);
- }
}
LLFloaterPathfindingConsole::~LLFloaterPathfindingConsole()
{
}
-std::string LLFloaterPathfindingConsole::getCurrentRegionCapabilityURL() const
-{
- std::string capURL("");
-
- LLViewerRegion *region = gAgent.getRegion();
- if (region != NULL)
- {
- capURL = region->getCapability("RetrieveNavMeshSrc");
- }
-
- return capURL;
-}
-
void LLFloaterPathfindingConsole::onShowWalkabilitySet()
{
switch (getRenderHeatmapType())
@@ -686,17 +609,51 @@ void LLFloaterPathfindingConsole::onClearPathClicked() updatePathTestStatus();
}
+void LLFloaterPathfindingConsole::onNavMeshZoneCB(LLPathfindingNavMeshZone::ENavMeshZoneRequestStatus pNavMeshZoneRequestStatus)
+{
+ switch (pNavMeshZoneRequestStatus)
+ {
+ case LLPathfindingNavMeshZone::kNavMeshZoneRequestUnknown :
+ setConsoleState(kConsoleStateUnknown);
+ break;
+ case LLPathfindingNavMeshZone::kNavMeshZoneRequestStarted :
+ setConsoleState(kConsoleStateDownloading);
+ break;
+ case LLPathfindingNavMeshZone::kNavMeshZoneRequestCompleted :
+ setConsoleState(kConsoleStateHasNavMesh);
+ break;
+ case LLPathfindingNavMeshZone::kNavMeshZoneRequestNotEnabled :
+ setConsoleState(kConsoleStateRegionNotEnabled);
+ break;
+ case LLPathfindingNavMeshZone::kNavMeshZoneRequestError :
+ setConsoleState(kConsoleStateError);
+ break;
+ default:
+ setConsoleState(kConsoleStateUnknown);
+ llassert(0);
+ break;
+ }
+}
+
void LLFloaterPathfindingConsole::onAgentStateCB(LLPathfindingManager::EAgentState pAgentState)
{
setAgentState(pAgentState);
}
-void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentState pAgentState)
+void LLFloaterPathfindingConsole::setConsoleState(EConsoleState pConsoleState)
{
- switch (pAgentState)
+ mConsoleState = pConsoleState;
+ updateControlsOnConsoleState();
+ updateStatusOnConsoleState();
+}
+
+void LLFloaterPathfindingConsole::updateControlsOnConsoleState()
+{
+ switch (mConsoleState)
{
- case LLPathfindingManager::kAgentStateUnknown :
- case LLPathfindingManager::kAgentStateNotEnabled :
+ case kConsoleStateUnknown :
+ case kConsoleStateLibraryNotImplemented :
+ case kConsoleStateRegionNotEnabled :
mShowNavMeshCheckBox->setEnabled(FALSE);
mShowNavMeshWalkabilityComboBox->setEnabled(FALSE);
mShowWalkablesCheckBox->setEnabled(FALSE);
@@ -705,16 +662,34 @@ void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentStat mShowExclusionVolumesCheckBox->setEnabled(FALSE);
mShowWorldCheckBox->setEnabled(FALSE);
mViewCharactersButton->setEnabled(FALSE);
- mEditTestTabContainer->setEnabled(FALSE);
+ mEditTestTabContainer->selectTab(0);
+ mTestTab->setEnabled(FALSE);
mCharacterWidthSlider->setEnabled(FALSE);
mCharacterTypeRadioGroup->setEnabled(FALSE);
mClearPathButton->setEnabled(FALSE);
-
+ mHasStartPoint = false;
+ mHasEndPoint = false;
+ break;
+ case kConsoleStateDownloading :
+ case kConsoleStateError :
+ mShowNavMeshCheckBox->setEnabled(FALSE);
+ mShowNavMeshWalkabilityComboBox->setEnabled(FALSE);
+ mShowWalkablesCheckBox->setEnabled(FALSE);
+ mShowStaticObstaclesCheckBox->setEnabled(FALSE);
+ mShowMaterialVolumesCheckBox->setEnabled(FALSE);
+ mShowExclusionVolumesCheckBox->setEnabled(FALSE);
+ mShowWorldCheckBox->setEnabled(FALSE);
+ mViewCharactersButton->setEnabled(TRUE);
mEditTestTabContainer->selectTab(0);
+ mTestTab->setEnabled(FALSE);
+ mCharacterWidthSlider->setEnabled(FALSE);
+ mCharacterTypeRadioGroup->setEnabled(FALSE);
+ mClearPathButton->setEnabled(FALSE);
mHasStartPoint = false;
mHasEndPoint = false;
break;
- default :
+ case kConsoleStateHasNavMesh :
+ case kConsoleStateHasNavMeshDownloading :
mShowNavMeshCheckBox->setEnabled(TRUE);
mShowNavMeshWalkabilityComboBox->setEnabled(TRUE);
mShowWalkablesCheckBox->setEnabled(TRUE);
@@ -723,17 +698,67 @@ void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentStat mShowExclusionVolumesCheckBox->setEnabled(TRUE);
mShowWorldCheckBox->setEnabled(TRUE);
mViewCharactersButton->setEnabled(TRUE);
- mEditTestTabContainer->setEnabled(TRUE);
+ mTestTab->setEnabled(TRUE);
mCharacterWidthSlider->setEnabled(TRUE);
mCharacterTypeRadioGroup->setEnabled(TRUE);
mClearPathButton->setEnabled(TRUE);
+ mTestTab->setEnabled(TRUE);
+ break;
+ default :
+ llassert(0);
+ break;
+ }
+}
+
+void LLFloaterPathfindingConsole::updateStatusOnConsoleState()
+{
+ static const LLColor4 warningColor = LLUIColorTable::instance().getColor("DrYellow");
+
+ std::string statusText("");
+ LLStyle::Params styleParams;
+
+ switch (mConsoleState)
+ {
+ case kConsoleStateUnknown :
+ statusText = getString("navmesh_status_unknown");
+ break;
+ case kConsoleStateLibraryNotImplemented :
+ statusText = getString("navmesh_status_library_not_implemented");
+ styleParams.color = warningColor;
+ break;
+ case kConsoleStateRegionNotEnabled :
+ statusText = getString("navmesh_status_region_not_enabled");
+ styleParams.color = warningColor;
+ break;
+ case kConsoleStateDownloading :
+ statusText = getString("navmesh_status_downloading");
+ break;
+ case kConsoleStateHasNavMesh :
+ statusText = getString("navmesh_status_has_navmesh");
+ break;
+ case kConsoleStateHasNavMeshDownloading :
+ statusText = getString("navmesh_status_has_navmesh_downloading");
+ break;
+ case kConsoleStateError :
+ statusText = getString("navmesh_status_error");
+ styleParams.color = warningColor;
+ break;
+ default :
+ statusText = getString("navmesh_status_unknown");
+ llassert(0);
break;
}
+ mPathfindingStatus->setText((LLStringExplicit)statusText, styleParams);
+}
+
+void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentState pAgentState)
+{
switch (LLPathfindingManager::getInstance()->getLastKnownNonErrorAgentState())
{
case LLPathfindingManager::kAgentStateUnknown :
case LLPathfindingManager::kAgentStateNotEnabled :
+ mEditTab->setEnabled(FALSE);
mUnfreezeLabel->setEnabled(FALSE);
mUnfreezeButton->setEnabled(FALSE);
mLinksetsLabel->setEnabled(FALSE);
@@ -742,6 +767,7 @@ void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentStat mFreezeButton->setEnabled(FALSE);
break;
case LLPathfindingManager::kAgentStateFrozen :
+ mEditTab->setEnabled(TRUE);
mUnfreezeLabel->setEnabled(TRUE);
mUnfreezeButton->setEnabled(TRUE);
mLinksetsLabel->setEnabled(FALSE);
@@ -750,6 +776,7 @@ void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentStat mFreezeButton->setEnabled(FALSE);
break;
case LLPathfindingManager::kAgentStateUnfrozen :
+ mEditTab->setEnabled(TRUE);
mUnfreezeLabel->setEnabled(FALSE);
mUnfreezeButton->setEnabled(FALSE);
mLinksetsLabel->setEnabled(TRUE);
@@ -803,36 +830,36 @@ void LLFloaterPathfindingConsole::updatePathTestStatus() }
-BOOL LLFloaterPathfindingConsole::isRenderAnyShapes() const -{ - if ( isRenderWalkables() || isRenderStaticObstacles() || - isRenderMaterialVolumes() || isRenderExclusionVolumes() ) - { - return true; - } - - return false; -} - -U32 LLFloaterPathfindingConsole::getRenderShapeFlags() -{ - resetShapeRenderFlags(); - - if ( isRenderWalkables() ) - { - setShapeRenderFlag( LLPathingLib::LLST_WalkableObjects ); - } - if ( isRenderStaticObstacles() ) - { - setShapeRenderFlag( LLPathingLib::LLST_ObstacleObjects ); - } - if ( isRenderMaterialVolumes() ) - { - setShapeRenderFlag( LLPathingLib::LLST_MaterialPhantoms ); - } - if ( isRenderExclusionVolumes() ) - { - setShapeRenderFlag( LLPathingLib::LLST_ExclusionPhantoms ); - } - return mShapeRenderFlags; -} +BOOL LLFloaterPathfindingConsole::isRenderAnyShapes() const
+{
+ if ( isRenderWalkables() || isRenderStaticObstacles() ||
+ isRenderMaterialVolumes() || isRenderExclusionVolumes() )
+ {
+ return true;
+ }
+
+ return false;
+}
+
+U32 LLFloaterPathfindingConsole::getRenderShapeFlags()
+{
+ resetShapeRenderFlags();
+
+ if ( isRenderWalkables() )
+ {
+ setShapeRenderFlag( LLPathingLib::LLST_WalkableObjects );
+ }
+ if ( isRenderStaticObstacles() )
+ {
+ setShapeRenderFlag( LLPathingLib::LLST_ObstacleObjects );
+ }
+ if ( isRenderMaterialVolumes() )
+ {
+ setShapeRenderFlag( LLPathingLib::LLST_MaterialPhantoms );
+ }
+ if ( isRenderExclusionVolumes() )
+ {
+ setShapeRenderFlag( LLPathingLib::LLST_ExclusionPhantoms );
+ }
+ return mShapeRenderFlags;
+}
|