[Bf-blender-cvs] [157fc43] master: Implement option to parent object to undistorted position of 2D track

Sergey Sharybin noreply at git.blender.org
Thu Jul 24 17:01:25 CEST 2014


Commit: 157fc433698558fc03ac4b58ede9e27521aae8a8
Author: Sergey Sharybin
Date:   Thu Jul 24 21:00:35 2014 +0600
Branches: master
https://developer.blender.org/rB157fc433698558fc03ac4b58ede9e27521aae8a8

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

===================================================================

M	release/scripts/startup/bl_ui/properties_constraint.py
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/makesdna/DNA_constraint_types.h
M	source/blender/makesrna/intern/rna_constraint.c
M	source/blender/makesrna/intern/rna_tracking.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 5010760..4baf31a 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -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:
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index b256f84..2f8690a 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -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;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index eb2310f..1273b90 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -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:
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index e35e467..0277956 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index eb38c58..5519b19 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -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)
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 537ffe6..899da62 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -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);
 }




More information about the Bf-blender-cvs mailing list