diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-27 14:12:58 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-27 14:12:58 +0400 |
commit | 52aa7a4a4c07f915b634a56162c9093ef1fecb09 (patch) | |
tree | 0734954c7a67a1d1dde7dffbad8e1894945c47ce /source/blender/blenkernel/intern | |
parent | b10a35a9a9128531347e60be530631b39386dcb2 (diff) |
Added utility function to return marker's subframe position
Used in mask parenting stuff.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 32 |
2 files changed, 32 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a2a63f67a62..3c008692cbb 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1635,9 +1635,8 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[ user.framenr = ctime; if (track) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); float marker_pos_ofs[2]; - add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); + BKE_tracking_marker_get_subframe_position(track, clip_framenr, marker_pos_ofs); BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs); return TRUE; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 35a688849e8..3c00397dfa5 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -916,7 +916,7 @@ void BKE_tracking_track_deselect(MovieTrackingTrack *track, int area) BKE_tracking_track_flag_clear(track, area, SELECT); } -/*********************** Marker *************************/ +/*********************** Marker *************************/ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track, MovieTrackingMarker *marker) { @@ -1133,6 +1133,36 @@ void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float DO_MINMAX2(marker->pattern_corners[3], min, max); } +void BKE_tracking_marker_get_subframe_position(MovieTrackingTrack *track, float framenr, float pos[2]) +{ + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, (int) framenr); + MovieTrackingMarker *marker_last = track->markers + (track->markersnr - 1); + + if (marker != marker_last) { + MovieTrackingMarker *marker_next = marker + 1; + + if (marker_next->framenr == marker->framenr + 1) { + /* currently only do subframing inside tracked ranges, do not extrapolate tracked segments + * could be changed when / if mask parent would be interpolating position in-between + * tracked segments + */ + + float fac = (framenr - (int) framenr) / (marker_next->framenr - marker->framenr); + + interp_v2_v2v2(pos, marker->pos, marker_next->pos, fac); + } + else { + copy_v2_v2(pos, marker->pos); + } + } + else { + copy_v2_v2(pos, marker->pos); + } + + /* currently track offset is always wanted to be applied here, could be made an option later */ + add_v2_v2(pos, track->offset); +} + /*********************** Object *************************/ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char *name) |