Fixed bug determing the closest keyframe point to another point. Added additional unit tests. Added new method to get the # of Points in a keyframe.

This commit is contained in:
Jonathan Thomas
2015-02-22 01:04:54 -06:00
parent b976b8220b
commit 61ed19250e
6 changed files with 54 additions and 13 deletions

View File

@@ -197,12 +197,23 @@ Point Keyframe::GetClosestPoint(Point p) {
Point existing_point = Points[x];
// find a match
if ((p.co.X <= existing_point.co.X && p.co.X >= closest.co.X) || (closest.co.X == -1)) {
if (existing_point.co.X >= p.co.X) {
// New closest point found
closest = existing_point;
break;
}
}
// Handle edge cases (if no point was found)
if (closest.co.X == -1) {
if (p.co.X < 1)
// Assign 1st point
closest = Points[0];
else
// Assign last point
closest = Points[Points.size() - 1];
}
// no matching point found
return closest;
}
@@ -416,6 +427,13 @@ int Keyframe::GetLength() {
return Values.size();
}
// Get the number of points (i.e. # of points)
int Keyframe::GetCount() {
// return the size of the Values vector
return Points.size();
}
// Remove a point by matching a coordinate
void Keyframe::RemovePoint(Point p) throw(OutOfBoundsPoint) {
// mark as dirty