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

Sergey Sharybin g.ulairi at gmail.com
Wed Jul 13 12:30:42 CEST 2011


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

Previous solution to make bundles work for parented camera
wasn't very nice. It could totally confuse depsgraph and it's
quite slow.

Now i've implemented function where_is_object_mat which makes
almost the same as where_is_object_time, but it:
- Does not applies constraints.
- Assumes matrices for all dependencies are valie already
  (handles by depsgraph).
- Doesn't make any changes to object itself or it's
  dependencies.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/object.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/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h	2011-07-13 08:26:33 UTC (rev 38354)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h	2011-07-13 10:30:42 UTC (rev 38355)
@@ -112,6 +112,7 @@
 void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime);
 void where_is_object(struct Scene *scene, struct Object *ob);
 void where_is_object_simul(struct Scene *scene, struct Object *ob);
+void where_is_object_mat(struct Scene *scene, struct Object *ob, float obmat[4][4]);
 
 struct BoundBox *unit_boundbox(void);
 void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]);

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:26:33 UTC (rev 38354)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-07-13 10:30:42 UTC (rev 38355)
@@ -4039,9 +4039,6 @@
 	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/object.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c	2011-07-13 08:26:33 UTC (rev 38354)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c	2011-07-13 10:30:42 UTC (rev 38355)
@@ -2142,6 +2142,39 @@
 	else							ob->transflag &= ~OB_NEG_SCALE;
 }
 
+/* get object transformation matrix without recalculating dependencies and
+   constraints -- assume dependencies are already solved by depsgraph.
+   no changes to object and it's parent would be done.
+   used for bundles orientation in 3d space relative to parented blender camera */
+void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4])
+{
+	float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY;
+	float fac1, fac2;
+	int a;
+
+	if(ob->parent) {
+		Object *par= ob->parent;
+
+		solve_parenting(scene, ob, par, obmat, slowmat, 1);
+
+		if(ob->partype & PARSLOW) {
+			// include framerate
+			fac1= ( 1.0f / (1.0f + (float)fabs(give_timeoffset(ob))) );
+			if(fac1 >= 1.0f) return;
+			fac2= 1.0f-fac1;
+
+			fp1= obmat[0];
+			fp2= slowmat[0];
+			for(a=0; a<16; a++, fp1++, fp2++) {
+				fp1[0]= fac1*fp1[0] + fac2*fp2[0];
+			}
+		}
+	}
+	else {
+		object_to_mat4(ob, obmat);
+	}
+}
+
 static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
 {
 	float totmat[4][4];

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:26:33 UTC (rev 38354)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-07-13 10:30:42 UTC (rev 38355)
@@ -35,7 +35,6 @@
 
 #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"
@@ -45,7 +44,6 @@
 #include "BLI_listbase.h"
 #include "BLI_ghash.h"
 
-#include "BKE_constraint.h"
 #include "BKE_global.h"
 #include "BKE_tracking.h"
 #include "BKE_movieclip.h"
@@ -873,40 +871,15 @@
 	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 tmat[4][4];
-
-	unit_m4(mat);
-	unit_m4(tmat);
-
 	if(!scene->camera)
 		scene->camera= scene_find_camera(scene);
 
-	if(scene->camera) {
-		temporary_disable_camerasolver(scene->camera, scene, 1);
-		copy_m4_m4(mat, scene->camera->obmat);
-		temporary_disable_camerasolver(scene->camera, scene, 0);
-	}
+	if(scene->camera)
+		where_is_object_mat(scene, scene->camera, mat);
+	else
+		unit_m4(mat);
 }
 
 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:26:33 UTC (rev 38354)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h	2011-07-13 10:30:42 UTC (rev 38355)
@@ -762,8 +762,7 @@
 
 /* CameraSolver Constraint -> flag */
 typedef enum eCameraSolver_Flags {
-	CAMERASOLVER_DEFAULTCLIP	= (1<<0),
-	CAMERASOLVER_TMPDISABLE		= (1<<1)
+	CAMERASOLVER_DEFAULTCLIP	= (1<<0)
 } eCameraSolver_Flags;
 
 /* Rigid-Body Constraint */




More information about the Bf-blender-cvs mailing list