diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.cpp | 90 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.h | 23 |
2 files changed, 67 insertions, 46 deletions
diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 8b6f6aea1f..5064812e47 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -50,7 +50,8 @@ LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::sInstan void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) { - unhideAnyCharacters(); + // Hide any capsule that might be showing on floater close + hideCapsule(); LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); } @@ -64,6 +65,14 @@ void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCa mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); } +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos) const +{ + id = mSelectedCharacterId; + // Physics capsule is enable if the checkbox is enabled and if we can get a position + // for any selected object + return (isShowPhysicsCapsule() && getCapsulePosition(pos)); +} + void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); @@ -86,6 +95,7 @@ LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::getInst LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), mShowPhysicsCapsuleCheckBox(NULL), + mSelectedCharacterId(), mBeaconColor(), mSelfHandle() { @@ -137,6 +147,7 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa void LLFloaterPathfindingCharacters::updateControls() { LLFloaterPathfindingObjects::updateControls(); + updateOnScrollListChange(); updateStateOnEditFields(); } @@ -158,19 +169,13 @@ LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() { - LLVector3 pos; - LLUUID id = getUUIDFromSelection( pos ); - if ( id.notNull() ) + if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) { - if ( isShowPhysicsCapsule() ) - { - //We want to hide the VO and display the the objects physics capsule - gPipeline.hideObject( id ); - } - else - { - gPipeline.restoreHiddenObject( id ); - } + showCapsule(); + } + else + { + hideCapsule(); } } @@ -224,46 +229,59 @@ void LLFloaterPathfindingCharacters::updateStateOnEditFields() } } -LLUUID LLFloaterPathfindingCharacters::getUUIDFromSelection( LLVector3& pos ) +void LLFloaterPathfindingCharacters::updateOnScrollListChange() { - LLUUID uuid = LLUUID::null; + // Hide any previous capsule + hideCapsule(); + // Get the only selected object, or set the selected object to null if we do not have exactly + // one object selected if (getNumSelectedObjects() == 1) { LLPathfindingObjectPtr selectedObjectPtr = getFirstSelectedObject(); - uuid = selectedObjectPtr->getUUID(); - LLViewerObject *viewerObject = gObjectList.findObject(uuid); - if ( viewerObject != NULL ) - { - pos = viewerObject->getRenderPosition(); - } + mSelectedCharacterId = selectedObjectPtr->getUUID(); + } + else + { + mSelectedCharacterId.setNull(); } - return uuid; + // Show any capsule if enabled + showCapsule(); } -void LLFloaterPathfindingCharacters::unhideAnyCharacters() +void LLFloaterPathfindingCharacters::showCapsule() const { - LLPathfindingObjectListPtr objectListPtr = getSelectedObjects(); - for (LLPathfindingObjectList::const_iterator objectIter = objectListPtr->begin(); - objectIter != objectListPtr->end(); ++objectIter) + if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) { - LLPathfindingObjectPtr objectPtr = objectIter->second; - gPipeline.restoreHiddenObject(objectPtr->getUUID()); + gPipeline.hideObject(mSelectedCharacterId); } } -BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +void LLFloaterPathfindingCharacters::hideCapsule() const { - BOOL result = false; - if ( isShowPhysicsCapsule() ) - { - id = getUUIDFromSelection( pos ); - result = true; + if (mSelectedCharacterId.notNull()) + { + gPipeline.restoreHiddenObject(mSelectedCharacterId); } - else +} + +bool LLFloaterPathfindingCharacters::getCapsulePosition(LLVector3 &pPosition) const +{ + bool result = false; + + // If we have a selected object, find the object on the viewer object list and return its + // position. Else, return false indicating that we either do not have a selected object + // or we cannot find the selected object on the viewer object list + if (mSelectedCharacterId.notNull()) { - id.setNull(); + LLViewerObject *viewerObject = gObjectList.findObject(mSelectedCharacterId); + if ( viewerObject != NULL ) + { + pPosition = viewerObject->getRenderPosition(); + result = true; + } } + return result; } diff --git a/indra/newview/llfloaterpathfindingcharacters.h b/indra/newview/llfloaterpathfindingcharacters.h index f62766df22..6be359e50d 100644 --- a/indra/newview/llfloaterpathfindingcharacters.h +++ b/indra/newview/llfloaterpathfindingcharacters.h @@ -44,12 +44,11 @@ public: BOOL isShowPhysicsCapsule() const; void setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule); - BOOL isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ); + BOOL isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos) const; static void openCharactersViewer(); static LLHandle<LLFloaterPathfindingCharacters> getInstanceHandle(); - protected: friend class LLFloaterReg; @@ -69,23 +68,27 @@ protected: virtual LLPathfindingObjectListPtr getEmptyObjectList() const; - private: - void onShowPhysicsCapsuleClicked(); + void onShowPhysicsCapsuleClicked(); + + LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const; + + void updateStateOnEditFields(); + void updateOnScrollListChange(); - LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const; - void updateStateOnEditFields(); - LLUUID getUUIDFromSelection( LLVector3& pos ); - void unhideAnyCharacters(); + void showCapsule() const; + void hideCapsule() const; + + bool getCapsulePosition(LLVector3 &pPosition) const; LLCheckBoxCtrl *mShowPhysicsCapsuleCheckBox; + LLUUID mSelectedCharacterId; + LLColor4 mBeaconColor; LLRootHandle<LLFloaterPathfindingCharacters> mSelfHandle; static LLHandle<LLFloaterPathfindingCharacters> sInstanceHandle; - -public: }; #endif // LL_LLFLOATERPATHFINDINGCHARACTERS_H |