Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-09-17 12:54:10 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-09-17 12:54:10 +0400
commitb9be47e91c64876d65d6bd061bc3ff3ee347d03e (patch)
tree87f06414c5ddd48d4530043ef29c524f0385d46f /source/blender/blenkernel/intern/tracking.c
parentbf5bbda187c891b75e6ee0fa8fd33dcf138f2ab9 (diff)
Re-track the plane after clearing the keyframe
From the math point of view there're two cases: - Clearing the keyframe between two other ones. In this case tracker will first track plane from left keyframe to right one without doing any kind of blending. This will make plane stick to the actual plane motion, but lead to possible jump at the right keyframe. Second step is to track from the right keyframe to the left one with blending. This gives nice transition at the point of second keyframe and this mimics situation when you've been setting keyframes from left to right. - Clearing left-most/right-most keyframe. In this case it's enough to only re-track the plane without blending from the neighbor keyframe without blending.
Diffstat (limited to 'source/blender/blenkernel/intern/tracking.c')
-rw-r--r--source/blender/blenkernel/intern/tracking.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 2c84fbd8680..fd92ec9f462 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -3282,7 +3282,8 @@ BLI_INLINE void mat3f_from_mat3d(float mat_float[3][3], double mat_double[3][3])
}
/* NOTE: frame number should be in clip space, not scene space */
-static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_track, int start_frame, int direction)
+static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_track, int start_frame,
+ int direction, bool retrack)
{
MovieTrackingPlaneMarker *start_plane_marker = BKE_tracking_plane_marker_get(plane_track, start_frame);
MovieTrackingPlaneMarker *keyframe_plane_marker = NULL;
@@ -3359,7 +3360,7 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac
new_plane_marker.framenr = current_frame + frame_delta;
- if (keyframe_plane_marker &&
+ if (!retrack && keyframe_plane_marker &&
next_plane_marker &&
(plane_track->flag & PLANE_TRACK_AUTOKEY))
{
@@ -3384,8 +3385,47 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac
/* NOTE: frame number should be in clip space, not scene space */
void BKE_tracking_track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_track, int start_frame)
{
- track_plane_from_existing_motion(plane_track, start_frame, 1);
- track_plane_from_existing_motion(plane_track, start_frame, -1);
+ track_plane_from_existing_motion(plane_track, start_frame, 1, false);
+ track_plane_from_existing_motion(plane_track, start_frame, -1, false);
+}
+
+static MovieTrackingPlaneMarker *find_plane_keyframe(MovieTrackingPlaneTrack *plane_track,
+ int start_frame, int direction)
+{
+ MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, start_frame);
+ int index = plane_marker - plane_track->markers;
+ int frame_delta = direction > 0 ? 1 : -1;
+
+ while (index >= 0 && index < plane_track->markersnr) {
+ if ((plane_marker->flag & PLANE_MARKER_TRACKED) == 0) {
+ return plane_marker;
+ }
+ plane_marker += frame_delta;
+ }
+
+ return NULL;
+}
+
+void BKE_tracking_retrack_plane_from_existing_motion_at_segment(MovieTrackingPlaneTrack *plane_track, int start_frame)
+{
+ MovieTrackingPlaneMarker *prev_plane_keyframe, *next_plane_keyframe;
+
+ prev_plane_keyframe = find_plane_keyframe(plane_track, start_frame, -1);
+ next_plane_keyframe = find_plane_keyframe(plane_track, start_frame, 1);
+
+ if (prev_plane_keyframe != NULL && next_plane_keyframe != NULL) {
+ /* First we track from left keyframe to the right one without any blending. */
+ track_plane_from_existing_motion(plane_track, prev_plane_keyframe->framenr, 1, true);
+
+ /* And then we track from the right keyframe to the left one, so shape blends in nicely */
+ track_plane_from_existing_motion(plane_track, next_plane_keyframe->framenr, -1, false);
+ }
+ else if (prev_plane_keyframe != NULL) {
+ track_plane_from_existing_motion(plane_track, prev_plane_keyframe->framenr, 1, true);
+ }
+ else if (next_plane_keyframe != NULL) {
+ track_plane_from_existing_motion(plane_track, next_plane_keyframe->framenr, -1, true);
+ }
}
BLI_INLINE void float_corners_to_double(/*const*/ float corners[4][2], double double_corners[4][2])