diff --git a/BBGE/Vector.cpp b/BBGE/Vector.cpp index 73b24bc..aacf987 100644 --- a/BBGE/Vector.cpp +++ b/BBGE/Vector.cpp @@ -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 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(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 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) diff --git a/BBGE/Vector.h b/BBGE/Vector.h index e56fbac..033f827 100644 --- a/BBGE/Vector.h +++ b/BBGE/Vector.h @@ -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 pathNodes;