diff options
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index e08c9e9d39e..16edbc3f0a9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -82,8 +82,6 @@ #include "BKE_tessmesh.h" #include "BKE_tracking.h" #include "BKE_movieclip.h" -#include "BKE_tracking.h" -#include "BKE_movieclip.h" #ifdef WITH_PYTHON #include "BPY_extern.h" @@ -3985,6 +3983,41 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase add_v2_v2v2(pos, marker->pos, track->offset); + /* aspect correction */ + if (data->frame_method != FOLLOWTRACK_FRAME_STRETCH) { + int width, height; + float w_src, h_src, w_dst, h_dst, asp_src, asp_dst; + + BKE_movieclip_get_size(clip, NULL, &width, &height); + + /* apply clip display aspect */ + w_src = width * clip->aspx; + h_src = height * clip->aspy; + + w_dst = scene->r.xsch * scene->r.xasp; + h_dst = scene->r.ysch * scene->r.yasp; + + asp_src = w_src / h_src; + asp_dst = w_dst / h_dst; + + if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) { + if ((asp_src > asp_dst) == (data->frame_method == FOLLOWTRACK_FRAME_CROP)) { + /* fit X */ + float div = asp_src / asp_dst; + float cent = (float) width / 2.0f; + + pos[0] = (((pos[0] * width - cent) * div) + cent) / width; + } + else { + /* fit Y */ + float div = asp_dst / asp_src; + float cent = (float) height / 2.0f; + + pos[1] = (((pos[1] * height - cent) * div) + cent) / height; + } + } + } + BKE_camera_params_init(¶ms); BKE_camera_params_from_object(¶ms, camob); |