You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user