[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41393] branches/soc-2011-tomato/source/ blender: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Sun Oct 30 23:56:45 CET 2011


Revision: 41393
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41393
Author:   nazgul
Date:     2011-10-30 22:56:45 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================

Rest of recent compilation error fix (this stuff better be kept
separated to make it easier to separate patches for trunk integration).

Made behavior of tracks selection more consistent with other areas:
- Make track active when starting sliding it.
- When using extend selection clicking on non-active track make it active
  instead of immediately hiding it.
- Reset offset from locked selection when using non-extending selection.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-10-30 22:53:24 UTC (rev 41392)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-10-30 22:56:45 UTC (rev 41393)
@@ -3989,7 +3989,7 @@
 			MovieTrackingMarker *marker;
 			float vec[3], disp[3], axis[3], mat[4][4];
 			float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
-			float sensor_x, lens, len, d, ortho_scale= 1.f;
+			float sensor_x, sensor_y, lens, len, d, ortho_scale= 1.f;
 
 			where_is_object_mat(scene, camob, mat);
 
@@ -4008,7 +4008,7 @@
 
 			if(len>FLT_EPSILON) {
 				float pos[2], rmat[4][4], shiftx= 0.0f, shifty= 0.0f, clipsta= 0.0f, clipend= 0.0f;
-				short is_ortho= 0;
+				short is_ortho= 0, fov_mode= CAMERA_FOV_AUTO;
 				Camera *cam= NULL;
 
 				user.framenr= scene->r.cfra;
@@ -4016,7 +4016,7 @@
 
 				add_v2_v2v2(pos, marker->pos, track->offset);
 
-				object_camera_intrinsics(camob, &cam, &is_ortho, &shiftx, &shifty, &clipsta, &clipend, &lens, &sensor_x);
+				object_camera_intrinsics(camob, &cam, &is_ortho, &shiftx, &shifty, &clipsta, &clipend, &lens, &sensor_x, &sensor_y, &fov_mode);
 
 				if(is_ortho) {
 					if(cam)

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-10-30 22:53:24 UTC (rev 41392)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-10-30 22:56:45 UTC (rev 41393)
@@ -1033,10 +1033,14 @@
 			ImBuf *ibuf= NULL;
 			MovieTrackingMarker marker_new, *marker_keyed;
 			int onbound= 0, coords_correct= 0;
+			int nextfra;
 
 			if(!context->settings.adjframes) need_readjust= context->first_time;
 			else need_readjust= context->frames%context->settings.adjframes == 0;
 
+			if(context->backwards) nextfra= curfra-1;
+			else nextfra= curfra+1;
+
 			/* margin from frame boundaries */
 			sub_v2_v2v2(margin, track->pat_max, track->pat_min);
 
@@ -1180,21 +1184,31 @@
 				}
 
 				marker_new.flag|= MARKER_TRACKED;
+				marker_new.framenr= nextfra;
 
-				if(context->backwards) marker_new.framenr= curfra-1;
-				else marker_new.framenr= curfra+1;
-
 				#pragma omp critical
 				{
 					BKE_tracking_insert_marker(track, &marker_new);
 				}
 
+				if(context->backwards) nextfra--;
+				else nextfra++;
+
+				/* make currently tracked segment be finished with disabled marker */
+				if(!BKE_tracking_has_marker(track, nextfra)) {
+					marker_new.framenr= nextfra;
+					marker_new.flag|= MARKER_DISABLED;
+					marker_new.flag&= ~MARKER_TRACKED;
+
+					#pragma omp critical
+					{
+						BKE_tracking_insert_marker(track, &marker_new);
+					}
+				}
 			} else {
 				marker_new= *marker;
 
-				if(context->backwards) marker_new.framenr--;
-				else marker_new.framenr++;
-
+				marker_new.framenr= nextfra;
 				marker_new.flag|= MARKER_DISABLED;
 
 				#pragma omp critical

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-10-30 22:53:24 UTC (rev 41392)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-10-30 22:56:45 UTC (rev 41393)
@@ -462,12 +462,22 @@
 
 static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-	op->customdata= slide_marker_customdata(C, event);
+	SlideMarkerData *slidedata= slide_marker_customdata(C, event);
 
-	if(op->customdata) {
+	if(slidedata) {
+		SpaceClip *sc= CTX_wm_space_clip(C);
+		MovieClip *clip= ED_space_clip(sc);
+		MovieTracking *tracking= &clip->tracking;
+
+		tracking->act_track= slidedata->track;
+
+		op->customdata= slidedata;
+
 		hide_cursor(C);
 		WM_event_add_modal_handler(C, op);
 
+		WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
+
 		return OPERATOR_RUNNING_MODAL;
 	}
 
@@ -740,6 +750,8 @@
 {
 	SpaceClip *sc= CTX_wm_space_clip(C);
 	MovieClip *clip= ED_space_clip(sc);
+	MovieTracking *tracking= &clip->tracking;
+	MovieTrackingTrack *act_track= tracking->act_track;
 	MovieTrackingTrack *track= NULL;	/* selected marker */
 
 	track= find_nearest_track(sc, clip, co);
@@ -751,7 +763,10 @@
 			area= TRACK_AREA_ALL;
 
 		if(extend && TRACK_AREA_SELECTED(track, area)) {
-			BKE_movieclip_deselect_track(clip, track, area);
+			if(track==act_track)
+				BKE_movieclip_deselect_track(clip, track, area);
+			else
+				clip->tracking.act_track= track;
 		} else {
 			if(area==TRACK_AREA_POINT)
 				area= TRACK_AREA_ALL;
@@ -761,6 +776,11 @@
 		}
 	}
 
+	if(!extend) {
+		sc->xlockof= 0.0f;
+		sc->ylockof= 0.0f;
+	}
+
 	WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
 
 	return OPERATOR_FINISHED;
@@ -779,14 +799,22 @@
 
 static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-	void *customdata;
 	float co[2];
 	int extend= RNA_boolean_get(op->ptr, "extend");
 
 	if(!extend) {
-		customdata= slide_marker_customdata(C, event);
-		if(customdata) {
-			MEM_freeN(customdata);
+		SlideMarkerData *slidedata= slide_marker_customdata(C, event);
+
+		if(slidedata) {
+			SpaceClip *sc= CTX_wm_space_clip(C);
+			MovieClip *clip= ED_space_clip(sc);
+
+			clip->tracking.act_track= slidedata->track;
+
+			WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
+
+			MEM_freeN(slidedata);
+
 			return OPERATOR_PASS_THROUGH;
 		}
 	}




More information about the Bf-blender-cvs mailing list