diff options
author | Todd Stinson <stinson@lindenlab.com> | 2012-06-04 17:29:48 -0700 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2012-06-04 17:29:48 -0700 |
commit | b64700913f3eecd245503b5a0162c9cc5a2df35e (patch) | |
tree | 0396fe0db9d11116b2603cfe476364cd651bae7d /indra/newview/llfloaterpathfindingcharacters.cpp | |
parent | e85909aa9b52ac439f2886ca0048069fb9561893 (diff) |
PATH-676: Correcting selection behavior so that the first selected object does remain invisible after changing the selection.
Diffstat (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.cpp | 90 |
1 files changed, 54 insertions, 36 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; } |