First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated.

master
Todd Stinson 2012-05-30 18:47:12 -07:00
parent 5d13d78c13
commit 3c2be426e5
24 changed files with 1923 additions and 1718 deletions

View File

@ -222,6 +222,7 @@ set(viewer_SOURCE_FILES
llfloaterpathfindingcharacters.cpp
llfloaterpathfindingconsole.cpp
llfloaterpathfindinglinksets.cpp
llfloaterpathfindingobjects.cpp
llfloaterpay.cpp
llfloaterperms.cpp
llfloaterpostprocess.cpp
@ -425,6 +426,8 @@ set(viewer_SOURCE_FILES
llpathfindingnavmesh.cpp
llpathfindingnavmeshstatus.cpp
llpathfindingnavmeshzone.cpp
llpathfindingobject.cpp
llpathfindingobjectlist.cpp
llpathfindingpathtool.cpp
llphysicsmotion.cpp
llphysicsshapebuilderutil.cpp
@ -791,6 +794,7 @@ set(viewer_HEADER_FILES
llfloaterpathfindingcharacters.h
llfloaterpathfindingconsole.h
llfloaterpathfindinglinksets.h
llfloaterpathfindingobjects.h
llfloaterpay.h
llfloaterperms.h
llfloaterpostprocess.h
@ -983,6 +987,8 @@ set(viewer_HEADER_FILES
llpathfindingnavmesh.h
llpathfindingnavmeshstatus.h
llpathfindingnavmeshzone.h
llpathfindingobject.h
llpathfindingobjectlist.h
llpathfindingpathtool.h
llphysicsmotion.h
llphysicsshapebuilderutil.h

View File

@ -26,176 +26,29 @@
*/
#include "llviewerprecompiledheaders.h"
#include "llfloater.h"
#include "llfloaterpathfindingcharacters.h"
#include "llfloaterreg.h"
#include "llfloaterpathfindingobjects.h"
#include "llpathfindingcharacter.h"
#include "llpathfindingcharacterlist.h"
#include "llsd.h"
#include "llagent.h"
#include "llhandle.h"
#include "llfloaterreg.h"
#include "lltextbase.h"
#include "llscrolllistitem.h"
#include "llscrolllistctrl.h"
#include "llcheckboxctrl.h"
#include "llradiogroup.h"
#include "llbutton.h"
#include "llresmgr.h"
#include "llviewerregion.h"
#include "llhttpclient.h"
#include "lluuid.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewermenu.h"
#include "llselectmgr.h"
#include "llenvmanager.h"
#include "llviewerregion.h"
//---------------------------------------------------------------------------
// LLFloaterPathfindingCharacters
//---------------------------------------------------------------------------
BOOL LLFloaterPathfindingCharacters::postBuild()
{
mCharactersScrollList = findChild<LLScrollListCtrl>("pathfinding_characters");
llassert(mCharactersScrollList != NULL);
mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this));
mCharactersScrollList->sortByColumnIndex(0, true);
mCharactersStatus = findChild<LLTextBase>("characters_status");
llassert(mCharactersStatus != NULL);
mRefreshListButton = findChild<LLButton>("refresh_characters_list");
llassert(mRefreshListButton != NULL);
mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this));
mSelectAllButton = findChild<LLButton>("select_all_characters");
llassert(mSelectAllButton != NULL);
mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this));
mSelectNoneButton = findChild<LLButton>("select_none_characters");
llassert(mSelectNoneButton != NULL);
mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this));
mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon");
llassert(mShowBeaconCheckBox != NULL);
mTakeButton = findChild<LLButton>("take_characters");
llassert(mTakeButton != NULL)
mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this));
mTakeCopyButton = findChild<LLButton>("take_copy_characters");
llassert(mTakeCopyButton != NULL)
mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this));
mReturnButton = findChild<LLButton>("return_characters");
llassert(mReturnButton != NULL)
mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this));
mDeleteButton = findChild<LLButton>("delete_characters");
llassert(mDeleteButton != NULL)
mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this));
mTeleportButton = findChild<LLButton>("teleport_to_character");
llassert(mTeleportButton != NULL)
mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked, this));
return LLFloater::postBuild();
}
void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey)
{
LLFloater::onOpen(pKey);
requestGetCharacters();
selectNoneCharacters();
mCharactersScrollList->setCommitOnSelectionChange(true);
if (!mSelectionUpdateSlot.connected())
{
mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingCharacters::updateControls, this));
}
if (!mRegionBoundarySlot.connected())
{
mRegionBoundarySlot = LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterPathfindingCharacters::onRegionBoundaryCross, this));
}
}
void LLFloaterPathfindingCharacters::onClose(bool pAppQuitting)
{
if (mRegionBoundarySlot.connected())
{
mRegionBoundarySlot.disconnect();
}
if (mSelectionUpdateSlot.connected())
{
mSelectionUpdateSlot.disconnect();
}
mCharactersScrollList->setCommitOnSelectionChange(false);
selectNoneCharacters();
if (mCharacterSelection.notNull())
{
mCharacterSelection.clear();
}
LLFloater::onClose(pAppQuitting);
}
void LLFloaterPathfindingCharacters::draw()
{
if (mShowBeaconCheckBox->get())
{
std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected();
if (!selectedItems.empty())
{
int numSelectedItems = selectedItems.size();
std::vector<LLViewerObject *> viewerObjects;
viewerObjects.reserve(numSelectedItems);
for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin();
selectedItemIter != selectedItems.end(); ++selectedItemIter)
{
const LLScrollListItem *selectedItem = *selectedItemIter;
const std::string &objectName = selectedItem->getColumn(0)->getValue().asString();
LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID());
if (viewerObject != NULL)
{
gObjectList.addDebugBeacon(viewerObject->getPositionAgent(), objectName, LLColor4(0.f, 0.f, 1.f, 0.8f), LLColor4(1.f, 1.f, 1.f, 1.f), 6);
}
}
}
}
LLFloater::draw();
}
void LLFloaterPathfindingCharacters::openCharactersViewer()
{
LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters");
}
LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed)
: LLFloater(pSeed),
mCharactersScrollList(NULL),
mCharactersStatus(NULL),
mRefreshListButton(NULL),
mSelectAllButton(NULL),
mSelectNoneButton(NULL),
mShowBeaconCheckBox(NULL),
mTakeButton(NULL),
mTakeCopyButton(NULL),
mReturnButton(NULL),
mDeleteButton(NULL),
mTeleportButton(NULL),
mMessagingState(kMessagingUnknown),
mMessagingRequestId(0U),
mCharacterListPtr(),
mCharacterSelection(),
mSelectionUpdateSlot()
: LLFloaterPathfindingObjects(pSeed),
mBeaconColor()
{
}
@ -203,208 +56,52 @@ LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters()
{
}
LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const
BOOL LLFloaterPathfindingCharacters::postBuild()
{
return mMessagingState;
mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingCharacterBeaconColor");
return LLFloaterPathfindingObjects::postBuild();
}
void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState)
void LLFloaterPathfindingCharacters::requestGetObjects()
{
mMessagingState = pMessagingState;
updateControls();
LLPathfindingManager::getInstance()->requestGetCharacters(getNewRequestId(), boost::bind(&LLFloaterPathfindingCharacters::handleNewObjectList, this, _1, _2, _3));
}
void LLFloaterPathfindingCharacters::requestGetCharacters()
LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const
{
LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3));
}
llassert(pObjectListPtr != NULL);
llassert(!pObjectListPtr->isEmpty());
void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr)
{
llassert(pRequestId <= mMessagingRequestId);
if (pRequestId == mMessagingRequestId)
LLSD scrollListData;
for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter)
{
switch (pCharacterRequestStatus)
{
case LLPathfindingManager::kRequestStarted :
setMessagingState(kMessagingGetRequestSent);
break;
case LLPathfindingManager::kRequestCompleted :
mCharacterListPtr = pCharacterListPtr;
updateScrollList();
setMessagingState(kMessagingComplete);
break;
case LLPathfindingManager::kRequestNotEnabled :
clearCharacters();
setMessagingState(kMessagingNotEnabled);
break;
case LLPathfindingManager::kRequestError :
setMessagingState(kMessagingGetError);
break;
default :
setMessagingState(kMessagingGetError);
llassert(0);
break;
}
}
}
void LLFloaterPathfindingCharacters::onCharactersSelectionChange()
{
mCharacterSelection.clear();
LLSelectMgr::getInstance()->deselectAll();
std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected();
if (!selectedItems.empty())
{
int numSelectedItems = selectedItems.size();
std::vector<LLViewerObject *> viewerObjects;
viewerObjects.reserve(numSelectedItems);
for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin();
selectedItemIter != selectedItems.end(); ++selectedItemIter)
{
const LLScrollListItem *selectedItem = *selectedItemIter;
LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID());
if (viewerObject != NULL)
{
viewerObjects.push_back(viewerObject);
}
}
if (!viewerObjects.empty())
{
mCharacterSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects);
}
const LLPathfindingCharacter *characterPtr = dynamic_cast<const LLPathfindingCharacter *>(objectIter->second.get());
LLSD element = buildCharacterScrollListData(characterPtr);
scrollListData.append(element);
}
updateControls();
return scrollListData;
}
void LLFloaterPathfindingCharacters::onRefreshCharactersClicked()
S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const
{
requestGetCharacters();
return 0;
}
void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked()
const LLColor4 &LLFloaterPathfindingCharacters::getBeaconColor() const
{
selectAllCharacters();
return mBeaconColor;
}
void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked()
LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() const
{
selectNoneCharacters();
LLPathfindingObjectListPtr objectListPtr(new LLPathfindingCharacterList());
return objectListPtr;
}
void LLFloaterPathfindingCharacters::onTakeCharactersClicked()
{
handle_take();
}
void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked()
{
handle_take_copy();
}
void LLFloaterPathfindingCharacters::onReturnCharactersClicked()
{
handle_object_return();
}
void LLFloaterPathfindingCharacters::onDeleteCharactersClicked()
{
handle_object_delete();
}
void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked()
{
std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected();
llassert(selectedItems.size() == 1);
if (selectedItems.size() == 1)
{
std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front();
const LLScrollListItem *selectedItem = selectedItemRef;
LLPathfindingCharacterList::const_iterator characterIter = mCharacterListPtr->find(selectedItem->getUUID().asString());
const LLPathfindingCharacterPtr &characterPtr = characterIter->second;
const LLVector3 &characterLocation = characterPtr->getLocation();
LLViewerRegion* region = gAgent.getRegion();
if (region != NULL)
{
gAgent.teleportRequest(region->getHandle(), characterLocation, true);
}
}
}
void LLFloaterPathfindingCharacters::onRegionBoundaryCross()
{
requestGetCharacters();
}
void LLFloaterPathfindingCharacters::selectAllCharacters()
{
mCharactersScrollList->selectAll();
}
void LLFloaterPathfindingCharacters::selectNoneCharacters()
{
mCharactersScrollList->deselectAllItems();
}
void LLFloaterPathfindingCharacters::clearCharacters()
{
if (mCharacterListPtr != NULL)
{
mCharacterListPtr->clear();
}
updateScrollList();
}
void LLFloaterPathfindingCharacters::updateControls()
{
updateStatusMessage();
updateEnableStateOnListActions();
updateEnableStateOnEditFields();
}
void LLFloaterPathfindingCharacters::updateScrollList()
{
std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected();
int numSelectedItems = selectedItems.size();
uuid_vec_t selectedUUIDs;
if (numSelectedItems > 0)
{
selectedUUIDs.reserve(selectedItems.size());
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
itemIter != selectedItems.end(); ++itemIter)
{
const LLScrollListItem *listItem = *itemIter;
selectedUUIDs.push_back(listItem->getUUID());
}
}
S32 origScrollPosition = mCharactersScrollList->getScrollPos();
mCharactersScrollList->deleteAllItems();
if (mCharacterListPtr != NULL)
{
for (LLPathfindingCharacterList::const_iterator characterIter = mCharacterListPtr->begin();
characterIter != mCharacterListPtr->end(); ++characterIter)
{
const LLPathfindingCharacterPtr& character(characterIter->second);
LLSD element = buildCharacterScrollListElement(character);
mCharactersScrollList->addElement(element);
}
}
mCharactersScrollList->selectMultiple(selectedUUIDs);
mCharactersScrollList->setScrollPos(origScrollPosition);
updateControls();
}
LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const
LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const
{
LLSD columns;
@ -439,106 +136,3 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPat
return element;
}
void LLFloaterPathfindingCharacters::updateStatusMessage()
{
static const LLColor4 errorColor = LLUIColorTable::instance().getColor("PathfindingErrorColor");
static const LLColor4 warningColor = LLUIColorTable::instance().getColor("PathfindingWarningColor");
std::string statusText("");
LLStyle::Params styleParams;
switch (getMessagingState())
{
case kMessagingUnknown:
statusText = getString("characters_messaging_initial");
styleParams.color = errorColor;
break;
case kMessagingGetRequestSent :
statusText = getString("characters_messaging_get_inprogress");
styleParams.color = warningColor;
break;
case kMessagingGetError :
statusText = getString("characters_messaging_get_error");
styleParams.color = errorColor;
break;
case kMessagingComplete :
if (mCharactersScrollList->isEmpty())
{
statusText = getString("characters_messaging_complete_none_found");
}
else
{
S32 numItems = mCharactersScrollList->getItemCount();
S32 numSelectedItems = mCharactersScrollList->getNumSelected();
LLLocale locale(LLStringUtil::getLocale());
std::string numItemsString;
LLResMgr::getInstance()->getIntegerString(numItemsString, numItems);
std::string numSelectedItemsString;
LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems);
LLStringUtil::format_map_t string_args;
string_args["[NUM_SELECTED]"] = numSelectedItemsString;
string_args["[NUM_TOTAL]"] = numItemsString;
statusText = getString("characters_messaging_complete_available", string_args);
}
break;
case kMessagingNotEnabled:
statusText = getString("characters_messaging_not_enabled");
styleParams.color = errorColor;
break;
default:
statusText = getString("characters_messaging_initial");
styleParams.color = errorColor;
llassert(0);
break;
}
mCharactersStatus->setText((LLStringExplicit)statusText, styleParams);
}
void LLFloaterPathfindingCharacters::updateEnableStateOnListActions()
{
switch (getMessagingState())
{
case kMessagingUnknown:
case kMessagingGetRequestSent :
mRefreshListButton->setEnabled(FALSE);
mSelectAllButton->setEnabled(FALSE);
mSelectNoneButton->setEnabled(FALSE);
break;
case kMessagingGetError :
case kMessagingNotEnabled :
mRefreshListButton->setEnabled(TRUE);
mSelectAllButton->setEnabled(FALSE);
mSelectNoneButton->setEnabled(FALSE);
break;
case kMessagingComplete :
{
int numItems = mCharactersScrollList->getItemCount();
int numSelectedItems = mCharactersScrollList->getNumSelected();
mRefreshListButton->setEnabled(TRUE);
mSelectAllButton->setEnabled(numSelectedItems < numItems);
mSelectNoneButton->setEnabled(numSelectedItems > 0);
}
break;
default:
llassert(0);
break;
}
}
void LLFloaterPathfindingCharacters::updateEnableStateOnEditFields()
{
int numSelectedItems = mCharactersScrollList->getNumSelected();
bool isEditEnabled = (numSelectedItems > 0);
mShowBeaconCheckBox->setEnabled(isEditEnabled);
mTakeButton->setEnabled(isEditEnabled && visible_take_object());
mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy());
mReturnButton->setEnabled(isEditEnabled && enable_object_return());
mDeleteButton->setEnabled(isEditEnabled && enable_object_delete());
mTeleportButton->setEnabled(numSelectedItems == 1);
}

View File

@ -28,101 +28,45 @@
#ifndef LL_LLFLOATERPATHFINDINGCHARACTERS_H
#define LL_LLFLOATERPATHFINDINGCHARACTERS_H
#include <string>
#include <map>
#include "llfloater.h"
#include "llfloaterpathfindingobjects.h"
#include "llpathfindingcharacter.h"
#include "llpathfindingcharacterlist.h"
#include "llpathfindingmanager.h"
#include "llselectmgr.h"
#include "llpathfindingobjectlist.h"
#include "v4color.h"
#include <boost/signals2.hpp>
class LLSD;
class LLTextBase;
class LLScrollListCtrl;
class LLButton;
class LLCheckBoxCtrl;
class LLRadioGroup;
class LLButton;
class LLScrollListCtrl;
class LLSD;
class LLTextBase;
class LLFloaterPathfindingCharacters
: public LLFloater
class LLFloaterPathfindingCharacters : public LLFloaterPathfindingObjects
{
friend class LLFloaterReg;
public:
typedef enum
{
kMessagingUnknown,
kMessagingGetRequestSent,
kMessagingGetError,
kMessagingComplete,
kMessagingNotEnabled
} EMessagingState;
virtual BOOL postBuild();
virtual void onOpen(const LLSD& pKey);
virtual void onClose(bool pAppQuitting);
virtual void draw();
static void openCharactersViewer();
static void openCharactersViewer();
protected:
friend class LLFloaterReg;
private:
LLScrollListCtrl *mCharactersScrollList;
LLTextBase *mCharactersStatus;
LLButton *mRefreshListButton;
LLButton *mSelectAllButton;
LLButton *mSelectNoneButton;
LLCheckBoxCtrl *mShowBeaconCheckBox;
LLButton *mTakeButton;
LLButton *mTakeCopyButton;
LLButton *mReturnButton;
LLButton *mDeleteButton;
LLButton *mTeleportButton;
EMessagingState mMessagingState;
LLPathfindingManager::request_id_t mMessagingRequestId;
LLPathfindingCharacterListPtr mCharacterListPtr;
LLObjectSelectionHandle mCharacterSelection;
boost::signals2::connection mSelectionUpdateSlot;
boost::signals2::connection mRegionBoundarySlot;
// Does its own instance management, so clients not allowed
// to allocate or destroy.
LLFloaterPathfindingCharacters(const LLSD& pSeed);
virtual ~LLFloaterPathfindingCharacters();
EMessagingState getMessagingState() const;
void setMessagingState(EMessagingState pMessagingState);
virtual BOOL postBuild();
void requestGetCharacters();
void handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr);
virtual void requestGetObjects();
void onCharactersSelectionChange();
void onRefreshCharactersClicked();
void onSelectAllCharactersClicked();
void onSelectNoneCharactersClicked();
void onTakeCharactersClicked();
void onTakeCopyCharactersClicked();
void onReturnCharactersClicked();
void onDeleteCharactersClicked();
void onTeleportCharacterToMeClicked();
void onRegionBoundaryCross();
virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const;
void selectAllCharacters();
void selectNoneCharacters();
void clearCharacters();
virtual S32 getNameColumnIndex() const;
virtual const LLColor4 &getBeaconColor() const;
void updateControls();
void updateScrollList();
LLSD buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const;
virtual LLPathfindingObjectListPtr getEmptyObjectList() const;
void updateStatusMessage();
void updateEnableStateOnListActions();
void updateEnableStateOnEditFields();
private:
LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const;
LLColor4 mBeaconColor;
};
#endif // LL_LLFLOATERPATHFINDINGCHARACTERS_H

File diff suppressed because it is too large Load Diff

View File

@ -28,142 +28,70 @@
#ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H
#define LL_LLFLOATERPATHFINDINGLINKSETS_H
#include "llfloater.h"
#include "lluuid.h"
#include "llselectmgr.h"
#include "llfloaterpathfindingobjects.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
#include "llpathfindingmanager.h"
#include "llpathfindingobjectlist.h"
#include "v4color.h"
#include <boost/signals2.hpp>
class LLSD;
class LLUICtrl;
class LLTextBase;
class LLScrollListCtrl;
class LLScrollListItem;
class LLLineEditor;
class LLComboBox;
class LLCheckBoxCtrl;
class LLButton;
class LLComboBox;
class LLLineEditor;
class LLScrollListItem;
class LLSD;
class LLTextBase;
class LLUICtrl;
class LLFloaterPathfindingLinksets
: public LLFloater
class LLFloaterPathfindingLinksets : public LLFloaterPathfindingObjects
{
friend class LLFloaterReg;
public:
typedef enum
{
kMessagingUnknown,
kMessagingGetRequestSent,
kMessagingGetError,
kMessagingSetRequestSent,
kMessagingSetError,
kMessagingComplete,
kMessagingNotEnabled
} EMessagingState;
virtual BOOL postBuild();
virtual void onOpen(const LLSD& pKey);
virtual void onClose(bool pAppQuitting);
virtual void draw();
virtual void onClose(bool pIsAppQuitting);
static void openLinksetsEditor();
static void openLinksetsEditor();
protected:
friend class LLFloaterReg;
private:
LLLineEditor *mFilterByName;
LLLineEditor *mFilterByDescription;
LLComboBox *mFilterByLinksetUse;
LLScrollListCtrl *mLinksetsScrollList;
LLTextBase *mLinksetsStatus;
LLButton *mRefreshListButton;
LLButton *mSelectAllButton;
LLButton *mSelectNoneButton;
LLCheckBoxCtrl *mShowBeaconCheckBox;
LLButton *mTakeButton;
LLButton *mTakeCopyButton;
LLButton *mReturnButton;
LLButton *mDeleteButton;
LLButton *mTeleportButton;
LLComboBox *mEditLinksetUse;
LLScrollListItem *mEditLinksetUseUnset;
LLScrollListItem *mEditLinksetUseWalkable;
LLScrollListItem *mEditLinksetUseStaticObstacle;
LLScrollListItem *mEditLinksetUseDynamicObstacle;
LLScrollListItem *mEditLinksetUseMaterialVolume;
LLScrollListItem *mEditLinksetUseExclusionVolume;
LLScrollListItem *mEditLinksetUseDynamicPhantom;
LLTextBase *mLabelWalkabilityCoefficients;
LLTextBase *mLabelEditA;
LLLineEditor *mEditA;
LLTextBase *mLabelEditB;
LLLineEditor *mEditB;
LLTextBase *mLabelEditC;
LLLineEditor *mEditC;
LLTextBase *mLabelEditD;
LLLineEditor *mEditD;
LLButton *mApplyEditsButton;
EMessagingState mMessagingState;
LLPathfindingManager::request_id_t mMessagingRequestId;
LLPathfindingLinksetListPtr mLinksetsListPtr;
LLObjectSelectionHandle mLinksetsSelection;
LLPathfindingManager::agent_state_slot_t mAgentStateSlot;
boost::signals2::connection mSelectionUpdateSlot;
boost::signals2::connection mRegionBoundarySlot;
// Does its own instance management, so clients not allowed
// to allocate or destroy.
LLFloaterPathfindingLinksets(const LLSD& pSeed);
virtual ~LLFloaterPathfindingLinksets();
EMessagingState getMessagingState() const;
void setMessagingState(EMessagingState pMessagingState);
virtual BOOL postBuild();
void requestGetLinksets();
void requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD);
void handleNewLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr);
void handleUpdateLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr);
virtual void requestGetObjects();
virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const;
virtual void updateControls();
virtual void updateSelection();
virtual S32 getNameColumnIndex() const;
virtual const LLColor4 &getBeaconColor() const;
virtual LLPathfindingObjectListPtr getEmptyObjectList() const;
private:
void requestSetLinksets(LLPathfindingObjectListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD);
void onApplyAllFilters();
void onClearFiltersClicked();
void onLinksetsSelectionChange();
void onRefreshLinksetsClicked();
void onSelectAllLinksetsClicked();
void onSelectNoneLinksetsClicked();
void onTakeClicked();
void onTakeCopyClicked();
void onReturnClicked();
void onDeleteClicked();
void onTeleportClicked();
void onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl);
void onApplyChangesClicked();
void onAgentStateCB(LLPathfindingManager::EAgentState pAgentState);
void onRegionBoundaryCross();
void onAgentStateChange(LLPathfindingManager::EAgentState pAgentState);
void applyFilters();
void clearFilters();
void selectAllLinksets();
void selectNoneLinksets();
void clearLinksets();
void updateControls();
void updateEditFieldValues();
void updateScrollList();
LLSD buildLinksetScrollListElement(const LLPathfindingLinksetPtr pLinksetPtr, const LLVector3 &pAvatarPosition) const;
LLSD buildLinksetUseScrollListElement(const std::string &label, S32 value) const;
LLSD buildLinksetScrollListData(const LLPathfindingLinkset *pLinksetPtr, const LLVector3 &pAvatarPosition) const;
LLSD buildLinksetUseScrollListData(const std::string &pLabel, S32 pValue) const;
bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const;
bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const;
bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const;
bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const;
void updateStatusMessage();
void updateEnableStateOnListActions();
void updateEnableStateOnEditFields();
void updateEnableStateOnEditLinksetUse();
void updateStateOnEditFields();
void updateStateOnEditLinksetUse();
void applyEdit();
void handleApplyEdit(const LLSD &pNotification, const LLSD &pResponse);
@ -179,6 +107,32 @@ private:
LLPathfindingLinkset::ELinksetUse convertToLinksetUse(LLSD pXuiValue) const;
LLSD convertToXuiValue(LLPathfindingLinkset::ELinksetUse pLinksetUse) const;
LLLineEditor *mFilterByName;
LLLineEditor *mFilterByDescription;
LLComboBox *mFilterByLinksetUse;
LLComboBox *mEditLinksetUse;
LLScrollListItem *mEditLinksetUseUnset;
LLScrollListItem *mEditLinksetUseWalkable;
LLScrollListItem *mEditLinksetUseStaticObstacle;
LLScrollListItem *mEditLinksetUseDynamicObstacle;
LLScrollListItem *mEditLinksetUseMaterialVolume;
LLScrollListItem *mEditLinksetUseExclusionVolume;
LLScrollListItem *mEditLinksetUseDynamicPhantom;
LLTextBase *mLabelWalkabilityCoefficients;
LLTextBase *mLabelEditA;
LLLineEditor *mEditA;
LLTextBase *mLabelEditB;
LLLineEditor *mEditB;
LLTextBase *mLabelEditC;
LLLineEditor *mEditC;
LLTextBase *mLabelEditD;
LLLineEditor *mEditD;
LLButton *mApplyEditsButton;
LLColor4 mBeaconColor;
LLPathfindingManager::agent_state_slot_t mAgentStateSlot;
};
#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H

View File

@ -0,0 +1,680 @@
/**
* @file llfloaterpathfindingobjects.cpp
* @brief Implementation of llfloaterpathfindingobjects
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfloaterpathfindingobjects.h"
#include <vector>
#include <boost/bind.hpp>
#include <boost/signals2.hpp>
#include "v4color.h"
#include "llagent.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "llenvmanager.h"
#include "lllineeditor.h"
#include "llfloater.h"
#include "llpathfindingmanager.h"
#include "llresmgr.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
#include "llselectmgr.h"
#include "llsd.h"
#include "llstring.h"
#include "llstyle.h"
#include "lltextbase.h"
#include "lluicolortable.h"
#include "llviewermenu.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#define DEFAULT_BEACON_WIDTH 6
//---------------------------------------------------------------------------
// LLFloaterPathfindingObjects
//---------------------------------------------------------------------------
void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey)
{
LLFloater::onOpen(pKey);
selectNoneObjects();
mObjectsScrollList->setCommitOnSelectionChange(TRUE);
if (!mSelectionUpdateSlot.connected())
{
mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingObjects::onSelectionListChanged, this));
}
if (!mRegionBoundaryCrossingSlot.connected())
{
mRegionBoundaryCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLFloaterPathfindingObjects::onRegionBoundaryCrossed, this));
}
requestGetObjects();
}
void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting)
{
if (mRegionBoundaryCrossingSlot.connected())
{
mRegionBoundaryCrossingSlot.disconnect();
}
if (mSelectionUpdateSlot.connected())
{
mSelectionUpdateSlot.disconnect();
}
mObjectsScrollList->setCommitOnSelectionChange(FALSE);
selectNoneObjects();
if (mObjectsSelection.notNull())
{
mObjectsSelection.clear();
}
}
void LLFloaterPathfindingObjects::draw()
{
LLFloater::draw();
if (isShowBeacons())
{
std::vector<LLScrollListItem *> selectedItems = mObjectsScrollList->getAllSelected();
if (!selectedItems.empty())
{
int numSelectedItems = selectedItems.size();
S32 nameColumnIndex = getNameColumnIndex();
const LLColor4 &beaconColor = getBeaconColor();
const LLColor4 &beaconTextColor = getBeaconTextColor();
S32 beaconWidth = getBeaconWidth();
std::vector<LLViewerObject *> viewerObjects;
viewerObjects.reserve(numSelectedItems);
for (std::vector<LLScrollListItem *>::const_iterator selectedItemIter = selectedItems.begin();
selectedItemIter != selectedItems.end(); ++selectedItemIter)
{
const LLScrollListItem *selectedItem = *selectedItemIter;
LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID());
if (viewerObject != NULL)
{
const std::string &objectName = selectedItem->getColumn(nameColumnIndex)->getValue().asString();
gObjectList.addDebugBeacon(viewerObject->getPositionAgent(), objectName, beaconColor, beaconTextColor, beaconWidth);
}
}
}
}
}
LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed)
: LLFloater(pSeed),
mObjectsScrollList(NULL),
mMessagingStatus(NULL),
mRefreshListButton(NULL),
mSelectAllButton(NULL),
mSelectNoneButton(NULL),
mShowBeaconCheckBox(NULL),
mTakeButton(NULL),
mTakeCopyButton(NULL),
mReturnButton(NULL),
mDeleteButton(NULL),
mTeleportButton(NULL),
mDefaultBeaconColor(),
mDefaultBeaconTextColor(),
mErrorTextColor(),
mWarningTextColor(),
mMessagingState(kMessagingUnknown),
mMessagingRequestId(0U),
mObjectList(),
mObjectsSelection(),
mSelectionUpdateSlot(),
mRegionBoundaryCrossingSlot()
{
}
LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects()
{
}
BOOL LLFloaterPathfindingObjects::postBuild()
{
mDefaultBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingDefaultBeaconColor");
mDefaultBeaconTextColor = LLUIColorTable::getInstance()->getColor("PathfindingDefaultBeaconTextColor");
mErrorTextColor = LLUIColorTable::getInstance()->getColor("PathfindingErrorColor");
mWarningTextColor = LLUIColorTable::getInstance()->getColor("PathfindingWarningColor");
mObjectsScrollList = findChild<LLScrollListCtrl>("objects_scroll_list");
llassert(mObjectsScrollList != NULL);
mObjectsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onScrollListSelectionChanged, this));
mObjectsScrollList->sortByColumnIndex(static_cast<U32>(getNameColumnIndex()), TRUE);
mMessagingStatus = findChild<LLTextBase>("messaging_status");
llassert(mMessagingStatus != NULL);
mRefreshListButton = findChild<LLButton>("refresh_objects_list");
llassert(mRefreshListButton != NULL);
mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onRefreshObjectsClicked, this));
mSelectAllButton = findChild<LLButton>("select_all_objects");
llassert(mSelectAllButton != NULL);
mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectAllObjectsClicked, this));
mSelectNoneButton = findChild<LLButton>("select_none_objects");
llassert(mSelectNoneButton != NULL);
mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectNoneObjectsClicked, this));
mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon");
llassert(mShowBeaconCheckBox != NULL);
mTakeButton = findChild<LLButton>("take_objects");
llassert(mTakeButton != NULL);
mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this));
mTakeCopyButton = findChild<LLButton>("take_copy_objects");
llassert(mTakeCopyButton != NULL);
mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeCopyClicked, this));
mReturnButton = findChild<LLButton>("return_objects");
llassert(mReturnButton != NULL);
mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onReturnClicked, this));
mDeleteButton = findChild<LLButton>("delete_objects");
llassert(mDeleteButton != NULL);
mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onDeleteClicked, this));
mTeleportButton = findChild<LLButton>("teleport_me_to_object");
llassert(mTeleportButton != NULL);
mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTeleportClicked, this));
return LLFloater::postBuild();
}
void LLFloaterPathfindingObjects::requestGetObjects()
{
}
LLPathfindingManager::request_id_t LLFloaterPathfindingObjects::getNewRequestId()
{
return ++mMessagingRequestId;
}
void LLFloaterPathfindingObjects::handleNewObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList)
{
llassert(pRequestId <= mMessagingRequestId);
if (pRequestId == mMessagingRequestId)
{
switch (pRequestStatus)
{
case LLPathfindingManager::kRequestStarted :
setMessagingState(kMessagingGetRequestSent);
break;
case LLPathfindingManager::kRequestCompleted :
mObjectList = pObjectList;
rebuildObjectsScrollList();
setMessagingState(kMessagingComplete);
break;
case LLPathfindingManager::kRequestNotEnabled :
clearAllObjects();
setMessagingState(kMessagingNotEnabled);
break;
case LLPathfindingManager::kRequestError :
clearAllObjects();
setMessagingState(kMessagingGetError);
break;
default :
clearAllObjects();
setMessagingState(kMessagingGetError);
llassert(0);
break;
}
}
}
void LLFloaterPathfindingObjects::handleUpdateObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList)
{
llassert(pRequestId <= mMessagingRequestId);
if (pRequestId == mMessagingRequestId)
{
switch (pRequestStatus)
{
case LLPathfindingManager::kRequestStarted :
setMessagingState(kMessagingGetRequestSent);
break;
case LLPathfindingManager::kRequestCompleted :
if (mObjectList == NULL)
{
mObjectList = pObjectList;
}
else
{
mObjectList->update(pObjectList);
}
rebuildObjectsScrollList();
setMessagingState(kMessagingComplete);
break;
case LLPathfindingManager::kRequestNotEnabled :
clearAllObjects();
setMessagingState(kMessagingNotEnabled);
break;
case LLPathfindingManager::kRequestError :
setMessagingState(kMessagingGetError);
break;
default :
setMessagingState(kMessagingGetError);
llassert(0);
break;
}
}
}
void LLFloaterPathfindingObjects::rebuildObjectsScrollList()
{
std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected();
int numSelectedItems = selectedItems.size();
uuid_vec_t selectedUUIDs;
if (numSelectedItems > 0)
{
selectedUUIDs.reserve(selectedItems.size());
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
itemIter != selectedItems.end(); ++itemIter)
{
const LLScrollListItem *listItem = *itemIter;
selectedUUIDs.push_back(listItem->getUUID());
}
}
S32 origScrollPosition = mObjectsScrollList->getScrollPos();
mObjectsScrollList->deleteAllItems();
if ((mObjectList != NULL) && !mObjectList->isEmpty())
{
LLSD scrollListData = convertObjectsIntoScrollListData(mObjectList);
llassert(scrollListData.isArray());
for (LLSD::array_const_iterator elementIter = scrollListData.beginArray(); elementIter != scrollListData.endArray(); ++elementIter)
{
const LLSD &element = *elementIter;
mObjectsScrollList->addElement(element);
}
}
mObjectsScrollList->selectMultiple(selectedUUIDs);
mObjectsScrollList->setScrollPos(origScrollPosition);
updateControls();
}
LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const
{
llassert(0);
LLSD nullObjs = LLSD::emptyArray();
return nullObjs;
}
void LLFloaterPathfindingObjects::updateControls()
{
updateMessagingStatus();
updateStateOnListActionControls();
updateStateOnEditFields();
}
void LLFloaterPathfindingObjects::updateSelection()
{
mObjectsSelection.clear();
LLSelectMgr::getInstance()->deselectAll();
std::vector<LLScrollListItem *> selectedItems = mObjectsScrollList->getAllSelected();
if (!selectedItems.empty())
{
int numSelectedItems = selectedItems.size();
std::vector<LLViewerObject *>viewerObjects;
viewerObjects.reserve(numSelectedItems);
for (std::vector<LLScrollListItem *>::const_iterator selectedItemIter = selectedItems.begin();
selectedItemIter != selectedItems.end(); ++selectedItemIter)
{
const LLScrollListItem *selectedItem = *selectedItemIter;
LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID());
if (viewerObject != NULL)
{
viewerObjects.push_back(viewerObject);
}
}
if (!viewerObjects.empty())
{
mObjectsSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects);
}
}
updateControls();
}
S32 LLFloaterPathfindingObjects::getNameColumnIndex() const
{
return 0;
}
const LLColor4 &LLFloaterPathfindingObjects::getBeaconColor() const
{
return mDefaultBeaconColor;
}
const LLColor4 &LLFloaterPathfindingObjects::getBeaconTextColor() const
{
return mDefaultBeaconTextColor;
}
S32 LLFloaterPathfindingObjects::getBeaconWidth() const
{
return DEFAULT_BEACON_WIDTH;
}
BOOL LLFloaterPathfindingObjects::isShowBeacons() const
{
return mShowBeaconCheckBox->get();
}
void LLFloaterPathfindingObjects::clearAllObjects()
{
selectNoneObjects();
mObjectsScrollList->clear();
mObjectList.reset();
}
void LLFloaterPathfindingObjects::selectAllObjects()
{
mObjectsScrollList->selectAll();
}
void LLFloaterPathfindingObjects::selectNoneObjects()
{
mObjectsScrollList->deselectAllItems();
}
void LLFloaterPathfindingObjects::teleportToSelectedObject()
{
std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected();
llassert(selectedItems.size() == 1);
if (selectedItems.size() == 1)
{
std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front();
const LLScrollListItem *selectedItem = selectedItemRef;
llassert(mObjectList != NULL);
const LLPathfindingObjectPtr objectPtr = mObjectList->find(selectedItem->getUUID().asString());
const LLVector3 &objectLocation = objectPtr->getLocation();
LLViewerRegion* region = gAgent.getRegion();
if (region != NULL)
{
gAgent.teleportRequest(region->getHandle(), objectLocation, true);
}
}
}
LLPathfindingObjectListPtr LLFloaterPathfindingObjects::getEmptyObjectList() const
{
llassert(0);
LLPathfindingObjectListPtr objectListPtr(new LLPathfindingObjectList());
return objectListPtr;
}
int LLFloaterPathfindingObjects::getNumSelectedObjects() const
{
return mObjectsScrollList->getNumSelected();
}
LLPathfindingObjectListPtr LLFloaterPathfindingObjects::getSelectedObjects() const
{
LLPathfindingObjectListPtr selectedObjects = getEmptyObjectList();
std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected();
if (!selectedItems.empty())
{
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
itemIter != selectedItems.end(); ++itemIter)
{
LLPathfindingObjectPtr objectPtr = findObject(*itemIter);
if (objectPtr != NULL)
{
selectedObjects->update(objectPtr);
}
}
}
return selectedObjects;
}
LLPathfindingObjectPtr LLFloaterPathfindingObjects::getFirstSelectedObject() const
{
LLPathfindingObjectPtr objectPtr;
std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected();
if (!selectedItems.empty())
{
objectPtr = findObject(selectedItems.front());
}
return objectPtr;
}
LLFloaterPathfindingObjects::EMessagingState LLFloaterPathfindingObjects::getMessagingState() const
{
return mMessagingState;
}
void LLFloaterPathfindingObjects::setMessagingState(EMessagingState pMessagingState)
{
mMessagingState = pMessagingState;
updateControls();
}
void LLFloaterPathfindingObjects::onRefreshObjectsClicked()
{
requestGetObjects();
}
void LLFloaterPathfindingObjects::onSelectAllObjectsClicked()
{
selectAllObjects();
}
void LLFloaterPathfindingObjects::onSelectNoneObjectsClicked()
{
selectNoneObjects();
}
void LLFloaterPathfindingObjects::onTakeClicked()
{
handle_take();
}
void LLFloaterPathfindingObjects::onTakeCopyClicked()
{
handle_take_copy();
}
void LLFloaterPathfindingObjects::onReturnClicked()
{
handle_object_return();
}
void LLFloaterPathfindingObjects::onDeleteClicked()
{
handle_object_delete();
}
void LLFloaterPathfindingObjects::onTeleportClicked()
{
teleportToSelectedObject();
}
void LLFloaterPathfindingObjects::onScrollListSelectionChanged()
{
updateSelection();
}
void LLFloaterPathfindingObjects::onSelectionListChanged()
{
updateControls();
}
void LLFloaterPathfindingObjects::onRegionBoundaryCrossed()
{
requestGetObjects();
}
void LLFloaterPathfindingObjects::updateMessagingStatus()
{
std::string statusText("");
LLStyle::Params styleParams;
switch (getMessagingState())
{
case kMessagingUnknown:
statusText = getString("messaging_initial");
styleParams.color = mErrorTextColor;
break;
case kMessagingGetRequestSent :
statusText = getString("messaging_get_inprogress");
styleParams.color = mWarningTextColor;
break;
case kMessagingGetError :
statusText = getString("messaging_get_error");
styleParams.color = mErrorTextColor;
break;
case kMessagingSetRequestSent :
statusText = getString("messaging_set_inprogress");
styleParams.color = mWarningTextColor;
break;
case kMessagingSetError :
statusText = getString("messaging_set_error");
styleParams.color = mErrorTextColor;
break;
case kMessagingComplete :
if (mObjectsScrollList->isEmpty())
{
statusText = getString("messaging_complete_none_found");
}
else
{
S32 numItems = mObjectsScrollList->getItemCount();
S32 numSelectedItems = mObjectsScrollList->getNumSelected();
LLLocale locale(LLStringUtil::getLocale());
std::string numItemsString;
LLResMgr::getInstance()->getIntegerString(numItemsString, numItems);
std::string numSelectedItemsString;
LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems);
LLStringUtil::format_map_t string_args;
string_args["[NUM_SELECTED]"] = numSelectedItemsString;
string_args["[NUM_TOTAL]"] = numItemsString;
statusText = getString("messaging_complete_available", string_args);
}
break;
case kMessagingNotEnabled :
statusText = getString("messaging_not_enabled");
styleParams.color = mErrorTextColor;
break;
default:
statusText = getString("messaging_initial");
styleParams.color = mErrorTextColor;
llassert(0);
break;
}
mMessagingStatus->setText((LLStringExplicit)statusText, styleParams);
}
void LLFloaterPathfindingObjects::updateStateOnListActionControls()
{
switch (getMessagingState())
{
case kMessagingUnknown:
case kMessagingGetRequestSent :
case kMessagingSetRequestSent :
mRefreshListButton->setEnabled(FALSE);
mSelectAllButton->setEnabled(FALSE);
mSelectNoneButton->setEnabled(FALSE);
break;
case kMessagingGetError :
case kMessagingSetError :
case kMessagingNotEnabled :
mRefreshListButton->setEnabled(TRUE);
mSelectAllButton->setEnabled(FALSE);
mSelectNoneButton->setEnabled(FALSE);
break;
case kMessagingComplete :
{
int numItems = mObjectsScrollList->getItemCount();
int numSelectedItems = mObjectsScrollList->getNumSelected();
mRefreshListButton->setEnabled(TRUE);
mSelectAllButton->setEnabled(numSelectedItems < numItems);
mSelectNoneButton->setEnabled(numSelectedItems > 0);
}
break;
default:
llassert(0);
break;
}
}
void LLFloaterPathfindingObjects::updateStateOnEditFields()
{
int numSelectedItems = mObjectsScrollList->getNumSelected();
bool isEditEnabled = (numSelectedItems > 0);
mShowBeaconCheckBox->setEnabled(isEditEnabled);
mTakeButton->setEnabled(isEditEnabled && visible_take_object());
mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy());
mReturnButton->setEnabled(isEditEnabled && enable_object_return());
mDeleteButton->setEnabled(isEditEnabled && enable_object_delete());
mTeleportButton->setEnabled(numSelectedItems == 1);
}
LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollListItem *pListItem) const
{
LLPathfindingObjectPtr objectPtr;
LLUUID uuid = pListItem->getUUID();
const std::string &uuidString = uuid.asString();
llassert(mObjectList != NULL);
objectPtr = mObjectList->find(uuidString);
return objectPtr;
}

View File

@ -0,0 +1,152 @@
/**
* @file llfloaterpathfindingobjects.h
* @brief Header file for llfloaterpathfindingobjects
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLFLOATERPATHFINDINGOBJECTS_H
#define LL_LLFLOATERPATHFINDINGOBJECTS_H
#include <boost/signals2.hpp>
#include "llfloater.h"
#include "llpathfindingmanager.h"
#include "llpathfindingobject.h"
#include "llpathfindingobjectlist.h"
#include "llselectmgr.h"
#include "v4color.h"
class LLButton;
class LLCheckBoxCtrl;
class LLScrollListCtrl;
class LLSD;
class LLTextBase;
class LLFloaterPathfindingObjects : public LLFloater
{
public:
virtual void onOpen(const LLSD &pKey);
virtual void onClose(bool pIsAppQuitting);
virtual void draw();
protected:
friend class LLFloaterReg;
typedef enum
{
kMessagingUnknown,
kMessagingGetRequestSent,
kMessagingGetError,
kMessagingSetRequestSent,
kMessagingSetError,
kMessagingComplete,
kMessagingNotEnabled
} EMessagingState;
LLFloaterPathfindingObjects(const LLSD &pSeed);
virtual ~LLFloaterPathfindingObjects();
virtual BOOL postBuild();
virtual void requestGetObjects();
LLPathfindingManager::request_id_t getNewRequestId();
void handleNewObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList);
void handleUpdateObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList);
void rebuildObjectsScrollList();
virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const;
virtual void updateControls();
virtual void updateSelection();
virtual S32 getNameColumnIndex() const;
virtual const LLColor4 &getBeaconColor() const;
virtual const LLColor4 &getBeaconTextColor() const;
virtual S32 getBeaconWidth() const;
BOOL isShowBeacons() const;
void clearAllObjects();
void selectAllObjects();
void selectNoneObjects();
void teleportToSelectedObject();
virtual LLPathfindingObjectListPtr getEmptyObjectList() const;
int getNumSelectedObjects() const;
LLPathfindingObjectListPtr getSelectedObjects() const;
LLPathfindingObjectPtr getFirstSelectedObject() const;
EMessagingState getMessagingState() const;
private:
LLFloaterPathfindingObjects(const LLFloaterPathfindingObjects &pOther);
void setMessagingState(EMessagingState pMessagingState);
void onRefreshObjectsClicked();
void onSelectAllObjectsClicked();
void onSelectNoneObjectsClicked();
void onTakeClicked();
void onTakeCopyClicked();
void onReturnClicked();
void onDeleteClicked();
void onTeleportClicked();
void onScrollListSelectionChanged();
void onSelectionListChanged();
void onRegionBoundaryCrossed();
void updateMessagingStatus();
void updateStateOnListActionControls();
void updateStateOnEditFields();
LLPathfindingObjectPtr findObject(const LLScrollListItem *pListItem) const;
LLScrollListCtrl *mObjectsScrollList;
LLTextBase *mMessagingStatus;
LLButton *mRefreshListButton;
LLButton *mSelectAllButton;
LLButton *mSelectNoneButton;
LLCheckBoxCtrl *mShowBeaconCheckBox;
LLButton *mTakeButton;
LLButton *mTakeCopyButton;
LLButton *mReturnButton;
LLButton *mDeleteButton;
LLButton *mTeleportButton;
LLColor4 mDefaultBeaconColor;
LLColor4 mDefaultBeaconTextColor;
LLColor4 mErrorTextColor;
LLColor4 mWarningTextColor;
EMessagingState mMessagingState;
LLPathfindingManager::request_id_t mMessagingRequestId;
LLPathfindingObjectListPtr mObjectList;
LLObjectSelectionHandle mObjectsSelection;
boost::signals2::connection mSelectionUpdateSlot;
boost::signals2::connection mRegionBoundaryCrossingSlot;
};
#endif // LL_LLFLOATERPATHFINDINGOBJECTS_H

View File

@ -3,9 +3,9 @@
* @author William Todd Stinson
* @brief Definition of a pathfinding character that contains various properties required for havok pathfinding.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -26,62 +26,28 @@
*/
#include "llviewerprecompiledheaders.h"
#include "llpathfindingcharacter.h"
#include "llsd.h"
#include "v3math.h"
#include "lluuid.h"
#include "llavatarname.h"
#include "llavatarnamecache.h"
#define CHARACTER_NAME_FIELD "name"
#define CHARACTER_DESCRIPTION_FIELD "description"
#define CHARACTER_OWNER_FIELD "owner"
#define CHARACTER_CPU_TIME_FIELD "cpu_time"
#define CHARACTER_POSITION_FIELD "position"
#include "llpathfindingcharacter.h"
#include "llpathfindingobject.h"
#include "llsd.h"
#define CHARACTER_CPU_TIME_FIELD "cpu_time"
//---------------------------------------------------------------------------
// LLPathfindingCharacter
//---------------------------------------------------------------------------
LLPathfindingCharacter::LLPathfindingCharacter(const std::string &pUUID, const LLSD& pCharacterItem)
: mUUID(pUUID),
mName(),
mDescription(),
mOwnerUUID(),
mOwnerName(),
mCPUTime(0U),
mLocation(LLVector3::zero)
LLPathfindingCharacter::LLPathfindingCharacter(const std::string &pUUID, const LLSD& pCharacterData)
: LLPathfindingObject(pUUID, pCharacterData),
mCPUTime(0U)
{
llassert(pCharacterItem.has(CHARACTER_NAME_FIELD));
llassert(pCharacterItem.get(CHARACTER_NAME_FIELD).isString());
mName = pCharacterItem.get(CHARACTER_NAME_FIELD).asString();
llassert(pCharacterItem.has(CHARACTER_DESCRIPTION_FIELD));
llassert(pCharacterItem.get(CHARACTER_DESCRIPTION_FIELD).isString());
mDescription = pCharacterItem.get(CHARACTER_DESCRIPTION_FIELD).asString();
llassert(pCharacterItem.has(CHARACTER_OWNER_FIELD));
llassert(pCharacterItem.get(CHARACTER_OWNER_FIELD).isUUID());
mOwnerUUID = pCharacterItem.get(CHARACTER_OWNER_FIELD).asUUID();
LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
llassert(pCharacterItem.has(CHARACTER_CPU_TIME_FIELD));
llassert(pCharacterItem.get(CHARACTER_CPU_TIME_FIELD).isReal());
mCPUTime = pCharacterItem.get(CHARACTER_CPU_TIME_FIELD).asReal();
llassert(pCharacterItem.has(CHARACTER_POSITION_FIELD));
llassert(pCharacterItem.get(CHARACTER_POSITION_FIELD).isArray());
mLocation.setValue(pCharacterItem.get(CHARACTER_POSITION_FIELD));
parseCharacterData(pCharacterData);
}
LLPathfindingCharacter::LLPathfindingCharacter(const LLPathfindingCharacter& pOther)
: mUUID(pOther.mUUID),
mName(pOther.mName),
mDescription(pOther.mDescription),
mOwnerUUID(pOther.mOwnerUUID),
mOwnerName(pOther.mOwnerName),
mCPUTime(pOther.mCPUTime),
mLocation(pOther.mLocation)
: LLPathfindingObject(pOther),
mCPUTime(pOther.mCPUTime)
{
}
@ -91,13 +57,16 @@ LLPathfindingCharacter::~LLPathfindingCharacter()
LLPathfindingCharacter& LLPathfindingCharacter::operator =(const LLPathfindingCharacter& pOther)
{
mUUID = pOther.mUUID;
mName = pOther.mName;
mDescription = pOther.mDescription;
mOwnerUUID = pOther.mOwnerUUID;
mOwnerName = pOther.mOwnerName;
dynamic_cast<LLPathfindingObject &>(*this) = pOther;
mCPUTime = pOther.mCPUTime;
mLocation = pOther.mLocation;
return *this;
}
void LLPathfindingCharacter::parseCharacterData(const LLSD &pCharacterData)
{
llassert(pCharacterData.has(CHARACTER_CPU_TIME_FIELD));
llassert(pCharacterData.get(CHARACTER_CPU_TIME_FIELD).isReal());
mCPUTime = pCharacterData.get(CHARACTER_CPU_TIME_FIELD).asReal();
}

View File

@ -28,43 +28,27 @@
#ifndef LL_LLPATHFINDINGCHARACTER_H
#define LL_LLPATHFINDINGCHARACTER_H
#include "v3math.h"
#include "lluuid.h"
#include "llavatarname.h"
#include <boost/shared_ptr.hpp>
#include "llpathfindingobject.h"
class LLSD;
class LLPathfindingCharacter;
typedef boost::shared_ptr<LLPathfindingCharacter> LLPathfindingCharacterPtr;
class LLPathfindingCharacter
class LLPathfindingCharacter : public LLPathfindingObject
{
public:
LLPathfindingCharacter(const std::string &pUUID, const LLSD &pCharacterItem);
LLPathfindingCharacter(const std::string &pUUID, const LLSD &pCharacterData);
LLPathfindingCharacter(const LLPathfindingCharacter& pOther);
virtual ~LLPathfindingCharacter();
LLPathfindingCharacter& operator = (const LLPathfindingCharacter& pOther);
LLPathfindingCharacter& operator =(const LLPathfindingCharacter& pOther);
inline const LLUUID& getUUID() const {return mUUID;};
inline const std::string& getName() const {return mName;};
inline const std::string& getDescription() const {return mDescription;};
inline const std::string getOwnerName() const {return mOwnerName.getCompleteName();};
inline F32 getCPUTime() const {return mCPUTime;};
inline const LLVector3& getLocation() const {return mLocation;};
inline F32 getCPUTime() const {return mCPUTime;};
protected:
private:
LLUUID mUUID;
std::string mName;
std::string mDescription;
LLUUID mOwnerUUID;
LLAvatarName mOwnerName;
F32 mCPUTime;
LLVector3 mLocation;
void parseCharacterData(const LLSD &pCharacterData);
F32 mCPUTime;
};
#endif // LL_LLPATHFINDINGCHARACTER_H

View File

@ -27,37 +27,42 @@
#include "llviewerprecompiledheaders.h"
#include <string>
#include <map>
#include "llpathfindingcharacterlist.h"
#include "llsd.h"
#include "lluuid.h"
#include "llpathfindingcharacter.h"
#include "llpathfindingcharacterlist.h"
#include "llpathfindingobject.h"
#include "llpathfindingobjectlist.h"
//---------------------------------------------------------------------------
// LLPathfindingCharacterList
//---------------------------------------------------------------------------
LLPathfindingCharacterList::LLPathfindingCharacterList()
: LLPathfindingCharacterMap()
: LLPathfindingObjectList()
{
}
LLPathfindingCharacterList::LLPathfindingCharacterList(const LLSD& pCharacterItems)
: LLPathfindingCharacterMap()
LLPathfindingCharacterList::LLPathfindingCharacterList(const LLSD& pCharacterListData)
: LLPathfindingObjectList()
{
for (LLSD::map_const_iterator characterItemIter = pCharacterItems.beginMap();
characterItemIter != pCharacterItems.endMap(); ++characterItemIter)
{
const std::string& uuid(characterItemIter->first);
const LLSD& characterData = characterItemIter->second;
LLPathfindingCharacterPtr character(new LLPathfindingCharacter(uuid, characterData));
insert(std::pair<std::string, LLPathfindingCharacterPtr>(uuid, character));
}
parseCharacterListData(pCharacterListData);
}
LLPathfindingCharacterList::~LLPathfindingCharacterList()
{
clear();
}
void LLPathfindingCharacterList::parseCharacterListData(const LLSD& pCharacterListData)
{
LLPathfindingObjectMap &objectMap = getObjectMap();
for (LLSD::map_const_iterator characterDataIter = pCharacterListData.beginMap();
characterDataIter != pCharacterListData.endMap(); ++characterDataIter)
{
const std::string& uuid(characterDataIter->first);
const LLSD& characterData = characterDataIter->second;
LLPathfindingObjectPtr character(new LLPathfindingCharacter(uuid, characterData));
objectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(uuid, character));
}
}

View File

@ -28,29 +28,22 @@
#ifndef LL_LLPATHFINDINGCHARACTERLIST_H
#define LL_LLPATHFINDINGCHARACTERLIST_H
#include <string>
#include <map>
#include "llpathfindingcharacter.h"
#include <boost/shared_ptr.hpp>
#include "llpathfindingobjectlist.h"
class LLSD;
class LLPathfindingCharacterList;
typedef boost::shared_ptr<LLPathfindingCharacterList> LLPathfindingCharacterListPtr;
typedef std::map<std::string, LLPathfindingCharacterPtr> LLPathfindingCharacterMap;
class LLPathfindingCharacterList : public LLPathfindingCharacterMap
class LLPathfindingCharacterList : public LLPathfindingObjectList
{
public:
LLPathfindingCharacterList();
LLPathfindingCharacterList(const LLSD& pCharacterItems);
LLPathfindingCharacterList(const LLSD& pCharacterListData);
virtual ~LLPathfindingCharacterList();
protected:
private:
void parseCharacterListData(const LLSD& pCharacterListData);
};
#endif // LL_LLPATHFINDINGCHARACTERLIST_H

View File

@ -29,15 +29,9 @@
#include "llpathfindinglinkset.h"
#include "v3math.h"
#include "llavatarname.h"
#include "llavatarnamecache.h"
#include "llpathfindingobject.h"
#include "llsd.h"
#include "lluuid.h"
#define LINKSET_NAME_FIELD "name"
#define LINKSET_DESCRIPTION_FIELD "description"
#define LINKSET_OWNER_FIELD "owner"
#define LINKSET_LAND_IMPACT_FIELD "landimpact"
#define LINKSET_MODIFIABLE_FIELD "modifiable"
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
@ -51,7 +45,6 @@
#define LINKSET_WALKABILITY_B_FIELD "B"
#define LINKSET_WALKABILITY_C_FIELD "C"
#define LINKSET_WALKABILITY_D_FIELD "D"
#define LINKSET_POSITION_FIELD "position"
#define LINKSET_CATEGORY_VALUE_INCLUDE 0
#define LINKSET_CATEGORY_VALUE_EXCLUDE 1
@ -64,15 +57,10 @@
const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0);
const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100);
LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem)
: mUUID(),
LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainData)
: LLPathfindingObject(),
mIsTerrain(true),
mName(),
mDescription(),
mOwnerUUID(),
mOwnerName(),
mLandImpact(0U),
mLocation(LLVector3::zero),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(true),
#endif // MISSING_MODIFIABLE_FIELD_WAR
@ -84,18 +72,13 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem)
mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE),
mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE)
{
parsePathfindingData(pTerrainLinksetItem);
parsePathfindingData(pTerrainData);
}
LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem)
: mUUID(pUUID),
LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetData)
: LLPathfindingObject(pUUID, pLinksetData),
mIsTerrain(false),
mName(),
mDescription(),
mOwnerUUID(),
mOwnerName(),
mLandImpact(0U),
mLocation(LLVector3::zero),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(false),
#endif // MISSING_MODIFIABLE_FIELD_WAR
@ -107,18 +90,14 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD&
mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE),
mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE)
{
parseObjectData(pLinksetItem);
parsePathfindingData(pLinksetItem);
parseLinksetData(pLinksetData);
parsePathfindingData(pLinksetData);
}
LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther)
: mUUID(pOther.mUUID),
mName(pOther.mName),
mDescription(pOther.mDescription),
mOwnerUUID(pOther.mOwnerUUID),
mOwnerName(pOther.mOwnerName),
: LLPathfindingObject(pOther),
mIsTerrain(pOther.mIsTerrain),
mLandImpact(pOther.mLandImpact),
mLocation(pOther.mLocation),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(pOther.mHasModifiable),
mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE),
@ -140,13 +119,10 @@ LLPathfindingLinkset::~LLPathfindingLinkset()
LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkset& pOther)
{
mUUID = pOther.mUUID;
mName = pOther.mName;
mDescription = pOther.mDescription;
mOwnerUUID = pOther.mOwnerUUID;
mOwnerName = pOther.mOwnerName;
dynamic_cast<LLPathfindingObject &>(*this) = pOther;
mIsTerrain = pOther.mIsTerrain;
mLandImpact = pOther.mLandImpact;
mLocation = pOther.mLocation;
#ifdef MISSING_MODIFIABLE_FIELD_WAR
if (pOther.mHasModifiable)
{
@ -166,18 +142,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse
return *this;
}
std::string LLPathfindingLinkset::getOwnerName() const
{
std::string ownerName;
if (hasOwnerName())
{
ownerName = mOwnerName.getCompleteName();
}
return ownerName;
}
BOOL LLPathfindingLinkset::isPhantom() const
{
return isPhantom(getLinksetUse());
@ -243,111 +207,85 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA,
return itemData;
}
void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem)
void LLPathfindingLinkset::parseLinksetData(const LLSD &pLinksetData)
{
llassert(pLinksetItem.has(LINKSET_NAME_FIELD));
llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString());
mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString();
llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD));
llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString());
mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString();
#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
llassert(pLinksetItem.has(LINKSET_OWNER_FIELD));
llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID());
mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID();
LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
if (pLinksetItem.has(LINKSET_OWNER_FIELD))
{
llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID());
mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID();
LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
}
#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
llassert(pLinksetItem.has(LINKSET_LAND_IMPACT_FIELD));
llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).isInteger());
llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0);
mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger();
llassert(pLinksetData.has(LINKSET_LAND_IMPACT_FIELD));
llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).isInteger());
llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0);
mLandImpact = pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger();
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD);
mHasModifiable = pLinksetData.has(LINKSET_MODIFIABLE_FIELD);
if (mHasModifiable)
{
llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
}
#else // MISSING_MODIFIABLE_FIELD_WAR
llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD));
llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
llassert(pLinksetData.has(LINKSET_MODIFIABLE_FIELD));
llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
#endif // MISSING_MODIFIABLE_FIELD_WAR
llassert(pLinksetItem.has(LINKSET_POSITION_FIELD));
llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray());
mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD));
}
void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem)
void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData)
{
bool isPhantom = false;
if (pLinksetItem.has(LINKSET_PHANTOM_FIELD))
if (pLinksetData.has(LINKSET_PHANTOM_FIELD))
{
llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean());
isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean();
llassert(pLinksetData.get(LINKSET_PHANTOM_FIELD).isBoolean());
isPhantom = pLinksetData.get(LINKSET_PHANTOM_FIELD).asBoolean();
}
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
if (pLinksetItem.has(LINKSET_CATEGORY_FIELD))
if (pLinksetData.has(LINKSET_CATEGORY_FIELD))
{
mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD)));
mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD)));
}
else
{
llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD));
llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean());
bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean();
llassert(pLinksetData.has(DEPRECATED_LINKSET_PERMANENT_FIELD));
llassert(pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean());
bool isPermanent = pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean();
llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD));
llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean());
bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean();
llassert(pLinksetData.has(DEPRECATED_LINKSET_WALKABLE_FIELD));
llassert(pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean());
bool isWalkable = pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean();
mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable);
}
#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD));
mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD)));
llassert(pLinksetData.has(LINKSET_CATEGORY_FIELD));
mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD)));
#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME))
if (pLinksetData.has(LINKSET_CAN_BE_VOLUME))
{
llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean());
mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean();
llassert(pLinksetData.get(LINKSET_CAN_BE_VOLUME).isBoolean());
mCanBeVolume = pLinksetData.get(LINKSET_CAN_BE_VOLUME).asBoolean();
}
llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD));
llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger());
mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger();
llassert(pLinksetData.has(LINKSET_WALKABILITY_A_FIELD));
llassert(pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).isInteger());
mWalkabilityCoefficientA = pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).asInteger();
llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE);
llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD));
llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger());
mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger();
llassert(pLinksetData.has(LINKSET_WALKABILITY_B_FIELD));
llassert(pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).isInteger());
mWalkabilityCoefficientB = pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).asInteger();
llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE);
llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD));
llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger());
mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger();
llassert(pLinksetData.has(LINKSET_WALKABILITY_C_FIELD));
llassert(pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).isInteger());
mWalkabilityCoefficientC = pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).asInteger();
llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE);
llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD));
llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger());
mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger();
llassert(pLinksetData.has(LINKSET_WALKABILITY_D_FIELD));
llassert(pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).isInteger());
mWalkabilityCoefficientD = pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).asInteger();
llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE);
}

View File

@ -28,21 +28,14 @@
#ifndef LL_LLPATHFINDINGLINKSET_H
#define LL_LLPATHFINDINGLINKSET_H
#include "v3math.h"
#include "llavatarname.h"
#include "lluuid.h"
#include <boost/shared_ptr.hpp>
class LLSD;
class LLPathfindingLinkset;
typedef boost::shared_ptr<LLPathfindingLinkset> LLPathfindingLinksetPtr;
#include "llpathfindingobject.h"
#define DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
#define MISSING_MODIFIABLE_FIELD_WAR
class LLPathfindingLinkset
class LLSD;
class LLPathfindingLinkset : public LLPathfindingObject
{
public:
typedef enum
@ -56,21 +49,15 @@ public:
kDynamicPhantom
} ELinksetUse;
LLPathfindingLinkset(const LLSD &pTerrainLinksetItem);
LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetItem);
LLPathfindingLinkset(const LLSD &pTerrainData);
LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetData);
LLPathfindingLinkset(const LLPathfindingLinkset& pOther);
virtual ~LLPathfindingLinkset();
LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther);
inline bool isTerrain() const {return mIsTerrain;};
inline const LLUUID& getUUID() const {return mUUID;};
inline const std::string& getName() const {return mName;};
inline const std::string& getDescription() const {return mDescription;};
inline BOOL hasOwnerName() const {return mOwnerUUID.notNull();};
std::string getOwnerName() const;
inline U32 getLandImpact() const {return mLandImpact;};
inline const LLVector3& getLocation() const {return mLocation;};
BOOL isModifiable() const {return mIsModifiable;};
BOOL isPhantom() const;
BOOL canBeVolume() const {return mCanBeVolume;};
@ -100,8 +87,8 @@ private:
kNavMeshGenerationExclude
} ENavMeshGenerationCategory;
void parseObjectData(const LLSD &pLinksetItem);
void parsePathfindingData(const LLSD &pLinksetItem);
void parseLinksetData(const LLSD &pLinksetData);
void parsePathfindingData(const LLSD &pLinksetData);
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
static ELinksetUse getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable);
@ -114,14 +101,8 @@ private:
static LLSD convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory);
static ENavMeshGenerationCategory convertCategoryFromLLSD(const LLSD &llsd);
LLUUID mUUID;
bool mIsTerrain;
std::string mName;
std::string mDescription;
LLUUID mOwnerUUID;
LLAvatarName mOwnerName;
U32 mLandImpact;
LLVector3 mLocation;
#ifdef MISSING_MODIFIABLE_FIELD_WAR
bool mHasModifiable;
#endif // MISSING_MODIFIABLE_FIELD_WAR

View File

@ -27,72 +27,44 @@
#include "llviewerprecompiledheaders.h"
#include <string>
#include <map>
#include "llpathfindinglinksetlist.h"
#include "llsd.h"
#include "lluuid.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
#include "llpathfindingobject.h"
#include "llpathfindingobjectlist.h"
//---------------------------------------------------------------------------
// LLPathfindingLinksetList
//---------------------------------------------------------------------------
LLPathfindingLinksetList::LLPathfindingLinksetList()
: LLPathfindingLinksetMap()
: LLPathfindingObjectList()
{
}
LLPathfindingLinksetList::LLPathfindingLinksetList(const LLSD& pLinksetItems)
: LLPathfindingLinksetMap()
LLPathfindingLinksetList::LLPathfindingLinksetList(const LLSD& pLinksetListData)
: LLPathfindingObjectList()
{
for (LLSD::map_const_iterator linksetItemIter = pLinksetItems.beginMap();
linksetItemIter != pLinksetItems.endMap(); ++linksetItemIter)
{
const std::string& uuid(linksetItemIter->first);
const LLSD& linksetData = linksetItemIter->second;
LLPathfindingLinksetPtr linkset(new LLPathfindingLinkset(uuid, linksetData));
insert(std::pair<std::string, LLPathfindingLinksetPtr>(uuid, linkset));
}
parseLinksetListData(pLinksetListData);
}
LLPathfindingLinksetList::~LLPathfindingLinksetList()
{
clear();
}
void LLPathfindingLinksetList::update(const LLPathfindingLinksetList &pUpdateLinksetList)
{
for (LLPathfindingLinksetList::const_iterator updateLinksetIter = pUpdateLinksetList.begin();
updateLinksetIter != pUpdateLinksetList.end(); ++updateLinksetIter)
{
const std::string &uuid = updateLinksetIter->first;
const LLPathfindingLinksetPtr updateLinksetPtr = updateLinksetIter->second;
LLPathfindingLinksetList::iterator linksetIter = find(uuid);
if (linksetIter == end())
{
insert(std::pair<std::string, LLPathfindingLinksetPtr>(uuid, updateLinksetPtr));
}
else
{
LLPathfindingLinksetPtr linksetPtr = linksetIter->second;
*linksetPtr = *updateLinksetPtr;
}
}
}
LLSD LLPathfindingLinksetList::encodeObjectFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const
{
LLSD listData;
for (LLPathfindingLinksetMap::const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter)
for (const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter)
{
const LLPathfindingLinksetPtr linksetPtr = linksetIter->second;
if (!linksetPtr->isTerrain())
const LLPathfindingObjectPtr objectPtr = linksetIter->second;
const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get());
if (!linkset->isTerrain())
{
LLSD linksetData = linksetPtr->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD);
LLSD linksetData = linkset->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD);
if (!linksetData.isUndefined())
{
const std::string& uuid(linksetIter->first);
@ -107,16 +79,114 @@ LLSD LLPathfindingLinksetList::encodeObjectFields(LLPathfindingLinkset::ELinkset
LLSD LLPathfindingLinksetList::encodeTerrainFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const
{
LLSD terrainData;
for (LLPathfindingLinksetMap::const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter)
for (const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter)
{
const LLPathfindingLinksetPtr linksetPtr = linksetIter->second;
if (linksetPtr->isTerrain())
const LLPathfindingObjectPtr objectPtr = linksetIter->second;
const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get());
if (linkset->isTerrain())
{
terrainData = linksetPtr->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD);
terrainData = linkset->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD);
break;
}
}
return terrainData;
}
bool LLPathfindingLinksetList::isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const
{
bool isShowWarning = false;
for (const_iterator objectIter = begin(); !isShowWarning && (objectIter != end()); ++objectIter)
{
const LLPathfindingObjectPtr objectPtr = objectIter->second;
const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get());
isShowWarning = linkset->isShowUnmodifiablePhantomWarning(pLinksetUse);
}
return isShowWarning;
}
bool LLPathfindingLinksetList::isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const
{
bool isShowWarning = false;
for (const_iterator objectIter = begin(); !isShowWarning && (objectIter != end()); ++objectIter)
{
const LLPathfindingObjectPtr objectPtr = objectIter->second;
const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get());
isShowWarning = linkset->isShowCannotBeVolumeWarning(pLinksetUse);
}
return isShowWarning;
}
void LLPathfindingLinksetList::determinePossibleStates(BOOL &pCanBeWalkable, BOOL &pCanBeStaticObstacle, BOOL &pCanBeDynamicObstacle,
BOOL &pCanBeMaterialVolume, BOOL &pCanBeExclusionVolume, BOOL &pCanBeDynamicPhantom) const
{
pCanBeWalkable = FALSE;
pCanBeStaticObstacle = FALSE;
pCanBeDynamicObstacle = FALSE;
pCanBeMaterialVolume = FALSE;
pCanBeExclusionVolume = FALSE;
pCanBeDynamicPhantom = FALSE;
for (const_iterator objectIter = begin();
!(pCanBeWalkable && pCanBeStaticObstacle && pCanBeDynamicObstacle && pCanBeMaterialVolume && pCanBeExclusionVolume && pCanBeDynamicPhantom) && (objectIter != end());
++objectIter)
{
const LLPathfindingObjectPtr objectPtr = objectIter->second;
const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get());
if (linkset->isTerrain())
{
pCanBeWalkable = TRUE;
}
else
{
if (linkset->isModifiable())
{
pCanBeWalkable = TRUE;
pCanBeStaticObstacle = TRUE;
pCanBeDynamicObstacle = TRUE;
pCanBeDynamicPhantom = TRUE;
if (linkset->canBeVolume())
{
pCanBeMaterialVolume = TRUE;
pCanBeExclusionVolume = TRUE;
}
}
else if (linkset->isPhantom())
{
pCanBeDynamicPhantom = TRUE;
if (linkset->canBeVolume())
{
pCanBeMaterialVolume = TRUE;
pCanBeExclusionVolume = TRUE;
}
}
else
{
pCanBeWalkable = TRUE;
pCanBeStaticObstacle = TRUE;
pCanBeDynamicObstacle = TRUE;
}
}
}
}
void LLPathfindingLinksetList::parseLinksetListData(const LLSD& pLinksetListData)
{
LLPathfindingObjectMap &objectMap = getObjectMap();
for (LLSD::map_const_iterator linksetDataIter = pLinksetListData.beginMap();
linksetDataIter != pLinksetListData.endMap(); ++linksetDataIter)
{
const std::string& uuid(linksetDataIter->first);
const LLSD& linksetData = linksetDataIter->second;
LLPathfindingObjectPtr linksetPtr(new LLPathfindingLinkset(uuid, linksetData));
objectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(uuid, linksetPtr));
}
}

View File

@ -28,34 +28,32 @@
#ifndef LL_LLPATHFINDINGLINKSETLIST_H
#define LL_LLPATHFINDINGLINKSETLIST_H
#include <string>
#include <map>
#include "llpathfindinglinkset.h"
#include <boost/shared_ptr.hpp>
#include "llpathfindingobjectlist.h"
class LLSD;
class LLPathfindingLinksetList;
class LLVector3;
typedef boost::shared_ptr<LLPathfindingLinksetList> LLPathfindingLinksetListPtr;
typedef std::map<std::string, LLPathfindingLinksetPtr> LLPathfindingLinksetMap;
class LLPathfindingLinksetList : public LLPathfindingLinksetMap
class LLPathfindingLinksetList : public LLPathfindingObjectList
{
public:
LLPathfindingLinksetList();
LLPathfindingLinksetList(const LLSD& pLinksetItems);
LLPathfindingLinksetList(const LLSD& pLinksetListData);
virtual ~LLPathfindingLinksetList();
void update(const LLPathfindingLinksetList &pUpdateLinksetList);
LLSD encodeObjectFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const;
LLSD encodeTerrainFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const;
bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const;
bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const;
void determinePossibleStates(BOOL &pCanBeWalkable, BOOL &pCanBeStaticObstacle, BOOL &pCanBeDynamicObstacle,
BOOL &pCanBeMaterialVolume, BOOL &pCanBeExclusionVolume, BOOL &pCanBeDynamicPhantom) const;
protected:
private:
void parseLinksetListData(const LLSD& pLinksetListData);
};
#endif // LL_LLPATHFINDINGLINKSETLIST_H

View File

@ -25,30 +25,35 @@
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llpathfindingmanager.h"
#include <string>
#include <vector>
#include "llviewerprecompiledheaders.h"
#include "llsd.h"
#include "lluuid.h"
#include "llpathfindingmanager.h"
#include "llsingleton.h"
#include "llhttpclient.h"
#include "llagent.h"
#include "llviewerregion.h"
#include "llpathfindingnavmesh.h"
#include "llpathfindingnavmeshstatus.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
#include "llpathfindingcharacterlist.h"
#include "llhttpnode.h"
#include "llnotificationsutil.h"
#include "lltrans.h"
#include "llweb.h"
#include <boost/function.hpp>
#include <boost/signals2.hpp>
#include "llagent.h"
#include "llhttpclient.h"
#include "llhttpnode.h"
#include "llnotificationsutil.h"
#include "llpathfindingcharacter.h"
#include "llpathfindingcharacterlist.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
#include "llpathfindingnavmesh.h"
#include "llpathfindingnavmeshstatus.h"
#include "llpathfindingobject.h"
#include "llpathfindinglinksetlist.h"
#include "llsingleton.h"
#include "llsd.h"
#include "lltrans.h"
#include "lluuid.h"
#include "llviewerregion.h"
#include "llweb.h"
#define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc"
#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus"
@ -159,7 +164,7 @@ private:
class LinksetsResponder
{
public:
LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested);
LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested);
virtual ~LinksetsResponder();
void handleObjectLinksetsResult(const LLSD &pContent);
@ -180,14 +185,14 @@ private:
kReceivedError
} EMessagingState;
LLPathfindingManager::request_id_t mRequestId;
LLPathfindingManager::linksets_callback_t mLinksetsCallback;
LLPathfindingManager::request_id_t mRequestId;
LLPathfindingManager::object_request_callback_t mLinksetsCallback;
EMessagingState mObjectMessagingState;
EMessagingState mTerrainMessagingState;
EMessagingState mObjectMessagingState;
EMessagingState mTerrainMessagingState;
LLPathfindingLinksetListPtr mObjectLinksetListPtr;
LLPathfindingLinksetPtr mTerrainLinksetPtr;
LLPathfindingObjectListPtr mObjectLinksetListPtr;
LLPathfindingObjectPtr mTerrainLinksetPtr;
};
typedef boost::shared_ptr<LinksetsResponder> LinksetsResponderPtr;
@ -239,7 +244,7 @@ private:
class CharactersResponder : public LLHTTPClient::Responder
{
public:
CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback);
CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback);
virtual ~CharactersResponder();
virtual void result(const LLSD &pContent);
@ -248,9 +253,9 @@ public:
protected:
private:
std::string mCapabilityURL;
LLPathfindingManager::request_id_t mRequestId;
LLPathfindingManager::characters_callback_t mCharactersCallback;
std::string mCapabilityURL;
LLPathfindingManager::request_id_t mRequestId;
LLPathfindingManager::object_request_callback_t mCharactersCallback;
};
//---------------------------------------------------------------------------
@ -397,9 +402,9 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState
}
}
void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const
void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const
{
LLPathfindingLinksetListPtr emptyLinksetListPtr;
LLPathfindingObjectListPtr emptyLinksetListPtr;
LLViewerRegion *currentRegion = getCurrentRegion();
if (currentRegion == NULL)
@ -438,9 +443,9 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_
}
}
void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const
void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const
{
LLPathfindingLinksetListPtr emptyLinksetListPtr;
LLPathfindingObjectListPtr emptyLinksetListPtr;
std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion();
std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion();
@ -448,13 +453,19 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin
{
pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr);
}
else
else if ((pLinksetListPtr == NULL) || pLinksetListPtr->isEmpty())
{
LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD);
pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr);
}
else
{
const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(pLinksetListPtr.get());
LLSD objectPostData = linksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD);
LLSD terrainPostData;
if (isAllowViewTerrainProperties())
{
terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD);
terrainPostData = linksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD);
}
if (objectPostData.isUndefined() && terrainPostData.isUndefined())
@ -482,9 +493,9 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin
}
}
void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const
void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const
{
LLPathfindingCharacterListPtr emptyCharacterListPtr;
LLPathfindingObjectListPtr emptyCharacterListPtr;
LLViewerRegion *currentRegion = getCurrentRegion();
@ -549,7 +560,7 @@ void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegi
}
}
void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const
void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const
{
LLViewerRegion *currentRegion = getCurrentRegion();
@ -559,7 +570,7 @@ void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pReg
}
}
void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const
void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const
{
LLViewerRegion *currentRegion = getCurrentRegion();
@ -898,7 +909,7 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason)
// LinksetsResponder
//---------------------------------------------------------------------------
LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested)
LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested)
: mRequestId(pRequestId),
mLinksetsCallback(pLinksetsCallback),
mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested),
@ -914,7 +925,7 @@ LinksetsResponder::~LinksetsResponder()
void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent)
{
mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent));
mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList(pContent));
mObjectMessagingState = kReceivedGood;
if (mTerrainMessagingState != kWaiting)
@ -935,7 +946,7 @@ void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string
void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent)
{
mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent));
mTerrainLinksetPtr = LLPathfindingObjectPtr(new LLPathfindingLinkset(pContent));
mTerrainMessagingState = kReceivedGood;
if (mObjectMessagingState != kWaiting)
@ -964,12 +975,12 @@ void LinksetsResponder::sendCallback()
if (mObjectMessagingState != kReceivedGood)
{
mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList());
mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList());
}
if (mTerrainMessagingState == kReceivedGood)
{
mObjectLinksetListPtr->insert(std::pair<std::string, LLPathfindingLinksetPtr>(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr));
mObjectLinksetListPtr->update(mTerrainLinksetPtr);
}
mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr);
@ -1029,7 +1040,7 @@ void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason)
// CharactersResponder
//---------------------------------------------------------------------------
CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback)
CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback)
: LLHTTPClient::Responder(),
mCapabilityURL(pCapabilityURL),
mRequestId(pRequestId),
@ -1043,7 +1054,7 @@ CharactersResponder::~CharactersResponder()
void CharactersResponder::result(const LLSD &pContent)
{
LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent));
LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList(pContent));
mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr);
}
@ -1051,7 +1062,6 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason)
{
llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl;
LLPathfindingCharacterListPtr characterListPtr;
LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList());
mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr);
}

View File

@ -28,19 +28,18 @@
#ifndef LL_LLPATHFINDINGMANAGER_H
#define LL_LLPATHFINDINGMANAGER_H
#include "llsingleton.h"
#include "lluuid.h"
#include "llpathfindingnavmesh.h"
#include "llpathfindinglinkset.h"
#include "llpathfindinglinksetlist.h"
#include "llpathfindingcharacterlist.h"
#include <string>
#include <map>
#include <boost/function.hpp>
#include <boost/signals2.hpp>
#include "llpathfindinglinkset.h"
#include "llpathfindingobjectlist.h"
#include "llpathfindingnavmesh.h"
#include "llsingleton.h"
#include "lluuid.h"
class LLFloater;
class LLViewerRegion;
class LLPathfindingNavMeshStatus;
@ -73,11 +72,6 @@ public:
kRequestError
} ERequestStatus;
typedef U32 request_id_t;
typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingLinksetListPtr)> linksets_callback_t;
typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingCharacterListPtr)> characters_callback_t;
LLPathfindingManager();
virtual ~LLPathfindingManager();
@ -98,10 +92,13 @@ public:
EAgentState getLastKnownNonErrorAgentState() const;
void requestSetAgentState(EAgentState pAgentState);
void requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const;
void requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const;
typedef U32 request_id_t;
typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingObjectListPtr)> object_request_callback_t;
void requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const;
void requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const;
void requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const;
void requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
protected:
@ -109,8 +106,8 @@ private:
void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus);
void handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID);
void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const;
void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const;
void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const;
void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion);
void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus);

View File

@ -0,0 +1,136 @@
/**
* @file llpathfindingobject.cpp
* @brief Implementation of llpathfindingobject
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llpathfindingobject.h"
#include <string>
#include "v3math.h"
#include "llavatarname.h"
#include "llavatarnamecache.h"
#include "llsd.h"
#include "lluuid.h"
#define PATHFINDING_OBJECT_NAME_FIELD "name"
#define PATHFINDING_OBJECT_DESCRIPTION_FIELD "description"
#define PATHFINDING_OBJECT_OWNER_FIELD "owner"
#define PATHFINDING_OBJECT_POSITION_FIELD "position"
//---------------------------------------------------------------------------
// LLPathfindingObject
//---------------------------------------------------------------------------
LLPathfindingObject::LLPathfindingObject()
: mUUID(),
mName(),
mDescription(),
mOwnerUUID(),
mOwnerName(),
mLocation()
{
}
LLPathfindingObject::LLPathfindingObject(const std::string &pUUID, const LLSD &pObjectData)
: mUUID(pUUID),
mName(),
mDescription(),
mOwnerUUID(),
mOwnerName(),
mLocation()
{
parseObjectData(pObjectData);
}
LLPathfindingObject::LLPathfindingObject(const LLPathfindingObject& pOther)
: mUUID(pOther.mUUID),
mName(pOther.mName),
mDescription(pOther.mDescription),
mOwnerUUID(pOther.mOwnerUUID),
mOwnerName(pOther.mOwnerName),
mLocation(pOther.mLocation)
{
}
LLPathfindingObject::~LLPathfindingObject()
{
}
LLPathfindingObject &LLPathfindingObject::operator =(const LLPathfindingObject& pOther)
{
mUUID = pOther.mUUID;
mName = pOther.mName;
mDescription = pOther.mDescription;
mOwnerUUID = pOther.mOwnerUUID;
mOwnerName = pOther.mOwnerName;
mLocation = pOther.mLocation;
return *this;
}
std::string LLPathfindingObject::getOwnerName() const
{
std::string ownerName;
if (hasOwnerName())
{
ownerName = mOwnerName.getCompleteName();
}
return ownerName;
}
void LLPathfindingObject::parseObjectData(const LLSD &pObjectData)
{
llassert(pObjectData.has(PATHFINDING_OBJECT_NAME_FIELD));
llassert(pObjectData.get(PATHFINDING_OBJECT_NAME_FIELD).isString());
mName = pObjectData.get(PATHFINDING_OBJECT_NAME_FIELD).asString();
llassert(pObjectData.has(PATHFINDING_OBJECT_DESCRIPTION_FIELD));
llassert(pObjectData.get(PATHFINDING_OBJECT_DESCRIPTION_FIELD).isString());
mDescription = pObjectData.get(PATHFINDING_OBJECT_DESCRIPTION_FIELD).asString();
#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
llassert(pObjectData.has(PATHFINDING_OBJECT_OWNER_FIELD));
llassert(pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).isUUID());
mOwnerUUID = pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).asUUID();
LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
if (pObjectData.has(PATHFINDING_OBJECT_OWNER_FIELD))
{
llassert(pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).isUUID());
mOwnerUUID = pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).asUUID();
LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
}
#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
llassert(pObjectData.has(PATHFINDING_OBJECT_POSITION_FIELD));
llassert(pObjectData.get(PATHFINDING_OBJECT_POSITION_FIELD).isArray());
mLocation.setValue(pObjectData.get(PATHFINDING_OBJECT_POSITION_FIELD));
}

View File

@ -0,0 +1,73 @@
/**
* @file llpathfindingobject.h
* @brief Header file for llpathfindingobject
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLPATHFINDINGOBJECT_H
#define LL_LLPATHFINDINGOBJECT_H
#include "v3math.h"
#include "llavatarname.h"
#include "lluuid.h"
#include <string>
#include <boost/shared_ptr.hpp>
class LLPathfindingObject;
class LLSD;
typedef boost::shared_ptr<LLPathfindingObject> LLPathfindingObjectPtr;
class LLPathfindingObject
{
public:
LLPathfindingObject();
LLPathfindingObject(const std::string &pUUID, const LLSD &pObjectData);
LLPathfindingObject(const LLPathfindingObject& pOther);
virtual ~LLPathfindingObject();
LLPathfindingObject& operator =(const LLPathfindingObject& pOther);
inline const LLUUID& getUUID() const {return mUUID;};
inline const std::string& getName() const {return mName;};
inline const std::string& getDescription() const {return mDescription;};
inline BOOL hasOwnerName() const {return mOwnerUUID.notNull();};
std::string getOwnerName() const;
inline const LLVector3& getLocation() const {return mLocation;};
protected:
private:
void parseObjectData(const LLSD &pObjectData);
LLUUID mUUID;
std::string mName;
std::string mDescription;
LLUUID mOwnerUUID;
LLAvatarName mOwnerName;
LLVector3 mLocation;
};
#endif // LL_LLPATHFINDINGOBJECT_H

View File

@ -0,0 +1,110 @@
/**
* @file llpathfindingobjectlist.cpp
* @brief Implementation of llpathfindingobjectlist
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llpathfindingobjectlist.h"
#include <string>
#include <map>
//---------------------------------------------------------------------------
// LLPathfindingObjectList
//---------------------------------------------------------------------------
LLPathfindingObjectList::LLPathfindingObjectList()
: mObjectMap()
{
}
LLPathfindingObjectList::~LLPathfindingObjectList()
{
}
bool LLPathfindingObjectList::isEmpty() const
{
return mObjectMap.empty();
}
void LLPathfindingObjectList::update(LLPathfindingObjectPtr pUpdateObjectPtr)
{
if (pUpdateObjectPtr != NULL)
{
std::string updateObjectId = pUpdateObjectPtr->getUUID().asString();
LLPathfindingObjectMap::iterator foundObjectIter = mObjectMap.find(updateObjectId);
if (foundObjectIter == mObjectMap.end())
{
mObjectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(updateObjectId, pUpdateObjectPtr));
}
else
{
foundObjectIter->second = pUpdateObjectPtr;
}
}
}
void LLPathfindingObjectList::update(LLPathfindingObjectListPtr pUpdateObjectListPtr)
{
if ((pUpdateObjectListPtr != NULL) && !pUpdateObjectListPtr->isEmpty())
{
for (LLPathfindingObjectMap::const_iterator updateObjectIter = pUpdateObjectListPtr->begin();
updateObjectIter != pUpdateObjectListPtr->end(); ++updateObjectIter)
{
const LLPathfindingObjectPtr updateObjectPtr = updateObjectIter->second;
update(updateObjectPtr);
}
}
}
LLPathfindingObjectPtr LLPathfindingObjectList::find(const std::string &pObjectId) const
{
LLPathfindingObjectPtr objectPtr;
LLPathfindingObjectMap::const_iterator objectIter = mObjectMap.find(pObjectId);
if (objectIter != mObjectMap.end())
{
objectPtr = objectIter->second;
}
return objectPtr;
}
LLPathfindingObjectList::const_iterator LLPathfindingObjectList::begin() const
{
return mObjectMap.begin();
}
LLPathfindingObjectList::const_iterator LLPathfindingObjectList::end() const
{
return mObjectMap.end();
}
LLPathfindingObjectMap &LLPathfindingObjectList::getObjectMap()
{
return mObjectMap;
}

View File

@ -0,0 +1,68 @@
/**
* @file llpathfindingobjectlist.h
* @brief Header file for llpathfindingobjectlist
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLPATHFINDINGOBJECTLIST_H
#define LL_LLPATHFINDINGOBJECTLIST_H
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include "llpathfindingobject.h"
class LLSD;
class LLPathfindingObjectList;
typedef boost::shared_ptr<LLPathfindingObjectList> LLPathfindingObjectListPtr;
typedef std::map<std::string, LLPathfindingObjectPtr> LLPathfindingObjectMap;
class LLPathfindingObjectList
{
public:
LLPathfindingObjectList();
virtual ~LLPathfindingObjectList();
bool isEmpty() const;
void update(LLPathfindingObjectPtr pUpdateObjectPtr);
void update(LLPathfindingObjectListPtr pUpdateObjectListPtr);
LLPathfindingObjectPtr find(const std::string &pObjectId) const;
typedef LLPathfindingObjectMap::const_iterator const_iterator;
const_iterator begin() const;
const_iterator end() const;
protected:
LLPathfindingObjectMap &getObjectMap();
private:
LLPathfindingObjectMap mObjectMap;
};
#endif // LL_LLPATHFINDINGOBJECTLIST_H

View File

@ -104,6 +104,15 @@
<color
name="LtGreen"
value="0.2 1 0.2 1" />
<color
name="Red_80"
value="1 0 0 0.8" />
<color
name="Green_80"
value="0 1 0 0.8" />
<color
name="Blue_80"
value="0 0 1 0.8" />
<!-- This color name makes potentially unused colors show up bright purple.
Leave this here until all Unused? are removed below, otherwise
@ -635,6 +644,18 @@
<color
name="PathfindingGoodColor"
reference="LtGreen" />
<color
name="PathfindingDefaultBeaconColor"
reference="Red_80" />
<color
name="PathfindingDefaultBeaconTextColor"
reference="White" />
<color
name="PathfindingLinksetBeaconColor"
reference="Blue_80" />
<color
name="PathfindingCharacterBeaconColor"
reference="Red_80" />
<color
name="PieMenuBgColor"
value="0.24 0.24 0.24 0.59" />

View File

@ -14,12 +14,14 @@
save_rect="false"
single_instance="true"
title="Pathfinding characters">
<floater.string name="characters_messaging_initial"></floater.string>
<floater.string name="characters_messaging_get_inprogress">Querying for pathfinding characters ...</floater.string>
<floater.string name="characters_messaging_get_error">Error detected while querying for pathfinding characters.</floater.string>
<floater.string name="characters_messaging_complete_none_found">No pathfinding characters.</floater.string>
<floater.string name="characters_messaging_complete_available">[NUM_SELECTED] characters selected out of [NUM_TOTAL].</floater.string>
<floater.string name="characters_messaging_not_enabled">This region is not enabled for pathfinding.</floater.string>
<floater.string name="messaging_initial"></floater.string>
<floater.string name="messaging_get_inprogress">Querying for pathfinding characters ...</floater.string>
<floater.string name="messaging_get_error">Error detected while querying for pathfinding characters.</floater.string>
<floater.string name="messaging_set_inprogress"></floater.string>
<floater.string name="messaging_set_error"></floater.string>
<floater.string name="messaging_complete_none_found">No pathfinding characters.</floater.string>
<floater.string name="messaging_complete_available">[NUM_SELECTED] characters selected out of [NUM_TOTAL].</floater.string>
<floater.string name="messaging_not_enabled">This region is not enabled for pathfinding.</floater.string>
<floater.string name="character_cpu_time">[CPU_TIME] µs</floater.string>
<panel
border="false"
@ -38,7 +40,7 @@
top_pad="10"
tab_stop="false"
multi_select="true"
name="pathfinding_characters"
name="objects_scroll_list"
width="600">
<scroll_list.columns
label="Name"
@ -70,7 +72,7 @@
length="1"
follows="left|bottom|right"
layout="topleft"
name="characters_status"
name="messaging_status"
top_pad="17"
width="238">
Characters:
@ -80,7 +82,7 @@
height="21"
label="Refresh list"
layout="topleft"
name="refresh_characters_list"
name="refresh_objects_list"
top_pad="-29"
left_pad="0"
width="115"/>
@ -89,7 +91,7 @@
height="21"
label="Select all"
layout="topleft"
name="select_all_characters"
name="select_all_objects"
top_pad="-21"
left_pad="8"
width="115"/>
@ -98,7 +100,7 @@
height="21"
label="Select none"
layout="topleft"
name="select_none_characters"
name="select_none_objects"
top_pad="-21"
left_pad="8"
width="115"/>
@ -150,7 +152,7 @@
height="22"
label="Take"
layout="topleft"
name="take_characters"
name="take_objects"
top_pad="9"
left="18"
width="94"/>
@ -159,7 +161,7 @@
height="22"
label="Take copy"
layout="topleft"
name="take_copy_characters"
name="take_copy_objects"
top_pad="-22"
left_pad="6"
width="94"/>
@ -168,7 +170,7 @@
height="22"
label="Return"
layout="topleft"
name="return_characters"
name="return_objects"
top_pad="-22"
left_pad="6"
width="94"/>
@ -177,7 +179,7 @@
height="22"
label="Delete"
layout="topleft"
name="delete_characters"
name="delete_objects"
top_pad="-22"
left_pad="6"
width="94"/>
@ -186,7 +188,7 @@
height="22"
label="Teleport me to it"
layout="topleft"
name="teleport_to_character"
name="teleport_me_to_object"
tool_tip="Enabled only when one character is selected."
top_pad="-22"
left_pad="6"

View File

@ -14,14 +14,14 @@
save_rect="false"
single_instance="true"
title="Pathfinding linksets">
<floater.string name="linksets_messaging_initial"></floater.string>
<floater.string name="linksets_messaging_get_inprogress">Querying for pathfinding linksets ...</floater.string>
<floater.string name="linksets_messaging_get_error">Error detected while querying for pathfinding linksets.</floater.string>
<floater.string name="linksets_messaging_set_inprogress">Modifying selected pathfinding linksets ...</floater.string>
<floater.string name="linksets_messaging_set_error">Error detected while modifying selected pathfinding linksets.</floater.string>
<floater.string name="linksets_messaging_complete_none_found">No pathfinding linksets.</floater.string>
<floater.string name="linksets_messaging_complete_available">[NUM_SELECTED] linksets selected out of [NUM_TOTAL].</floater.string>
<floater.string name="linksets_messaging_not_enabled">This region is not enabled for pathfinding.</floater.string>
<floater.string name="messaging_initial"></floater.string>
<floater.string name="messaging_get_inprogress">Querying for pathfinding linksets ...</floater.string>
<floater.string name="messaging_get_error">Error detected while querying for pathfinding linksets.</floater.string>
<floater.string name="messaging_set_inprogress">Modifying selected pathfinding linksets ...</floater.string>
<floater.string name="messaging_set_error">Error detected while modifying selected pathfinding linksets.</floater.string>
<floater.string name="messaging_complete_none_found">No pathfinding linksets.</floater.string>
<floater.string name="messaging_complete_available">[NUM_SELECTED] linksets selected out of [NUM_TOTAL].</floater.string>
<floater.string name="messaging_not_enabled">This region is not enabled for pathfinding.</floater.string>
<floater.string name="linkset_terrain_name">[Terrain]</floater.string>
<floater.string name="linkset_terrain_description">--</floater.string>
<floater.string name="linkset_terrain_owner">--</floater.string>
@ -174,7 +174,7 @@
top_pad="15"
tab_stop="false"
multi_select="true"
name="pathfinding_linksets"
name="objects_scroll_list"
width="980">
<scroll_list.columns
label="Name (root prim)"
@ -226,7 +226,7 @@
length="1"
follows="left|bottom|right"
layout="topleft"
name="linksets_status"
name="messaging_status"
top_pad="17"
width="619">
Linksets:
@ -236,7 +236,7 @@
height="21"
label="Refresh list"
layout="topleft"
name="refresh_linksets_list"
name="refresh_objects_list"
top_pad="-16"
left_pad="0"
width="115"/>
@ -245,7 +245,7 @@
height="21"
label="Select all"
layout="topleft"
name="select_all_linksets"
name="select_all_objects"
top_pad="-21"
left_pad="8"
width="115"/>
@ -254,7 +254,7 @@
height="21"
label="Select none"
layout="topleft"
name="select_none_linksets"
name="select_none_objects"
top_pad="-21"
left_pad="8"
width="115"/>
@ -305,7 +305,7 @@
height="21"
label="Take"
layout="topleft"
name="take_linksets"
name="take_objects"
top_pad="9"
left="18"
width="95"/>
@ -314,7 +314,7 @@
height="21"
label="Take copy"
layout="topleft"
name="take_copy_linksets"
name="take_copy_objects"
top_pad="-21"
left_pad="6"
width="95"/>
@ -323,7 +323,7 @@
height="21"
label="Return"
layout="topleft"
name="return_linksets"
name="return_objects"
top_pad="-21"
left_pad="6"
width="95"/>
@ -332,7 +332,7 @@
height="21"
label="Delete"
layout="topleft"
name="delete_linksets"
name="delete_objects"
top_pad="-21"
left_pad="6"
width="95"/>
@ -341,7 +341,7 @@
height="21"
label="Teleport me to it"
layout="topleft"
name="teleport_me_to_linkset"
name="teleport_me_to_object"
top_pad="-21"
left_pad="6"
width="160"/>