Added new properties to the clip JSON properties method, to enable more rich control of a clips properties. Fixed some defaults on Points that still used X=0.

This commit is contained in:
Jonathan Thomas
2015-02-21 03:10:38 -06:00
parent 0df6439103
commit b976b8220b
5 changed files with 49 additions and 26 deletions

View File

@@ -47,8 +47,6 @@ void Keyframe::ReorderPoints() {
// swap items
if (smallest_index != compare_index) {
cout << "swap item " << Points[compare_index].co.X << " with "
<< Points[smallest_index].co.X << endl;
swap(Points[compare_index], Points[smallest_index]);
}
}
@@ -189,6 +187,26 @@ bool Keyframe::Contains(Point p) {
return false;
}
// Get current point (or closest point) from the X coordinate (i.e. the frame number)
Point Keyframe::GetClosestPoint(Point p) {
Point closest(-1, -1);
// loop through points, and find a matching coordinate
for (int x = 0; x < Points.size(); x++) {
// Get each point
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)) {
// New closest point found
closest = existing_point;
}
}
// no matching point found
return closest;
}
// Get the value at a specific index
float Keyframe::GetValue(int index)
{