PATH-187: Moving the filtered pathfinding linksets class into its own file.
parent
8330e11159
commit
58f299fb8a
|
|
@ -162,6 +162,7 @@ set(viewer_SOURCE_FILES
|
|||
llfavoritesbar.cpp
|
||||
llfeaturemanager.cpp
|
||||
llfilepicker.cpp
|
||||
llfilteredpathfindinglinksets.cpp
|
||||
llfilteredwearablelist.cpp
|
||||
llfirstuse.cpp
|
||||
llflexibleobject.cpp
|
||||
|
|
@ -415,7 +416,7 @@ set(viewer_SOURCE_FILES
|
|||
llparcelselection.cpp
|
||||
llparticipantlist.cpp
|
||||
llpatchvertexarray.cpp
|
||||
llpathfindinglinksets.cpp
|
||||
llpathfindinglinkset.cpp
|
||||
llphysicsmotion.cpp
|
||||
llphysicsshapebuilderutil.cpp
|
||||
llplacesinventorybridge.cpp
|
||||
|
|
@ -722,6 +723,7 @@ set(viewer_HEADER_FILES
|
|||
llfavoritesbar.h
|
||||
llfeaturemanager.h
|
||||
llfilepicker.h
|
||||
llfilteredpathfindinglinksets.h
|
||||
llfilteredwearablelist.h
|
||||
llfirstuse.h
|
||||
llflexibleobject.h
|
||||
|
|
@ -964,7 +966,7 @@ set(viewer_HEADER_FILES
|
|||
llparcelselection.h
|
||||
llparticipantlist.h
|
||||
llpatchvertexarray.h
|
||||
llpathfindinglinksets.h
|
||||
llpathfindinglinkset.h
|
||||
llphysicsmotion.h
|
||||
llphysicsshapebuilderutil.h
|
||||
llplacesinventorybridge.h
|
||||
|
|
|
|||
|
|
@ -0,0 +1,313 @@
|
|||
/**
|
||||
* @file llfilteredpathfindinglinksets.h
|
||||
* @author William Todd Stinson
|
||||
* @brief Class to implement the filtering of a set of pathfinding linksets
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, 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 <string>
|
||||
#include <map>
|
||||
|
||||
#include "llsd.h"
|
||||
#include "lluuid.h"
|
||||
#include "llpathfindinglinkset.h"
|
||||
#include "llfilteredpathfindinglinksets.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// FilterString
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FilterString::FilterString()
|
||||
: mFilter(),
|
||||
mUpperFilter()
|
||||
{
|
||||
}
|
||||
|
||||
FilterString::FilterString(const std::string& pFilter)
|
||||
: mFilter(pFilter),
|
||||
mUpperFilter()
|
||||
{
|
||||
LLStringUtil::trim(mFilter);
|
||||
mUpperFilter = mFilter;
|
||||
if (!mUpperFilter.empty())
|
||||
{
|
||||
LLStringUtil::toUpper(mUpperFilter);
|
||||
}
|
||||
}
|
||||
|
||||
FilterString::~FilterString()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& FilterString::get() const
|
||||
{
|
||||
return mFilter;
|
||||
}
|
||||
|
||||
bool FilterString::set(const std::string& pFilter)
|
||||
{
|
||||
std::string newFilter(pFilter);
|
||||
LLStringUtil::trim(newFilter);
|
||||
bool didFilterChange = (mFilter.compare(newFilter) != 0);
|
||||
if (didFilterChange)
|
||||
{
|
||||
mFilter = newFilter;
|
||||
mUpperFilter = newFilter;
|
||||
LLStringUtil::toUpper(mUpperFilter);
|
||||
}
|
||||
|
||||
return didFilterChange;
|
||||
}
|
||||
|
||||
void FilterString::clear()
|
||||
{
|
||||
mFilter.clear();
|
||||
mUpperFilter.clear();
|
||||
}
|
||||
|
||||
bool FilterString::isActive() const
|
||||
{
|
||||
return !mFilter.empty();
|
||||
}
|
||||
|
||||
bool FilterString::doesMatch(const std::string& pTestString) const
|
||||
{
|
||||
bool doesMatch = true;
|
||||
|
||||
if (isActive())
|
||||
{
|
||||
std::string upperTestString(pTestString);
|
||||
LLStringUtil::toUpper(upperTestString);
|
||||
doesMatch = (upperTestString.find(mUpperFilter) != std::string::npos);
|
||||
}
|
||||
|
||||
return doesMatch;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// LLFilteredPathfindingLinksets
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets()
|
||||
: mAllLinksets(),
|
||||
mFilteredLinksets(),
|
||||
mIsFiltersDirty(false),
|
||||
mNameFilter(),
|
||||
mDescriptionFilter(),
|
||||
mIsWalkableFilter(true),
|
||||
mIsObstacleFilter(true),
|
||||
mIsIgnoredFilter(true)
|
||||
{
|
||||
}
|
||||
|
||||
LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLSD& pNavMeshData)
|
||||
: mAllLinksets(),
|
||||
mFilteredLinksets(),
|
||||
mIsFiltersDirty(false),
|
||||
mNameFilter(),
|
||||
mDescriptionFilter(),
|
||||
mIsWalkableFilter(true),
|
||||
mIsObstacleFilter(true),
|
||||
mIsIgnoredFilter(true)
|
||||
{
|
||||
setPathfindingLinksets(pNavMeshData);
|
||||
}
|
||||
|
||||
LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLFilteredPathfindingLinksets& pOther)
|
||||
: mAllLinksets(pOther.mAllLinksets),
|
||||
mFilteredLinksets(pOther.mFilteredLinksets),
|
||||
mIsFiltersDirty(pOther.mIsFiltersDirty),
|
||||
mNameFilter(pOther.mNameFilter),
|
||||
mDescriptionFilter(pOther.mDescriptionFilter),
|
||||
mIsWalkableFilter(pOther.mIsWalkableFilter),
|
||||
mIsObstacleFilter(pOther.mIsObstacleFilter),
|
||||
mIsIgnoredFilter(pOther.mIsIgnoredFilter)
|
||||
{
|
||||
}
|
||||
|
||||
LLFilteredPathfindingLinksets::~LLFilteredPathfindingLinksets()
|
||||
{
|
||||
clearPathfindingLinksets();
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setPathfindingLinksets(const LLSD& pNavMeshData)
|
||||
{
|
||||
clearPathfindingLinksets();
|
||||
|
||||
for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
|
||||
navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
|
||||
{
|
||||
const std::string& uuid(navMeshDataIter->first);
|
||||
const LLSD& linksetData = navMeshDataIter->second;
|
||||
LLPathfindingLinkset linkset(uuid, linksetData);
|
||||
|
||||
mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
|
||||
mIsFiltersDirty = true;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::updatePathfindingLinksets(const LLSD& pNavMeshData)
|
||||
{
|
||||
for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
|
||||
navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
|
||||
{
|
||||
const std::string& uuid(navMeshDataIter->first);
|
||||
const LLSD& linksetData = navMeshDataIter->second;
|
||||
LLPathfindingLinkset linkset(uuid, linksetData);
|
||||
|
||||
PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid);
|
||||
if (linksetIter == mAllLinksets.end())
|
||||
{
|
||||
mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
else
|
||||
{
|
||||
linksetIter->second = linkset;
|
||||
}
|
||||
}
|
||||
|
||||
mIsFiltersDirty = true;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::clearPathfindingLinksets()
|
||||
{
|
||||
mAllLinksets.clear();
|
||||
mFilteredLinksets.clear();
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap& LLFilteredPathfindingLinksets::getAllLinksets() const
|
||||
{
|
||||
return mAllLinksets;
|
||||
}
|
||||
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap& LLFilteredPathfindingLinksets::getFilteredLinksets()
|
||||
{
|
||||
if (!isFiltersActive())
|
||||
{
|
||||
return mAllLinksets;
|
||||
}
|
||||
else
|
||||
{
|
||||
applyFilters();
|
||||
return mFilteredLinksets;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLFilteredPathfindingLinksets::isFiltersActive() const
|
||||
{
|
||||
return (mNameFilter.isActive() || mDescriptionFilter.isActive() || !mIsWalkableFilter || !mIsObstacleFilter || !mIsIgnoredFilter);
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setNameFilter(const std::string& pNameFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mNameFilter.set(pNameFilter) || mIsFiltersDirty);
|
||||
}
|
||||
|
||||
const std::string& LLFilteredPathfindingLinksets::getNameFilter() const
|
||||
{
|
||||
return mNameFilter.get();
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setDescriptionFilter(const std::string& pDescriptionFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mDescriptionFilter.set(pDescriptionFilter) || mIsFiltersDirty);
|
||||
}
|
||||
|
||||
const std::string& LLFilteredPathfindingLinksets::getDescriptionFilter() const
|
||||
{
|
||||
return mDescriptionFilter.get();
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setWalkableFilter(BOOL pWalkableFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsWalkableFilter == pWalkableFilter));
|
||||
mIsWalkableFilter = pWalkableFilter;
|
||||
}
|
||||
|
||||
BOOL LLFilteredPathfindingLinksets::isWalkableFilter() const
|
||||
{
|
||||
return mIsWalkableFilter;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setObstacleFilter(BOOL pObstacleFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsObstacleFilter == pObstacleFilter));
|
||||
mIsObstacleFilter = pObstacleFilter;
|
||||
}
|
||||
|
||||
BOOL LLFilteredPathfindingLinksets::isObstacleFilter() const
|
||||
{
|
||||
return mIsObstacleFilter;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::setIgnoredFilter(BOOL pIgnoredFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsIgnoredFilter == pIgnoredFilter));
|
||||
mIsIgnoredFilter = pIgnoredFilter;
|
||||
}
|
||||
|
||||
BOOL LLFilteredPathfindingLinksets::isIgnoredFilter() const
|
||||
{
|
||||
return mIsIgnoredFilter;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::clearFilters()
|
||||
{
|
||||
mNameFilter.clear();
|
||||
mDescriptionFilter.clear();
|
||||
mIsWalkableFilter = true;
|
||||
mIsObstacleFilter = true;
|
||||
mIsIgnoredFilter = true;
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
void LLFilteredPathfindingLinksets::applyFilters()
|
||||
{
|
||||
mFilteredLinksets.clear();
|
||||
|
||||
for (PathfindingLinksetMap::const_iterator linksetIter = mAllLinksets.begin();
|
||||
linksetIter != mAllLinksets.end(); ++linksetIter)
|
||||
{
|
||||
const std::string& uuid(linksetIter->first);
|
||||
const LLPathfindingLinkset& linkset(linksetIter->second);
|
||||
if (doesMatchFilters(linkset))
|
||||
{
|
||||
mFilteredLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
}
|
||||
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
BOOL LLFilteredPathfindingLinksets::doesMatchFilters(const LLPathfindingLinkset& pLinkset) const
|
||||
{
|
||||
return (((mIsWalkableFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kWalkable)) ||
|
||||
(mIsObstacleFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kObstacle)) ||
|
||||
(mIsIgnoredFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kIgnored))) &&
|
||||
(!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) &&
|
||||
(!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription())));
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* @file llfilteredpathfindinglinksets.h
|
||||
* @author William Todd Stinson
|
||||
* @brief Class to implement the filtering of a set of pathfinding linksets
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, 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_FILTEREDPATHFINDINGLINKSETS_H
|
||||
#define LL_FILTEREDPATHFINDINGLINKSETS_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
class LLSD;
|
||||
class LLPathfindingLinkset;
|
||||
|
||||
class FilterString
|
||||
{
|
||||
public:
|
||||
FilterString();
|
||||
FilterString(const std::string& pFilter);
|
||||
virtual ~FilterString();
|
||||
|
||||
const std::string& get() const;
|
||||
bool set(const std::string& pFilter);
|
||||
void clear();
|
||||
|
||||
bool isActive() const;
|
||||
bool doesMatch(const std::string& pTestString) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string mFilter;
|
||||
std::string mUpperFilter;
|
||||
};
|
||||
|
||||
class LLFilteredPathfindingLinksets
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, LLPathfindingLinkset> PathfindingLinksetMap;
|
||||
|
||||
LLFilteredPathfindingLinksets();
|
||||
LLFilteredPathfindingLinksets(const LLSD& pNavMeshData);
|
||||
LLFilteredPathfindingLinksets(const LLFilteredPathfindingLinksets& pOther);
|
||||
virtual ~LLFilteredPathfindingLinksets();
|
||||
|
||||
void setPathfindingLinksets(const LLSD& pNavMeshData);
|
||||
void updatePathfindingLinksets(const LLSD& pNavMeshData);
|
||||
void clearPathfindingLinksets();
|
||||
|
||||
const PathfindingLinksetMap& getAllLinksets() const;
|
||||
const PathfindingLinksetMap& getFilteredLinksets();
|
||||
|
||||
BOOL isFiltersActive() const;
|
||||
|
||||
void setNameFilter(const std::string& pNameFilter);
|
||||
const std::string& getNameFilter() const;
|
||||
|
||||
void setDescriptionFilter(const std::string& pDescriptionFilter);
|
||||
const std::string& getDescriptionFilter() const;
|
||||
|
||||
void setWalkableFilter(BOOL pWalkableFilter);
|
||||
BOOL isWalkableFilter() const;
|
||||
|
||||
void setObstacleFilter(BOOL pObstacleFilter);
|
||||
BOOL isObstacleFilter() const;
|
||||
|
||||
void setIgnoredFilter(BOOL pIgnoredFilter);
|
||||
BOOL isIgnoredFilter() const;
|
||||
|
||||
void clearFilters();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
PathfindingLinksetMap mAllLinksets;
|
||||
PathfindingLinksetMap mFilteredLinksets;
|
||||
|
||||
bool mIsFiltersDirty;
|
||||
FilterString mNameFilter;
|
||||
FilterString mDescriptionFilter;
|
||||
BOOL mIsWalkableFilter;
|
||||
BOOL mIsObstacleFilter;
|
||||
BOOL mIsIgnoredFilter;
|
||||
|
||||
void applyFilters();
|
||||
BOOL doesMatchFilters(const LLPathfindingLinkset& pLinkset) const;
|
||||
};
|
||||
|
||||
#endif // LL_FILTEREDPATHFINDINGLINKSETS_H
|
||||
|
|
@ -45,7 +45,8 @@
|
|||
#include "llviewerregion.h"
|
||||
#include "llhttpclient.h"
|
||||
#include "lluuid.h"
|
||||
#include "llpathfindinglinksets.h"
|
||||
#include "llpathfindinglinkset.h"
|
||||
#include "llfilteredpathfindinglinksets.h"
|
||||
|
||||
#define XUI_PATH_STATE_WALKABLE 1
|
||||
#define XUI_PATH_STATE_OBSTACLE 2
|
||||
|
|
@ -91,289 +92,6 @@ private:
|
|||
LLFloaterPathfindingLinksets *mLinksetsFloater;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// FilterString
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FilterString::FilterString()
|
||||
: mFilter(),
|
||||
mUpperFilter()
|
||||
{
|
||||
}
|
||||
|
||||
FilterString::FilterString(const std::string& pFilter)
|
||||
: mFilter(pFilter),
|
||||
mUpperFilter()
|
||||
{
|
||||
LLStringUtil::trim(mFilter);
|
||||
mUpperFilter = mFilter;
|
||||
if (!mUpperFilter.empty())
|
||||
{
|
||||
LLStringUtil::toUpper(mUpperFilter);
|
||||
}
|
||||
}
|
||||
|
||||
FilterString::FilterString(const FilterString& pOther)
|
||||
: mFilter(pOther.mFilter),
|
||||
mUpperFilter(pOther.mUpperFilter)
|
||||
{
|
||||
}
|
||||
|
||||
FilterString::~FilterString()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& FilterString::get() const
|
||||
{
|
||||
return mFilter;
|
||||
}
|
||||
|
||||
bool FilterString::set(const std::string& pFilter)
|
||||
{
|
||||
std::string newFilter(pFilter);
|
||||
LLStringUtil::trim(newFilter);
|
||||
bool didFilterChange = (mFilter.compare(newFilter) != 0);
|
||||
if (didFilterChange)
|
||||
{
|
||||
mFilter = newFilter;
|
||||
mUpperFilter = newFilter;
|
||||
LLStringUtil::toUpper(mUpperFilter);
|
||||
}
|
||||
|
||||
return didFilterChange;
|
||||
}
|
||||
|
||||
void FilterString::clear()
|
||||
{
|
||||
mFilter.clear();
|
||||
mUpperFilter.clear();
|
||||
}
|
||||
|
||||
bool FilterString::isActive() const
|
||||
{
|
||||
return !mFilter.empty();
|
||||
}
|
||||
|
||||
bool FilterString::doesMatch(const std::string& pTestString) const
|
||||
{
|
||||
bool doesMatch = true;
|
||||
|
||||
if (isActive())
|
||||
{
|
||||
std::string upperTestString(pTestString);
|
||||
LLStringUtil::toUpper(upperTestString);
|
||||
doesMatch = (upperTestString.find(mUpperFilter) != std::string::npos);
|
||||
}
|
||||
|
||||
return doesMatch;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// PathfindingLinksets
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PathfindingLinksets::PathfindingLinksets()
|
||||
: mAllLinksets(),
|
||||
mFilteredLinksets(),
|
||||
mIsFiltersDirty(false),
|
||||
mNameFilter(),
|
||||
mDescriptionFilter(),
|
||||
mIsWalkableFilter(true),
|
||||
mIsObstacleFilter(true),
|
||||
mIsIgnoredFilter(true)
|
||||
{
|
||||
}
|
||||
|
||||
PathfindingLinksets::PathfindingLinksets(const LLSD& pNavMeshData)
|
||||
: mAllLinksets(),
|
||||
mFilteredLinksets(),
|
||||
mIsFiltersDirty(false),
|
||||
mNameFilter(),
|
||||
mDescriptionFilter(),
|
||||
mIsWalkableFilter(true),
|
||||
mIsObstacleFilter(true),
|
||||
mIsIgnoredFilter(true)
|
||||
{
|
||||
setNavMeshData(pNavMeshData);
|
||||
}
|
||||
|
||||
PathfindingLinksets::PathfindingLinksets(const PathfindingLinksets& pOther)
|
||||
: mAllLinksets(pOther.mAllLinksets),
|
||||
mFilteredLinksets(pOther.mFilteredLinksets),
|
||||
mIsFiltersDirty(pOther.mIsFiltersDirty),
|
||||
mNameFilter(pOther.mNameFilter),
|
||||
mDescriptionFilter(pOther.mDescriptionFilter),
|
||||
mIsWalkableFilter(pOther.mIsWalkableFilter),
|
||||
mIsObstacleFilter(pOther.mIsObstacleFilter),
|
||||
mIsIgnoredFilter(pOther.mIsIgnoredFilter)
|
||||
{
|
||||
}
|
||||
|
||||
PathfindingLinksets::~PathfindingLinksets()
|
||||
{
|
||||
clearLinksets();
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setNavMeshData(const LLSD& pNavMeshData)
|
||||
{
|
||||
clearLinksets();
|
||||
|
||||
for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
|
||||
navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
|
||||
{
|
||||
const std::string& uuid(navMeshDataIter->first);
|
||||
const LLSD& linksetData = navMeshDataIter->second;
|
||||
LLPathfindingLinkset linkset(uuid, linksetData);
|
||||
|
||||
mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
|
||||
mIsFiltersDirty = true;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::updateNavMeshData(const LLSD& pNavMeshData)
|
||||
{
|
||||
for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
|
||||
navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
|
||||
{
|
||||
const std::string& uuid(navMeshDataIter->first);
|
||||
const LLSD& linksetData = navMeshDataIter->second;
|
||||
LLPathfindingLinkset linkset(uuid, linksetData);
|
||||
|
||||
PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid);
|
||||
if (linksetIter == mAllLinksets.end())
|
||||
{
|
||||
mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
else
|
||||
{
|
||||
linksetIter->second = linkset;
|
||||
}
|
||||
}
|
||||
|
||||
mIsFiltersDirty = true;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::clearLinksets()
|
||||
{
|
||||
mAllLinksets.clear();
|
||||
mFilteredLinksets.clear();
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getAllLinksets() const
|
||||
{
|
||||
return mAllLinksets;
|
||||
}
|
||||
|
||||
const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getFilteredLinksets()
|
||||
{
|
||||
if (!isFiltersActive())
|
||||
{
|
||||
return mAllLinksets;
|
||||
}
|
||||
else
|
||||
{
|
||||
applyFilters();
|
||||
return mFilteredLinksets;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL PathfindingLinksets::isFiltersActive() const
|
||||
{
|
||||
return (mNameFilter.isActive() || mDescriptionFilter.isActive() || !mIsWalkableFilter || !mIsObstacleFilter || !mIsIgnoredFilter);
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setNameFilter(const std::string& pNameFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mNameFilter.set(pNameFilter) || mIsFiltersDirty);
|
||||
}
|
||||
|
||||
const std::string& PathfindingLinksets::getNameFilter() const
|
||||
{
|
||||
return mNameFilter.get();
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setDescriptionFilter(const std::string& pDescriptionFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mDescriptionFilter.set(pDescriptionFilter) || mIsFiltersDirty);
|
||||
}
|
||||
|
||||
const std::string& PathfindingLinksets::getDescriptionFilter() const
|
||||
{
|
||||
return mDescriptionFilter.get();
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setWalkableFilter(BOOL pWalkableFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsWalkableFilter == pWalkableFilter));
|
||||
mIsWalkableFilter = pWalkableFilter;
|
||||
}
|
||||
|
||||
BOOL PathfindingLinksets::isWalkableFilter() const
|
||||
{
|
||||
return mIsWalkableFilter;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setObstacleFilter(BOOL pObstacleFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsObstacleFilter == pObstacleFilter));
|
||||
mIsObstacleFilter = pObstacleFilter;
|
||||
}
|
||||
|
||||
BOOL PathfindingLinksets::isObstacleFilter() const
|
||||
{
|
||||
return mIsObstacleFilter;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::setIgnoredFilter(BOOL pIgnoredFilter)
|
||||
{
|
||||
mIsFiltersDirty = (mIsFiltersDirty || (mIsIgnoredFilter == pIgnoredFilter));
|
||||
mIsIgnoredFilter = pIgnoredFilter;
|
||||
}
|
||||
|
||||
BOOL PathfindingLinksets::isIgnoredFilter() const
|
||||
{
|
||||
return mIsIgnoredFilter;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::clearFilters()
|
||||
{
|
||||
mNameFilter.clear();
|
||||
mDescriptionFilter.clear();
|
||||
mIsWalkableFilter = true;
|
||||
mIsObstacleFilter = true;
|
||||
mIsIgnoredFilter = true;
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
void PathfindingLinksets::applyFilters()
|
||||
{
|
||||
mFilteredLinksets.clear();
|
||||
|
||||
for (PathfindingLinksetMap::const_iterator linksetIter = mAllLinksets.begin();
|
||||
linksetIter != mAllLinksets.end(); ++linksetIter)
|
||||
{
|
||||
const std::string& uuid(linksetIter->first);
|
||||
const LLPathfindingLinkset& linkset(linksetIter->second);
|
||||
if (doesMatchFilters(linkset))
|
||||
{
|
||||
mFilteredLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
|
||||
}
|
||||
}
|
||||
|
||||
mIsFiltersDirty = false;
|
||||
}
|
||||
|
||||
BOOL PathfindingLinksets::doesMatchFilters(const LLPathfindingLinkset& pLinkset) const
|
||||
{
|
||||
return (((mIsWalkableFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kWalkable)) ||
|
||||
(mIsObstacleFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kObstacle)) ||
|
||||
(mIsIgnoredFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kIgnored))) &&
|
||||
(!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) &&
|
||||
(!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription())));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// LLFloaterPathfindingLinksets
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -557,7 +275,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataGetRequest()
|
|||
else
|
||||
{
|
||||
setMessagingState(kMessagingFetchStarting);
|
||||
mPathfindingLinksets.clearLinksets();
|
||||
mPathfindingLinksets.clearPathfindingLinksets();
|
||||
updateLinksetsList();
|
||||
|
||||
std::string navMeshDataURL = getCapabilityURL();
|
||||
|
|
@ -593,7 +311,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataPutRequest(const LLSD& pPostDa
|
|||
void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMeshData)
|
||||
{
|
||||
setMessagingState(kMessagingFetchReceived);
|
||||
mPathfindingLinksets.setNavMeshData(pNavMeshData);
|
||||
mPathfindingLinksets.setPathfindingLinksets(pNavMeshData);
|
||||
updateLinksetsList();
|
||||
setMessagingState(kMessagingComplete);
|
||||
}
|
||||
|
|
@ -601,7 +319,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMes
|
|||
void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string& pURL, const std::string& pErrorReason)
|
||||
{
|
||||
setMessagingState(kMessagingFetchError);
|
||||
mPathfindingLinksets.clearLinksets();
|
||||
mPathfindingLinksets.clearPathfindingLinksets();
|
||||
updateLinksetsList();
|
||||
llwarns << "Error fetching object navmesh properties from URL '" << pURL << "' because " << pErrorReason << llendl;
|
||||
}
|
||||
|
|
@ -609,7 +327,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string&
|
|||
void LLFloaterPathfindingLinksets::handleNavMeshDataPutReply(const LLSD& pModifiedData)
|
||||
{
|
||||
setMessagingState(kMessagingModifyReceived);
|
||||
mPathfindingLinksets.updateNavMeshData(pModifiedData);
|
||||
mPathfindingLinksets.updatePathfindingLinksets(pModifiedData);
|
||||
updateLinksetsList();
|
||||
setMessagingState(kMessagingComplete);
|
||||
}
|
||||
|
|
@ -729,9 +447,9 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
|
|||
updateLinksetsStatusMessage();
|
||||
|
||||
const LLVector3& avatarPosition = gAgent.getPositionAgent();
|
||||
const PathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
|
||||
|
||||
for (PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
|
||||
for (LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
|
||||
linksetIter != linksetMap.end(); ++linksetIter)
|
||||
{
|
||||
const LLPathfindingLinkset& linkset(linksetIter->second);
|
||||
|
|
@ -905,8 +623,8 @@ void LLFloaterPathfindingLinksets::updateEditFields()
|
|||
{
|
||||
LLScrollListItem *firstItem = selectedItems.front();
|
||||
|
||||
const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
|
||||
PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
|
||||
LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
|
||||
const LLPathfindingLinkset &linkset(linksetIter->second);
|
||||
|
||||
setPathState(linkset.getPathState());
|
||||
|
|
@ -936,7 +654,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
|
|||
S32 dValue = static_cast<S32>(atoi(dString.c_str()));
|
||||
BOOL isPhantom = mEditPhantom->getValue();
|
||||
|
||||
const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
|
||||
|
||||
LLSD editData;
|
||||
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
|
||||
|
|
@ -945,7 +663,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
|
|||
const LLScrollListItem *listItem = *itemIter;
|
||||
LLUUID uuid = listItem->getUUID();
|
||||
|
||||
const PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
|
||||
const LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
|
||||
const LLPathfindingLinkset &linkset = linksetIter->second;
|
||||
|
||||
LLSD itemData = linkset.getAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@
|
|||
#include "v3math.h"
|
||||
#include "llfloater.h"
|
||||
#include "lluuid.h"
|
||||
#include "llpathfindinglinksets.h"
|
||||
#include "llpathfindinglinkset.h"
|
||||
#include "llfilteredpathfindinglinksets.h"
|
||||
|
||||
class LLTextBase;
|
||||
class LLScrollListCtrl;
|
||||
|
|
@ -41,75 +42,6 @@ class LLCheckBoxCtrl;
|
|||
class LLRadioGroup;
|
||||
class LLButton;
|
||||
|
||||
class FilterString
|
||||
{
|
||||
public:
|
||||
FilterString();
|
||||
FilterString(const std::string& pFilter);
|
||||
FilterString(const FilterString& pOther);
|
||||
virtual ~FilterString();
|
||||
|
||||
const std::string& get() const;
|
||||
bool set(const std::string& pFilter);
|
||||
void clear();
|
||||
|
||||
bool isActive() const;
|
||||
bool doesMatch(const std::string& pTestString) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string mFilter;
|
||||
std::string mUpperFilter;
|
||||
};
|
||||
|
||||
class PathfindingLinksets
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, LLPathfindingLinkset> PathfindingLinksetMap;
|
||||
|
||||
PathfindingLinksets();
|
||||
PathfindingLinksets(const LLSD& pNavMeshData);
|
||||
PathfindingLinksets(const PathfindingLinksets& pOther);
|
||||
virtual ~PathfindingLinksets();
|
||||
|
||||
void setNavMeshData(const LLSD& pNavMeshData);
|
||||
void updateNavMeshData(const LLSD& pNavMeshData);
|
||||
void clearLinksets();
|
||||
|
||||
const PathfindingLinksetMap& getAllLinksets() const;
|
||||
const PathfindingLinksetMap& getFilteredLinksets();
|
||||
|
||||
BOOL isFiltersActive() const;
|
||||
void setNameFilter(const std::string& pNameFilter);
|
||||
const std::string& getNameFilter() const;
|
||||
void setDescriptionFilter(const std::string& pDescriptionFilter);
|
||||
const std::string& getDescriptionFilter() const;
|
||||
void setWalkableFilter(BOOL pWalkableFilter);
|
||||
BOOL isWalkableFilter() const;
|
||||
void setObstacleFilter(BOOL pObstacleFilter);
|
||||
BOOL isObstacleFilter() const;
|
||||
void setIgnoredFilter(BOOL pIgnoredFilter);
|
||||
BOOL isIgnoredFilter() const;
|
||||
void clearFilters();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
PathfindingLinksetMap mAllLinksets;
|
||||
PathfindingLinksetMap mFilteredLinksets;
|
||||
|
||||
bool mIsFiltersDirty;
|
||||
FilterString mNameFilter;
|
||||
FilterString mDescriptionFilter;
|
||||
BOOL mIsWalkableFilter;
|
||||
BOOL mIsObstacleFilter;
|
||||
BOOL mIsIgnoredFilter;
|
||||
|
||||
void applyFilters();
|
||||
BOOL doesMatchFilters(const LLPathfindingLinkset& pLinkset) const;
|
||||
};
|
||||
|
||||
class LLFloaterPathfindingLinksets
|
||||
: public LLFloater
|
||||
{
|
||||
|
|
@ -144,30 +76,30 @@ public:
|
|||
protected:
|
||||
|
||||
private:
|
||||
PathfindingLinksets mPathfindingLinksets;
|
||||
EMessagingState mMessagingState;
|
||||
LLScrollListCtrl *mLinksetsScrollList;
|
||||
LLTextBase *mLinksetsStatus;
|
||||
LLLineEditor *mFilterByName;
|
||||
LLLineEditor *mFilterByDescription;
|
||||
LLCheckBoxCtrl *mFilterByWalkable;
|
||||
LLCheckBoxCtrl *mFilterByObstacle;
|
||||
LLCheckBoxCtrl *mFilterByIgnored;
|
||||
LLRadioGroup *mEditPathState;
|
||||
LLUICtrl *mEditPathStateWalkable;
|
||||
LLUICtrl *mEditPathStateObstacle;
|
||||
LLUICtrl *mEditPathStateIgnored;
|
||||
LLTextBase *mLabelWalkabilityCoefficients;
|
||||
LLTextBase *mLabelEditA;
|
||||
LLTextBase *mLabelEditB;
|
||||
LLTextBase *mLabelEditC;
|
||||
LLTextBase *mLabelEditD;
|
||||
LLLineEditor *mEditA;
|
||||
LLLineEditor *mEditB;
|
||||
LLLineEditor *mEditC;
|
||||
LLLineEditor *mEditD;
|
||||
LLCheckBoxCtrl *mEditPhantom;
|
||||
LLButton *mApplyEdits;
|
||||
LLFilteredPathfindingLinksets mPathfindingLinksets;
|
||||
EMessagingState mMessagingState;
|
||||
LLScrollListCtrl *mLinksetsScrollList;
|
||||
LLTextBase *mLinksetsStatus;
|
||||
LLLineEditor *mFilterByName;
|
||||
LLLineEditor *mFilterByDescription;
|
||||
LLCheckBoxCtrl *mFilterByWalkable;
|
||||
LLCheckBoxCtrl *mFilterByObstacle;
|
||||
LLCheckBoxCtrl *mFilterByIgnored;
|
||||
LLRadioGroup *mEditPathState;
|
||||
LLUICtrl *mEditPathStateWalkable;
|
||||
LLUICtrl *mEditPathStateObstacle;
|
||||
LLUICtrl *mEditPathStateIgnored;
|
||||
LLTextBase *mLabelWalkabilityCoefficients;
|
||||
LLTextBase *mLabelEditA;
|
||||
LLTextBase *mLabelEditB;
|
||||
LLTextBase *mLabelEditC;
|
||||
LLTextBase *mLabelEditD;
|
||||
LLLineEditor *mEditA;
|
||||
LLLineEditor *mEditB;
|
||||
LLLineEditor *mEditC;
|
||||
LLLineEditor *mEditD;
|
||||
LLCheckBoxCtrl *mEditPhantom;
|
||||
LLButton *mApplyEdits;
|
||||
|
||||
// Does its own instance management, so clients not allowed
|
||||
// to allocate or destroy.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llpathfindinglinksets.h"
|
||||
#include "llpathfindinglinkset.h"
|
||||
#include "llsd.h"
|
||||
#include "v3math.h"
|
||||
#include "lluuid.h"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file llpathfindinglinksets.h
|
||||
* @file llpathfindinglinkset.h
|
||||
* @author William Todd Stinson
|
||||
* @brief Definition of a pathfinding linkset that contains various properties required for havok pathfinding.
|
||||
*
|
||||
|
|
@ -25,8 +25,8 @@
|
|||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPATHFINDINGLINKSETS_H
|
||||
#define LL_LLPATHFINDINGLINKSETS_H
|
||||
#ifndef LL_LLPATHFINDINGLINKSET_H
|
||||
#define LL_LLPATHFINDINGLINKSET_H
|
||||
|
||||
#include "v3math.h"
|
||||
#include "lluuid.h"
|
||||
|
|
@ -105,4 +105,4 @@ private:
|
|||
S32 mWalkabilityCoefficientD;
|
||||
};
|
||||
|
||||
#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H
|
||||
#endif // LL_LLPATHFINDINGLINKSET_H
|
||||
Loading…
Reference in New Issue