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

Sergey Sharybin g.ulairi at gmail.com
Wed Jul 13 10:26:33 CEST 2011


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

Attempt to fix bundles position for case scene camera has got
other constraints than CameraSolver (mostly to support camera
parenting to other object for scene orientation).

Use a bit silly logic to calculate camera matrix to orient
bundles in 3d space: temporary disable all CameraSolver
constraints for camera, re-calculate object matrix, use it
to orient bundles and clear temporary flag.

This allows to parent both of camera and mesh created from
bundles to the same Empty object and both of bundles and
mesh vertices would have the same coords in camera space.

Also removed copying of location/rotation from camera to
bundles object in "Bundles to Mesh" operator.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h

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-13 08:15:06 UTC (rev 38353)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-13 08:26:33 UTC (rev 38354)
@@ -84,12 +84,6 @@
 
         ob = bpy.data.objects.new(name="Bundles", object_data=mesh)
 
-        camera = bpy.context.scene.camera
-        if camera:
-            ob.location = camera.location
-            ob.rotation_quaternion = camera.rotation_quaternion
-            ob.rotation_euler = camera.rotation_euler
-
         bpy.context.scene.objects.link(ob)
 
         return {'FINISHED'}

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-07-13 08:15:06 UTC (rev 38353)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-07-13 08:26:33 UTC (rev 38354)
@@ -4039,6 +4039,9 @@
 	MovieClip *clip= data->clip;
 	MovieReconstructedCamera *camera;
 
+	if(data->flag&CAMERASOLVER_TMPDISABLE)
+		return;
+
 	if(data->flag&CAMERASOLVER_DEFAULTCLIP)
 		clip= scene->clip;
 

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c	2011-07-13 08:15:06 UTC (rev 38353)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c	2011-07-13 08:26:33 UTC (rev 38354)
@@ -645,6 +645,17 @@
 
 		/* special case for FollowTrack -- it doesn't use targets to define relations */
 		if(ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER)) {
+			if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
+				bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data;
+
+				if(data->reference==FOLLOWTRACK_BUNDLE) {
+					if((data->clip || data->flag&FOLLOWTRACK_DEFAULTCLIP) && data->track[0]) {
+						node2 = dag_get_node(dag, scene->camera);
+						dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
+					}
+				}
+			}
+
 			dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation");
 			addtoroot = 0;
 		}

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-07-13 08:15:06 UTC (rev 38353)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-07-13 08:26:33 UTC (rev 38354)
@@ -35,6 +35,7 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_constraint_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_object_types.h"	/* SELECT */
 #include "DNA_scene_types.h"
@@ -44,6 +45,7 @@
 #include "BLI_listbase.h"
 #include "BLI_ghash.h"
 
+#include "BKE_constraint.h"
 #include "BKE_global.h"
 #include "BKE_tracking.h"
 #include "BKE_movieclip.h"
@@ -871,19 +873,40 @@
 	return NULL;
 }
 
+static void temporary_disable_camerasolver(Object *ob, Scene *scene, int disable)
+{
+	bConstraint *con;
+
+	for(con= ob->constraints.first; con; con=con->next) {
+		bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+
+		if(cti->type==CONSTRAINT_TYPE_CAMERASOLVER) {
+			bCameraSolverConstraint *data= (bCameraSolverConstraint *)con->data;
+
+			if(disable) data->flag|= CAMERASOLVER_TMPDISABLE;
+			else data->flag&= ~CAMERASOLVER_TMPDISABLE;
+		}
+	}
+
+	if(ob->constraints.first)
+		where_is_object_time(scene, ob, CFRA+SUBFRA);
+}
+
 void BKE_get_tracking_mat(Scene *scene, float mat[4][4])
 {
-	float obmat[4][4];
+	float tmat[4][4];
 
-	unit_m4(obmat);
+	unit_m4(mat);
+	unit_m4(tmat);
 
 	if(!scene->camera)
 		scene->camera= scene_find_camera(scene);
 
-	if(scene->camera)
-		object_to_mat4(scene->camera, obmat);
-
-	copy_m4_m4(mat, obmat);
+	if(scene->camera) {
+		temporary_disable_camerasolver(scene->camera, scene, 1);
+		copy_m4_m4(mat, scene->camera->obmat);
+		temporary_disable_camerasolver(scene->camera, scene, 0);
+	}
 }
 
 void BKE_tracking_projection_matrix(MovieTracking *tracking, int framenr, int winx, int winy, float mat[4][4])

Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h	2011-07-13 08:15:06 UTC (rev 38353)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h	2011-07-13 08:26:33 UTC (rev 38354)
@@ -762,7 +762,8 @@
 
 /* CameraSolver Constraint -> flag */
 typedef enum eCameraSolver_Flags {
-	CAMERASOLVER_DEFAULTCLIP	= (1<<0)
+	CAMERASOLVER_DEFAULTCLIP	= (1<<0),
+	CAMERASOLVER_TMPDISABLE		= (1<<1)
 } eCameraSolver_Flags;
 
 /* Rigid-Body Constraint */




More information about the Bf-blender-cvs mailing list