From ef75a2e07ec4f26c9126c04af1adfbd28d7eaa9b Mon Sep 17 00:00:00 2001 From: prep Date: Thu, 31 May 2012 16:38:19 -0400 Subject: WIP:Displaying physics capsule for a character - it is currently disabled. --- indra/newview/llfloaterpathfindingobjects.cpp | 91 ++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') 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::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("show_beacon"); llassert(mShowBeaconCheckBox != NULL); + mShowPhysicsCapsuleCheckBox = findChild("show_physics_capsule"); + llassert(mShowPhysicsCapsuleCheckBox != NULL); + mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked, this)); + mTakeButton = findChild("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 selectedItems = mObjectsScrollList->getAllSelected(); + if ( selectedItems.size() > 1 ) + { + return LLUUID::null; + } + if (selectedItems.size() == 1) + { + std::vector::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 : "<getUUID()<getUUID(); + } + + return LLUUID::null; +} + +LLHandle LLFloaterPathfindingObjects::getInstanceHandle() +{ + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingObjects *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; +} -- cgit v1.2.3