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

Sergey Sharybin g.ulairi at gmail.com
Wed Jul 20 11:16:26 CEST 2011


Revision: 38529
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38529
Author:   nazgul
Date:     2011-07-20 09:16:26 +0000 (Wed, 20 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Fixed bug with bundle getting selected when clicking on camera.
- Bundles are now low-poly.
- Tweaked "Snap Cursor To Active" operator:
  If active object is camera and there's bundles wisible in viewport,
  snapping would happen to midpoint of selected bundles.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_snap.c

Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c	2011-07-20 08:10:01 UTC (rev 38528)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c	2011-07-20 09:16:26 UTC (rev 38529)
@@ -1391,7 +1391,7 @@
 		qobj= gluNewQuadric();
 		gluQuadricDrawStyle(qobj, GLU_FILL);
 		glShadeModel(GL_SMOOTH);
-		gluSphere(qobj, 0.05, 16, 16);
+		gluSphere(qobj, 0.05, 8, 8);
 		glShadeModel(GL_FLAT);
 		gluDeleteQuadric(qobj);
 
@@ -1415,13 +1415,13 @@
 
 		qobj= gluNewQuadric();
 		gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
-		gluDisk(qobj, 0.0,  0.05, 16, 1);
+		gluDisk(qobj, 0.0,  0.05, 8, 1);
 
 		glRotatef(90, 0, 1, 0);
-		gluDisk(qobj, 0.0,  0.05, 16, 1);
+		gluDisk(qobj, 0.0,  0.05, 8, 1);
 
 		glRotatef(90, 1, 0, 0);
-		gluDisk(qobj, 0.0,  0.05, 16, 1);
+		gluDisk(qobj, 0.0,  0.05, 8, 1);
 
 		gluDeleteQuadric(qobj);
 
@@ -1482,8 +1482,11 @@
 				glDisable(GL_LIGHTING);
 				glDepthMask(0);
 
-				if(TRACK_SELECTED(track)) UI_ThemeColor(TH_SELECT);
-				else UI_ThemeColor(TH_WIRE);
+				if(TRACK_SELECTED(track)) {
+					if(base==BASACT) UI_ThemeColor(TH_ACTIVE);
+					else UI_ThemeColor(TH_SELECT);
+				} else UI_ThemeColor(TH_WIRE);
+
 				draw_bundle_outline();
 
 				glDepthMask(1);
@@ -1491,7 +1494,8 @@
 			} else if(v3d->drawtype>OB_WIRE) {
 				/* selection outline */
 				if(TRACK_SELECTED(track)) {
-					UI_ThemeColor(TH_SELECT);
+					if(base==BASACT) UI_ThemeColor(TH_ACTIVE);
+					else UI_ThemeColor(TH_SELECT);
 
 					glDepthMask(0);
 					glLineWidth(2.f);
@@ -1555,6 +1559,9 @@
 	glDisable(GL_LIGHTING);
 
 	glColor4fv(curcol);
+
+	if(flag&DRAW_PICKING)
+		glLoadName(base->selcol);
 }
 
 /* flag similar to draw_object() */

Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c	2011-07-20 08:10:01 UTC (rev 38528)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c	2011-07-20 09:16:26 UTC (rev 38529)
@@ -1282,33 +1282,37 @@
 			}
 			
 			if(has_bones && basact) {
-				int is_cam= basact->object->type==OB_CAMERA;
+				if(basact->object->type==OB_CAMERA) {
+					if(BASACT==basact) {
+						int i, hitresult;
+						MovieTrackingTrack *track;
 
-				if(is_cam) {
-					int i, hitresult;
-					MovieTrackingTrack *track;
+						for (i=0; i< hits; i++) {
+							hitresult= buffer[3+(i*4)];
 
-					for (i=0; i< hits; i++) {
-						hitresult= buffer[3+(i*4)];
+							/* if there's bundles in buffer select bundles first,
+							   so non-camera elements should be ignored in buffer */
+							if(basact->selcol != (hitresult & 0xFFFF))
+								continue;
 
-						/* if there's bundles in buffer select bundles first,
-						   so non-camera elements should be ignored in buffer */
-						if(basact->selcol != (hitresult & 0xFFFF))
-							continue;
+							/* index of bundle is 1<<16-based. if there's no "bone" index
+							   in hight word, this buffer value belongs to camera,. not to bundle */
+							if(buffer[4*i+3] & 0xFFFF0000) {
+								track= BKE_tracking_indexed_bundle(&scene->clip->tracking, hitresult >> 16);
 
-						/* index of bundle is 1<<16-based. if there's no "bone" index
-						   in hight word, this buffer value belongs to camera,. not to bundle */
-						if(buffer[4*i+3] & 0xFFFF0000) {
-							track= BKE_tracking_indexed_bundle(&scene->clip->tracking, hitresult >> 16);
-							BKE_movieclip_select_track(scene->clip, track, TRACK_AREA_ALL, extend);
+								if(TRACK_SELECTED(track) && extend) BKE_movieclip_deselect_track(scene->clip, track, TRACK_AREA_ALL);
+								else BKE_movieclip_select_track(scene->clip, track, TRACK_AREA_ALL, extend);
 
-							basact->flag|= SELECT;
-							basact->object->flag= basact->flag;
+								basact->flag|= SELECT;
+								basact->object->flag= basact->flag;
 
-							retval= 1;
-							WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, basact->object);
+								retval= 1;
 
-							break;
+								WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, track);
+								WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+
+								break;
+							}
 						}
 					}
 				}
@@ -1331,7 +1335,7 @@
 
 				}
 				/* prevent bone selecting to pass on to object selecting */
-				if(!is_cam && basact==BASACT)
+				if(basact==BASACT)
 					basact= NULL;
 			}
 		}

Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_snap.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_snap.c	2011-07-20 08:10:01 UTC (rev 38528)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_snap.c	2011-07-20 09:16:26 UTC (rev 38529)
@@ -57,6 +57,7 @@
 #include "BKE_lattice.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_tracking.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -852,6 +853,32 @@
 
 /* ********************************************** */
 
+static void snap_to_bundle(Scene *scene, float *curs)
+{
+	MovieTrackingTrack *track;
+	int ok= 0;
+	float min[3], max[3], mat[4][4], pos[3];
+
+	BKE_get_tracking_mat(scene, mat);
+
+	INIT_MINMAX(min, max);
+
+	track= scene->clip->tracking.tracks.first;
+	while(track) {
+		if(track->flag&TRACK_HAS_BUNDLE && TRACK_SELECTED(track)) {
+			ok= 1;
+			mul_v3_m4v3(pos, mat, track->bundle_pos);
+			DO_MINMAX(pos, min, max);
+		}
+
+		track= track->next;
+	}
+
+	if(ok) {
+		interp_v3_v3v3(curs, min, max, 0.5);
+	}
+}
+
 static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *obedit= CTX_data_edit_object(C);
@@ -878,6 +905,14 @@
 	else {
 		if (obact) {
 			VECCOPY(curs, obact->obmat[3]);
+
+			/* special case for camera -- snap to bundles */
+			if(obact->type==OB_CAMERA) {
+				/* snap to bundles should happen only when bundles are visible */
+				if(scene->clip && v3d->flag2&V3D_SHOW_RECONSTRUCTION) {
+					snap_to_bundle(scene, curs);
+				}
+			}
 		}
 	}
 	




More information about the Bf-blender-cvs mailing list