Implement option to parent object to undistorted position of 2D track

This commit is contained in:
Sergey Sharybin 2014-07-24 21:00:35 +06:00
parent d2cf9f0c4b
commit 157fc43369
6 changed files with 29 additions and 5 deletions

View File

@ -788,6 +788,10 @@ class ConstraintButtonsPanel():
row.prop(con, "use_active_clip")
row.prop(con, "use_3d_position")
sub = row.column()
sub.active = not con.use_3d_position
sub.prop(con, "use_undistorted_position")
col = layout.column()
if not con.use_active_clip:

View File

@ -3943,19 +3943,31 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
if (len > FLT_EPSILON) {
CameraParams params;
int width, height;
float pos[2], rmat[4][4];
BKE_movieclip_get_size(clip, NULL, &width, &height);
marker = BKE_tracking_marker_get(track, framenr);
add_v2_v2v2(pos, marker->pos, track->offset);
if (data->flag & FOLLOWTRACK_USE_UNDISTORTION) {
/* Undistortion need to happen in pixel space. */
pos[0] *= width;
pos[1] *= height;
BKE_tracking_undistort_v2(tracking, pos, pos);
/* Normalize pixel coordinates back. */
pos[0] /= width;
pos[1] /= height;
}
/* 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;

View File

@ -915,7 +915,7 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
ED_region_tag_redraw(ar);
break;
case NC_MOVIECLIP:
if (wmn->data == ND_DISPLAY)
if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED)
ED_region_tag_redraw(ar);
break;
case NC_SPACE:

View File

@ -796,7 +796,8 @@ typedef enum ePivotConstraint_Flag {
typedef enum eFollowTrack_Flags {
FOLLOWTRACK_ACTIVECLIP = (1<<0),
FOLLOWTRACK_USE_3D_POSITION = (1<<1)
FOLLOWTRACK_USE_3D_POSITION = (1<<1),
FOLLOWTRACK_USE_UNDISTORTION = (1<<2)
} eFollowTrack_Flags;
typedef enum eFollowTrack_FrameMethod {

View File

@ -2452,6 +2452,12 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna)
RNA_def_property_enum_items(prop, frame_method_items);
RNA_def_property_ui_text(prop, "Frame Method", "How the footage fits in the camera frame");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
/* use undistortion */
prop = RNA_def_property(srna, "use_undistorted_position", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FOLLOWTRACK_USE_UNDISTORTION);
RNA_def_property_ui_text(prop, "Undistort", "Parent to undistorted position of 2D track");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
}
static void rna_def_constraint_camera_solver(BlenderRNA *brna)

View File

@ -393,6 +393,7 @@ static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerR
nodeUpdateID(scene->nodetree, &clip->id);
WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
WM_main_add_notifier(NC_SCENE, NULL);
DAG_id_tag_update(&clip->id, 0);
}