1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-15 14:09:06 +00:00

Little optimization for molestPath()

This commit is contained in:
fgenesis 2013-12-10 03:48:40 +01:00
parent 70286954a0
commit 204152a783
2 changed files with 8 additions and 20 deletions

View file

@ -220,17 +220,10 @@ void VectorPath::splice(const VectorPath &path, int sz)
}
}
void VectorPath::removeNodes(int startInclusive, int endInclusive)
void VectorPath::removeNodes(unsigned int startInclusive, unsigned int endInclusive)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
for (int i = 0; i < copy.size(); i++)
{
if (i < startInclusive || i > endInclusive)
{
pathNodes.push_back(copy[i]);
}
}
// end iterator is exclusive, so max. end + 1
pathNodes.erase(pathNodes.begin() + startInclusive, pathNodes.begin() + std::min<size_t>(pathNodes.size(), endInclusive+1));
}
void VectorPath::prepend(const VectorPath &path)
@ -273,15 +266,10 @@ void VectorPath::cut(int n)
}
}
void VectorPath::removeNode(int t)
void VectorPath::removeNode(unsigned int t)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
for (int i = 0; i < copy.size(); i++)
{
if (i != t)
pathNodes.push_back(copy[i]);
}
if(t < pathNodes.size())
pathNodes.erase(pathNodes.begin() + t);
}
Vector VectorPath::getValue(float usePercent)

View file

@ -426,11 +426,11 @@ public:
void splice(const VectorPath &path, int sz);
void prepend(const VectorPath &path);
void append(const VectorPath &path);
void removeNode(int i);
void removeNode(unsigned int i);
void calculatePercentages();
float getLength();
void realPercentageCalc();
void removeNodes(int startInclusive, int endInclusive);
void removeNodes(unsigned int startInclusive, unsigned int endInclusive);
float getSubSectionLength(int startIncl, int endIncl);
protected:
std::vector <VectorPathNode> pathNodes;