From 19612f63bde9b0cd615987c02c1eea2d962ace21 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 19 Oct 2012 21:50:50 -0500 Subject: [PATCH] Fixed some bugs with the new Keyframe system, and now it generates the correct values. --- src/Clip.cpp | 4 ++-- src/KeyFrame.cpp | 13 ++++++------- src/Main.cpp | 6 ++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index 7066c870..c56b7b8d 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -214,9 +214,9 @@ void Clip::apply_time_mapped_frame(tr1::shared_ptr frame, int frame_numbe int previous_value = time.GetValue(frame_number - 1); int next_value = time.GetValue(frame_number + 1); - // walk the curve (for 30 X coordinates), and try and detect direction + // walk the curve (for 100 X coordinates), and try and detect direction bool reverse = false; - for (int index = frame_number; index < frame_number + 30; index++) + for (int index = frame_number; index < frame_number + 100; index++) { if (time.GetValue(index) > new_frame_number) { diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 0c9b33e1..040209ad 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -257,10 +257,9 @@ void Keyframe::PrintPoints() { if (needs_update) Process(); - int x = 0; for (vector::iterator it = Points.begin(); it != Points.end(); it++) { - cout << it->co.X << "\t" << it->co.Y << endl; - x++; + Point p = *it; + cout << p.co.X << "\t" << p.co.Y << endl; } } @@ -271,9 +270,9 @@ void Keyframe::PrintValues() { cout << " PRINT ALL VALUES " << endl; - for (int x = 0; x < Values.size(); x++) { - Coordinate c = Values[x]; - cout << c.X << "\t" << int(round(c.Y)) << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << endl; + for (vector::iterator it = Values.begin() + 1; it != Values.end(); it++) { + Coordinate c = *it; + cout << int(round(c.X)) << "\t" << int(round(c.Y)) << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << endl; } } @@ -318,7 +317,7 @@ void Keyframe::Process() { bool increasing = true; int repeat_count = 1; int last_value = 0; - for (vector::iterator it = Values.begin(); it != Values.end(); it++) { + for (vector::iterator it = Values.begin() + 1; it != Values.end(); it++) { int current_value = int(round((*it).Y)); int next_value = int(round((*it).Y)); int prev_value = int(round((*it).Y)); diff --git a/src/Main.cpp b/src/Main.cpp index e22f1921..8a39490e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -16,11 +16,9 @@ void FrameReady(int number) int main() { - - Keyframe time; - time.AddPoint(1, 300); - time.AddPoint(200, 500, LINEAR); + //time.AddPoint(1, 300); + time.AddPoint(1, 500, LINEAR); time.AddPoint(400, 100); time.AddPoint(500, 500); time.PrintValues();