diff options
author | prep <prep@lindenlab.com> | 2012-05-31 16:38:19 -0400 |
---|---|---|
committer | prep <prep@lindenlab.com> | 2012-05-31 16:38:19 -0400 |
commit | ef75a2e07ec4f26c9126c04af1adfbd28d7eaa9b (patch) | |
tree | 9fcf0f9cdf911ff6c86dc48c939131dd701ba49b /indra/newview/llfloaterpathfindingobjects.cpp | |
parent | d00192c9cbeaace7c1b7c09bfb86a5b5d8dff458 (diff) |
WIP:Displaying physics capsule for a character - it is currently disabled.
Diffstat (limited to 'indra/newview/llfloaterpathfindingobjects.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingobjects.cpp | 91 |
1 files changed, 90 insertions, 1 deletions
diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index e8d80c09d8..572f2f707e 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -54,9 +54,13 @@ #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "v4color.h" +#include "pipeline.h" +#include "llfloaterreg.h" #define DEFAULT_BEACON_WIDTH 6 +LLHandle<LLFloaterPathfindingObjects> LLFloaterPathfindingObjects::sInstanceHandle; + //--------------------------------------------------------------------------- // LLFloaterPathfindingObjects //--------------------------------------------------------------------------- @@ -144,6 +148,7 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mSelectAllButton(NULL), mSelectNoneButton(NULL), mShowBeaconCheckBox(NULL), + mShowPhysicsCapsuleCheckBox(NULL), mTakeButton(NULL), mTakeCopyButton(NULL), mReturnButton(NULL), @@ -158,8 +163,10 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mObjectList(), mObjectsSelection(), mSelectionUpdateSlot(), - mRegionBoundaryCrossingSlot() + mRegionBoundaryCrossingSlot(), + mSelfHandle() { + mSelfHandle.bind(this); } LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects() @@ -196,6 +203,10 @@ BOOL LLFloaterPathfindingObjects::postBuild() mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon"); llassert(mShowBeaconCheckBox != NULL); + mShowPhysicsCapsuleCheckBox = findChild<LLCheckBoxCtrl>("show_physics_capsule"); + llassert(mShowPhysicsCapsuleCheckBox != NULL); + mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked, this)); + mTakeButton = findChild<LLButton>("take_objects"); llassert(mTakeButton != NULL); mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this)); @@ -657,6 +668,7 @@ void LLFloaterPathfindingObjects::updateStateOnEditFields() bool isEditEnabled = (numSelectedItems > 0); mShowBeaconCheckBox->setEnabled(isEditEnabled); + //prep#mShowPhysicsCapsuleCheckBox->setEnabled( false ); mTakeButton->setEnabled(isEditEnabled && visible_take_object()); mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); mReturnButton->setEnabled(isEditEnabled && enable_object_return()); @@ -675,3 +687,80 @@ LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollLis return objectPtr; } + +void LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked() +{ + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + //We want to hide the VO and display the the objects physics capsule + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.hideObject( id ); + } + } + else + { + //We want to restore the selected objects vo and disable the physics capsule rendering + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.restoreHiddenObject( id ); + } + } +} + +BOOL LLFloaterPathfindingObjects::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +{ + BOOL result = false; + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else + { + id.setNull(); + } + return result; +} + +LLUUID LLFloaterPathfindingObjects::getUUIDFromSelection( LLVector3& pos ) +{ + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + if ( selectedItems.size() > 1 ) + { + return LLUUID::null; + } + if (selectedItems.size() == 1) + { + std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); + const LLScrollListItem *selectedItem = selectedItemRef; + llassert(mObjectList != NULL); + LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); + if ( viewerObject != NULL ) + { + pos = viewerObject->getRenderPosition(); + } + //prep#llinfos<<"id : "<<selectedItem->getUUID()<<llendl; + return selectedItem->getUUID(); + } + + return LLUUID::null; +} + +LLHandle<LLFloaterPathfindingObjects> LLFloaterPathfindingObjects::getInstanceHandle() +{ + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingObjects *floaterInstance = LLFloaterReg::getTypedInstance<LLFloaterPathfindingObjects>("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; +} |