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

Sergey Sharybin g.ulairi at gmail.com
Tue Jul 26 17:58:29 CEST 2011


Revision: 38734
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38734
Author:   nazgul
Date:     2011-07-26 15:58:29 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Clip Editor now could be an owner for jobs. It was useful
  when i've been attaching Peter's work in my local repo.
- Fixed mouse selection to handle offset correct.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-26 15:56:53 UTC (rev 38733)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-26 15:58:29 UTC (rev 38734)
@@ -111,6 +111,7 @@
                 sub.menu("CLIP_MT_track")
 
         layout.template_ID(sc, "clip")
+        layout.template_running_jobs()
 
 
 class CLIP_PT_tools(bpy.types.Panel):

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2011-07-26 15:56:53 UTC (rev 38733)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2011-07-26 15:58:29 UTC (rev 38734)
@@ -2359,6 +2359,7 @@
 #define B_STOPCAST		2
 #define B_STOPANIM		3
 #define B_STOPCOMPO		4
+#define B_STOPCLIP		5
 
 static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
 {
@@ -2375,6 +2376,9 @@
 		case B_STOPCOMPO:
 			WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
 			break;
+		case B_STOPCLIP:
+			WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
+			break;
 	}
 }
 
@@ -2397,6 +2401,11 @@
 		   owner = sa;
 		handle_event= B_STOPCOMPO;
 	} 
+	if(sa->spacetype==SPACE_CLIP) {
+		if(WM_jobs_test(wm, sa))
+		   owner = sa;
+		handle_event= B_STOPCLIP;
+	}
 	else {
 		Scene *scene;
 		/* another scene can be rendering too, for example via compositor */

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2011-07-26 15:56:53 UTC (rev 38733)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2011-07-26 15:58:29 UTC (rev 38734)
@@ -414,6 +414,20 @@
 				glVertex2f(pos[0], pos[1] + px[1]*3);
 				glVertex2f(pos[0], pos[1] + px[1]*7);
 			glEnd();
+
+			glColor3f(0.f, 0.f, 0.f);
+			glLineStipple(3, 0xaaaa);
+			glEnable(GL_LINE_STIPPLE);
+			glEnable(GL_COLOR_LOGIC_OP);
+			glLogicOp(GL_NOR);
+
+			glBegin(GL_LINES);
+				glVertex2fv(pos);
+				glVertex2fv(marker->pos);
+			glEnd();
+
+			glDisable(GL_COLOR_LOGIC_OP);
+			glDisable(GL_LINE_STIPPLE);
 		}
 	}
 

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-07-26 15:56:53 UTC (rev 38733)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-26 15:58:29 UTC (rev 38734)
@@ -374,7 +374,7 @@
 	data->width= width;
 	data->height= height;
 
-	if(area!=TRACK_AREA_POINT)
+	if(action==SLIDE_ACTION_SIZE)
 		data->lock= 1;
 
 	return data;
@@ -543,7 +543,6 @@
 		data->min[1]= data->smin[1];
 		data->max[1]= data->smax[1];
 	}
-
 }
 
 static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
@@ -557,7 +556,7 @@
 		case RIGHTCTRLKEY:
 		case LEFTSHIFTKEY:
 		case RIGHTSHIFTKEY:
-			if(data->area!=TRACK_AREA_POINT)
+			if(data->action==SLIDE_ACTION_SIZE)
 				if(ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY))
 					data->lock= event->val==KM_RELEASE;
 
@@ -686,22 +685,25 @@
 	epsy= MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1],
 	           fabsf(track->pat_min[1]), fabsf(track->pat_max[1])) / 2;
 
-	epsx= MAX2(epsy, 2.0 / width);
-	epsy= MAX2(epsy, 2.0 / height);
+	epsx= MAX2(epsy, 2.f / width);
+	epsy= MAX2(epsy, 2.f / height);
 
+	if(sc->flag&SC_SHOW_MARKER_SEARCH)
+		if(mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy))
+			return TRACK_AREA_SEARCH;
+
 	if((marker->flag&MARKER_DISABLED)==0) {
-		if(fabsf(co[0]-marker->pos[0])< epsx && fabsf(co[1]-marker->pos[1])<=epsy)
-			return TRACK_AREA_POINT;
-
 		if(sc->flag&SC_SHOW_MARKER_PATTERN)
 			if(mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy))
 				return TRACK_AREA_PAT;
+
+		epsx= 12.f/width;
+		epsy= 12.f/height;
+
+		if(fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy)
+			return TRACK_AREA_POINT;
 	}
 
-	if(sc->flag&SC_SHOW_MARKER_SEARCH)
-		if(mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy))
-			return TRACK_AREA_SEARCH;
-
 	return TRACK_AREA_NONE;
 }
 
@@ -732,8 +734,8 @@
 		if(((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) {
 			float dist, d1, d2=FLT_MAX, d3=FLT_MAX;
 
-			d1= sqrtf((co[0]-marker->pos[0])*(co[0]-marker->pos[0])+
-					  (co[1]-marker->pos[1])*(co[1]-marker->pos[1])); /* distance to marker point */
+			d1= sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+
+					  (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */
 
 			/* distance to pattern boundbox */
 			if(sc->flag&SC_SHOW_MARKER_PATTERN)
@@ -808,11 +810,14 @@
 	ARegion *ar= CTX_wm_region(C);
 	void *customdata;
 	float co[2];
+	int extend= RNA_boolean_get(op->ptr, "extend");
 
-	customdata= slide_marker_customdata(C, event);
-	if(customdata) {
-		MEM_freeN(customdata);
-		return OPERATOR_PASS_THROUGH;
+	if(!extend) {
+		customdata= slide_marker_customdata(C, event);
+		if(customdata) {
+			MEM_freeN(customdata);
+			return OPERATOR_PASS_THROUGH;
+		}
 	}
 
 	UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
@@ -1250,7 +1255,7 @@
 	tmj->screen= CTX_wm_screen(C);
 }
 
-static void track_markers_startjob(void *tmv, short *UNUSED(stop), short *do_update, float *progress)
+static void track_markers_startjob(void *tmv, short *stop, short *do_update, float *progress)
 {
 	TrackMarkersJob *tmj= (TrackMarkersJob *)tmv;
 	int framenr= tmj->sfra;
@@ -1283,7 +1288,7 @@
 
 		tmj->lastfra= framenr;
 
-		if(track_markers_testbreak())
+		if(*stop || track_markers_testbreak())
 			break;
 	}
 
@@ -1364,10 +1369,10 @@
 static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
 	TrackMarkersJob *tmj;
+	ScrArea *sa= CTX_wm_area(C);
 	SpaceClip *sc= CTX_wm_space_clip(C);
 	MovieClip *clip= ED_space_clip(sc);
 	wmJob *steve;
-	Scene *scene= CTX_data_scene(C);
 	int backwards= RNA_boolean_get(op->ptr, "backwards");
 	int sequence= RNA_boolean_get(op->ptr, "sequence");
 
@@ -1381,7 +1386,7 @@
 	track_markers_initjob(C, tmj, backwards);
 
 	/* setup job */
-	steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Track Markers", WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS);
+	steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS);
 	WM_jobs_customdata(steve, tmj, track_markers_freejob);
 
 	/* if there's delay set in tracking job, tracking should happen




More information about the Bf-blender-cvs mailing list