Migrated physics capsule logic into pathing character object

master
prep 2012-06-01 15:48:19 -04:00
parent ed486b3ca0
commit a8ff37b956
7 changed files with 149 additions and 105 deletions

View File

@ -38,6 +38,17 @@
#include "llsd.h"
#include "lluicolortable.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llfloater.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
#include "llselectmgr.h"
#include "pipeline.h"
#include "llviewerobjectlist.h"
LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::sInstanceHandle;
//---------------------------------------------------------------------------
// LLFloaterPathfindingCharacters
//---------------------------------------------------------------------------
@ -46,11 +57,17 @@ void LLFloaterPathfindingCharacters::openCharactersViewer()
{
LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters");
}
void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting)
{
}
LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed)
: LLFloaterPathfindingObjects(pSeed),
mBeaconColor()
mBeaconColor(),
mSelfHandle(),
mShowPhysicsCapsuleCheckBox(NULL)
{
mSelfHandle.bind(this);
}
LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters()
@ -61,6 +78,10 @@ BOOL LLFloaterPathfindingCharacters::postBuild()
{
mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingCharacterBeaconColor");
mShowPhysicsCapsuleCheckBox = findChild<LLCheckBoxCtrl>("show_physics_capsule");
llassert(mShowPhysicsCapsuleCheckBox != NULL);
mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked, this));
return LLFloaterPathfindingObjects::postBuild();
}
@ -137,3 +158,91 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi
return element;
}
void LLFloaterPathfindingCharacters::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 LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos )
{
BOOL result = false;
if ( mShowPhysicsCapsuleCheckBox->get() )
{
id = getUUIDFromSelection( pos );
result = true;
}
else
{
id.setNull();
}
return result;
}
LLUUID LLFloaterPathfindingCharacters::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();
}
//llinfos<<"id : "<<selectedItem->getUUID()<<llendl;
return selectedItem->getUUID();
}
return LLUUID::null;
}
LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::getInstanceHandle()
{
if ( sInstanceHandle.isDead() )
{
LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance<LLFloaterPathfindingCharacters>("pathfinding_characters");
if (floaterInstance != NULL)
{
sInstanceHandle = floaterInstance->mSelfHandle;
}
}
return sInstanceHandle;
}
void LLFloaterPathfindingCharacters::updateStateOnEditFields()
{
int numSelectedItems = mObjectsScrollList->getNumSelected();
bool isEditEnabled = (numSelectedItems > 0);
mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled);
LLFloaterPathfindingObjects::updateStateOnEditFields();
}

View File

@ -39,7 +39,8 @@ class LLFloaterPathfindingCharacters : public LLFloaterPathfindingObjects
{
public:
static void openCharactersViewer();
/*virtual*/ void onClose(bool pIsAppQuitting);
void updateStateOnEditFields();
protected:
friend class LLFloaterReg;
@ -57,10 +58,25 @@ protected:
virtual LLPathfindingObjectListPtr getEmptyObjectList() const;
private:
LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const;
LLColor4 mBeaconColor;
LLUUID getUUIDFromSelection( LLVector3& pos );
public:
BOOL isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos );
void onShowPhysicsCapsuleClicked();
LLRootHandle<LLFloaterPathfindingCharacters> mSelfHandle;
static LLHandle<LLFloaterPathfindingCharacters> sInstanceHandle;
static LLHandle<LLFloaterPathfindingCharacters> getInstanceHandle();
public:
LLCheckBoxCtrl *mShowPhysicsCapsuleCheckBox;
};
#endif // LL_LLFLOATERPATHFINDINGCHARACTERS_H

View File

@ -59,8 +59,6 @@
#define DEFAULT_BEACON_WIDTH 6
LLHandle<LLFloaterPathfindingObjects> LLFloaterPathfindingObjects::sInstanceHandle;
//---------------------------------------------------------------------------
// LLFloaterPathfindingObjects
//---------------------------------------------------------------------------
@ -92,6 +90,8 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey)
void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting)
{
unhideAnyCharacters();
if (mGodLevelChangeSlot.connected())
{
mGodLevelChangeSlot.disconnect();
@ -158,7 +158,6 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed)
mSelectAllButton(NULL),
mSelectNoneButton(NULL),
mShowBeaconCheckBox(NULL),
mShowPhysicsCapsuleCheckBox(NULL),
mTakeButton(NULL),
mTakeCopyButton(NULL),
mReturnButton(NULL),
@ -173,10 +172,8 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed)
mObjectList(),
mObjectsSelection(),
mSelectionUpdateSlot(),
mRegionBoundaryCrossingSlot(),
mSelfHandle()
mRegionBoundaryCrossingSlot()
{
mSelfHandle.bind(this);
}
LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects()
@ -213,10 +210,6 @@ 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));
@ -649,7 +642,6 @@ 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());
@ -701,79 +693,19 @@ 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 )
void LLFloaterPathfindingObjects::unhideAnyCharacters( )
{
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 )
int numSelectedItems = selectedItems.size();
uuid_vec_t selectedUUIDs;
if (numSelectedItems > 0)
{
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 )
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
itemIter != selectedItems.end(); ++itemIter)
{
pos = viewerObject->getRenderPosition();
}
//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;
const LLScrollListItem *listItem = *itemIter;
gPipeline.restoreHiddenObject( listItem->getUUID() );
}
}
return sInstanceHandle;
}

View File

@ -50,6 +50,7 @@ public:
virtual void onOpen(const LLSD &pKey);
virtual void onClose(bool pIsAppQuitting);
virtual void draw();
virtual void updateStateOnEditFields();
protected:
friend class LLFloaterReg;
@ -98,11 +99,6 @@ protected:
EMessagingState getMessagingState() const;
public:
LLUUID getUUIDFromSelection( LLVector3& pos );
BOOL isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos );
void onShowPhysicsCapsuleClicked();
private:
LLFloaterPathfindingObjects(const LLFloaterPathfindingObjects &pOther);
@ -124,18 +120,20 @@ private:
void updateMessagingStatus();
void updateStateOnListActionControls();
void updateStateOnEditFields();
void updateOnScrollListChange();
LLPathfindingObjectPtr findObject(const LLScrollListItem *pListItem) const;
void unhideAnyCharacters( );
protected:
LLScrollListCtrl *mObjectsScrollList;
LLTextBase *mMessagingStatus;
LLButton *mRefreshListButton;
LLButton *mSelectAllButton;
LLButton *mSelectNoneButton;
LLCheckBoxCtrl *mShowBeaconCheckBox;
LLCheckBoxCtrl *mShowPhysicsCapsuleCheckBox;
LLButton *mTakeButton;
LLButton *mTakeCopyButton;
LLButton *mReturnButton;
@ -157,11 +155,7 @@ private:
boost::signals2::connection mSelectionUpdateSlot;
boost::signals2::connection mRegionBoundaryCrossingSlot;
LLAgent::god_level_change_slot_t mGodLevelChangeSlot;
public:
LLRootHandle<LLFloaterPathfindingObjects> mSelfHandle;
static LLHandle<LLFloaterPathfindingObjects> sInstanceHandle;
static LLHandle<LLFloaterPathfindingObjects> getInstanceHandle();
};
#endif // LL_LLFLOATERPATHFINDINGOBJECTS_H

View File

@ -52,6 +52,8 @@ public:
protected:
public:
private:
void parseCharacterData(const LLSD &pCharacterData);

View File

@ -106,7 +106,7 @@
#include "llnotifications.h"
#include "llpathinglib.h"
#include "llfloaterpathfindingconsole.h"
#include "llfloaterpathfindingobjects.h"
#include "llfloaterpathfindingcharacters.h"
#include "llpathfindingpathtool.h"
#ifdef _DEBUG
@ -4362,10 +4362,10 @@ void LLPipeline::renderDebug()
{
//character floater renderables
LLHandle<LLFloaterPathfindingObjects> pathfindingCharacterHandle = LLFloaterPathfindingObjects::getInstanceHandle();
LLHandle<LLFloaterPathfindingCharacters> pathfindingCharacterHandle = LLFloaterPathfindingCharacters::getInstanceHandle();
if ( !pathfindingCharacterHandle.isDead() )
{
LLFloaterPathfindingObjects *pathfindingCharacter = pathfindingCharacterHandle.get();
LLFloaterPathfindingCharacters *pathfindingCharacter = pathfindingCharacterHandle.get();
if ( pathfindingCharacter->getVisible() || gAgentCamera.cameraMouselook() )
{

View File

@ -300,15 +300,6 @@
left_pad="0"
top_pad="-16"
width="90" />
<check_box
height="19"
follows="left|bottom"
label="Show physics capsule"
layout="topleft"
name="show_physics_capsule"
top_pad="-19"
left_pad="10"
width="90" />
<button
follows="left|bottom"
height="21"