From 3c2be426e5e905076d00b9492c0e66c8b31caf19 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 18:47:12 -0700 Subject: First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated. --- indra/newview/llpathfindingobjectlist.cpp | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 indra/newview/llpathfindingobjectlist.cpp (limited to 'indra/newview/llpathfindingobjectlist.cpp') diff --git a/indra/newview/llpathfindingobjectlist.cpp b/indra/newview/llpathfindingobjectlist.cpp new file mode 100644 index 0000000000..cad3a0a00f --- /dev/null +++ b/indra/newview/llpathfindingobjectlist.cpp @@ -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 +#include + +//--------------------------------------------------------------------------- +// 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(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; +} -- cgit v1.3 From 3352a1eac15f752535b636866eeb966ec3900c62 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 19:39:08 -0700 Subject: Cleaning up some unreferenced headers and classes definitions from previous refactoring. --- indra/newview/llfloaterpathfindingcharacters.cpp | 5 ++-- indra/newview/llfloaterpathfindingcharacters.h | 8 +------ indra/newview/llfloaterpathfindinglinksets.cpp | 11 ++------- indra/newview/llfloaterpathfindinglinksets.h | 1 + indra/newview/llfloaterpathfindingobjects.cpp | 5 +--- indra/newview/llfloaterpathfindingobjects.h | 1 + indra/newview/llpathfindingcharacterlist.cpp | 2 +- indra/newview/llpathfindingcharacterlist.h | 1 - indra/newview/llpathfindinglinkset.cpp | 2 ++ indra/newview/llpathfindinglinkset.h | 30 +++++++++++++----------- indra/newview/llpathfindinglinksetlist.cpp | 5 +++- indra/newview/llpathfindinglinksetlist.h | 1 - indra/newview/llpathfindingmanager.cpp | 4 +--- indra/newview/llpathfindingmanager.h | 2 -- indra/newview/llpathfindingobject.h | 4 ++-- indra/newview/llpathfindingobjectlist.cpp | 2 ++ 16 files changed, 37 insertions(+), 47 deletions(-) (limited to 'indra/newview/llpathfindingobjectlist.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 6599bac6a6..59f54c12bf 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -33,9 +33,10 @@ #include "llfloaterpathfindingobjects.h" #include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" +#include "llpathfindingmanager.h" +#include "llpathfindingobjectlist.h" #include "llsd.h" -#include "lluuid.h" -#include "llviewerregion.h" +#include "lluicolortable.h" //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters diff --git a/indra/newview/llfloaterpathfindingcharacters.h b/indra/newview/llfloaterpathfindingcharacters.h index c4277b9d25..38fb4d48d7 100644 --- a/indra/newview/llfloaterpathfindingcharacters.h +++ b/indra/newview/llfloaterpathfindingcharacters.h @@ -29,17 +29,11 @@ #define LL_LLFLOATERPATHFINDINGCHARACTERS_H #include "llfloaterpathfindingobjects.h" -#include "llpathfindingcharacter.h" -#include "llpathfindingmanager.h" #include "llpathfindingobjectlist.h" #include "v4color.h" -class LLButton; -class LLCheckBoxCtrl; -class LLRadioGroup; -class LLScrollListCtrl; +class LLPathfindingCharacter; class LLSD; -class LLTextBase; class LLFloaterPathfindingCharacters : public LLFloaterPathfindingObjects { diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 7fe22f65cf..36f54ffae1 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -33,27 +33,20 @@ #include "llagent.h" #include "llbutton.h" -#include "llcheckboxctrl.h" #include "llcombobox.h" -#include "llfloater.h" #include "llfloaterreg.h" #include "lllineeditor.h" #include "llnotificationsutil.h" #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llpathfindingmanager.h" -#include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llsd.h" -#include "llselectmgr.h" #include "lltextbase.h" #include "lltextvalidate.h" -#include "lluuid.h" -#include "llviewermenu.h" -#include "llviewerobject.h" -#include "llviewerobjectlist.h" -#include "llviewerregion.h" +#include "lluicolortable.h" #include "v3math.h" +#include "v4color.h" #define XUI_LINKSET_USE_NONE 0 #define XUI_LINKSET_USE_WALKABLE 1 diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index bad803f420..d989e0ea4d 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -41,6 +41,7 @@ class LLScrollListItem; class LLSD; class LLTextBase; class LLUICtrl; +class LLVector3; class LLFloaterPathfindingLinksets : public LLFloaterPathfindingObjects { diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 3b3de3f417..e8d80c09d8 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -34,14 +34,10 @@ #include #include -#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" @@ -57,6 +53,7 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" +#include "v4color.h" #define DEFAULT_BEACON_WIDTH 6 diff --git a/indra/newview/llfloaterpathfindingobjects.h b/indra/newview/llfloaterpathfindingobjects.h index 7fa7f89f51..34eb129864 100644 --- a/indra/newview/llfloaterpathfindingobjects.h +++ b/indra/newview/llfloaterpathfindingobjects.h @@ -39,6 +39,7 @@ class LLButton; class LLCheckBoxCtrl; class LLScrollListCtrl; +class LLScrollListItem; class LLSD; class LLTextBase; diff --git a/indra/newview/llpathfindingcharacterlist.cpp b/indra/newview/llpathfindingcharacterlist.cpp index 53b21f436d..9b0ed14e35 100644 --- a/indra/newview/llpathfindingcharacterlist.cpp +++ b/indra/newview/llpathfindingcharacterlist.cpp @@ -29,10 +29,10 @@ #include "llpathfindingcharacterlist.h" -#include "llsd.h" #include "llpathfindingcharacter.h" #include "llpathfindingobject.h" #include "llpathfindingobjectlist.h" +#include "llsd.h" //--------------------------------------------------------------------------- // LLPathfindingCharacterList diff --git a/indra/newview/llpathfindingcharacterlist.h b/indra/newview/llpathfindingcharacterlist.h index a80db08c87..734cfcafa1 100644 --- a/indra/newview/llpathfindingcharacterlist.h +++ b/indra/newview/llpathfindingcharacterlist.h @@ -28,7 +28,6 @@ #ifndef LL_LLPATHFINDINGCHARACTERLIST_H #define LL_LLPATHFINDINGCHARACTERLIST_H -#include "llpathfindingcharacter.h" #include "llpathfindingobjectlist.h" class LLSD; diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index dca5b6c93d..5b321b4408 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -29,6 +29,8 @@ #include "llpathfindinglinkset.h" +#include + #include "llpathfindingobject.h" #include "llsd.h" diff --git a/indra/newview/llpathfindinglinkset.h b/indra/newview/llpathfindinglinkset.h index cda71dffb3..a598452ea5 100644 --- a/indra/newview/llpathfindinglinkset.h +++ b/indra/newview/llpathfindinglinkset.h @@ -28,6 +28,8 @@ #ifndef LL_LLPATHFINDINGLINKSET_H #define LL_LLPATHFINDINGLINKSET_H +#include + #include "llpathfindingobject.h" #define DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS @@ -56,23 +58,23 @@ public: LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther); - inline bool isTerrain() const {return mIsTerrain;}; - inline U32 getLandImpact() const {return mLandImpact;}; - BOOL isModifiable() const {return mIsModifiable;}; - BOOL isPhantom() const; - BOOL canBeVolume() const {return mCanBeVolume;}; - static ELinksetUse getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse); + inline bool isTerrain() const {return mIsTerrain;}; + inline U32 getLandImpact() const {return mLandImpact;}; + BOOL isModifiable() const {return mIsModifiable;}; + BOOL isPhantom() const; + BOOL canBeVolume() const {return mCanBeVolume;}; + static ELinksetUse getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse); - inline ELinksetUse getLinksetUse() const {return mLinksetUse;}; + inline ELinksetUse getLinksetUse() const {return mLinksetUse;}; - inline S32 getWalkabilityCoefficientA() const {return mWalkabilityCoefficientA;}; - inline S32 getWalkabilityCoefficientB() const {return mWalkabilityCoefficientB;}; - inline S32 getWalkabilityCoefficientC() const {return mWalkabilityCoefficientC;}; - inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;}; + inline S32 getWalkabilityCoefficientA() const {return mWalkabilityCoefficientA;}; + inline S32 getWalkabilityCoefficientB() const {return mWalkabilityCoefficientB;}; + inline S32 getWalkabilityCoefficientC() const {return mWalkabilityCoefficientC;}; + inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;}; - bool isShowUnmodifiablePhantomWarning(ELinksetUse pLinksetUse) const; - bool isShowCannotBeVolumeWarning(ELinksetUse pLinksetUse) const; - LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; + bool isShowUnmodifiablePhantomWarning(ELinksetUse pLinksetUse) const; + bool isShowCannotBeVolumeWarning(ELinksetUse pLinksetUse) const; + LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; static const S32 MIN_WALKABILITY_VALUE; static const S32 MAX_WALKABILITY_VALUE; diff --git a/indra/newview/llpathfindinglinksetlist.cpp b/indra/newview/llpathfindinglinksetlist.cpp index 0ba6ef07f3..5323635438 100644 --- a/indra/newview/llpathfindinglinksetlist.cpp +++ b/indra/newview/llpathfindinglinksetlist.cpp @@ -29,10 +29,13 @@ #include "llpathfindinglinksetlist.h" -#include "llsd.h" +#include +#include + #include "llpathfindinglinkset.h" #include "llpathfindingobject.h" #include "llpathfindingobjectlist.h" +#include "llsd.h" //--------------------------------------------------------------------------- // LLPathfindingLinksetList diff --git a/indra/newview/llpathfindinglinksetlist.h b/indra/newview/llpathfindinglinksetlist.h index 7bd6986094..50a8e069d0 100644 --- a/indra/newview/llpathfindinglinksetlist.h +++ b/indra/newview/llpathfindinglinksetlist.h @@ -32,7 +32,6 @@ #include "llpathfindingobjectlist.h" class LLSD; -class LLVector3; class LLPathfindingLinksetList : public LLPathfindingObjectList { diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index b8b9dff51c..e282a3e2f4 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -30,7 +30,7 @@ #include "llpathfindingmanager.h" #include -#include +#include #include #include @@ -39,14 +39,12 @@ #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" diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index 172670cdf8..3c9af91e7b 100644 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -40,7 +40,6 @@ #include "llsingleton.h" #include "lluuid.h" -class LLFloater; class LLViewerRegion; class LLPathfindingNavMeshStatus; @@ -143,4 +142,3 @@ private: }; #endif // LL_LLPATHFINDINGMANAGER_H - diff --git a/indra/newview/llpathfindingobject.h b/indra/newview/llpathfindingobject.h index 9dc114b40f..880a3a6864 100644 --- a/indra/newview/llpathfindingobject.h +++ b/indra/newview/llpathfindingobject.h @@ -27,9 +27,9 @@ #ifndef LL_LLPATHFINDINGOBJECT_H #define LL_LLPATHFINDINGOBJECT_H -#include "v3math.h" #include "llavatarname.h" #include "lluuid.h" +#include "v3math.h" #include @@ -60,7 +60,7 @@ public: protected: private: - void parseObjectData(const LLSD &pObjectData); + void parseObjectData(const LLSD &pObjectData); LLUUID mUUID; std::string mName; diff --git a/indra/newview/llpathfindingobjectlist.cpp b/indra/newview/llpathfindingobjectlist.cpp index cad3a0a00f..68a7e736e6 100644 --- a/indra/newview/llpathfindingobjectlist.cpp +++ b/indra/newview/llpathfindingobjectlist.cpp @@ -32,6 +32,8 @@ #include #include +#include "llpathfindingobject.h" + //--------------------------------------------------------------------------- // LLPathfindingObjectList //--------------------------------------------------------------------------- -- cgit v1.3