[Bf-blender-cvs] [da9e26a] depsgraph_refactor: Object transform evaluation is now done in new-depsgraph-driven callbacks instead of ubereval

Joshua Leung noreply at git.blender.org
Thu Dec 18 05:09:26 CET 2014


Commit: da9e26a2c3d8d397d9a9c5ba08aea6e3994d1d2a
Author: Joshua Leung
Date:   Thu Dec 18 16:25:44 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rBda9e26a2c3d8d397d9a9c5ba08aea6e3994d1d2a

Object transform evaluation is now done in new-depsgraph-driven callbacks instead of ubereval

* The ubereval is still lurking around for handling proxy cruft

* I've implemented a stripped-down version of the parenting code for
  use here (notably, without the slow parenting, and originmat support).
  The old/full version did a bit too much for us to be able to keep the
  old code running while we worked on the new version too, without making
  the code too messy.

  Later on, when we work out the geometry handling a bit more, we may need
  to replace the parent-matrix finding code it uses too (i.e. to make it
  grab data from context instead - especially in cases where it hunts for
  this info itself currently).

===================================================================

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp

===================================================================

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 2bd7d83..8fface9 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -183,10 +183,6 @@ void BKE_object_eval_constraints(struct EvaluationContext *eval_ctx,
                                  struct Object *ob);
 void BKE_object_eval_done(struct EvaluationContext *eval_ctx, struct Object *ob);
 
-/* (placeholder helpers for granular object transform updates) */
-void BKE_object_solve_parenting(struct Scene *scene, struct Object *ob, struct Object *par, float obmat[4][4], float slowmat[4][4],
-                                float r_originmat[3][3], const bool set_origin);
-
 void BKE_object_eval_modifier(struct EvaluationContext *eval_ctx,
                               struct Scene *scene,
                               struct Object *ob,
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 3c2f953..613c85e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2314,7 +2314,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
 	}
 }
 
-static void ob_get_parent_matrix(Scene *scene, Object *ob, Object *par, float parentmat[4][4])
+void ob_get_parent_matrix(Scene *scene, Object *ob, Object *par, float parentmat[4][4])
 {
 	float tmat[4][4];
 	float vec[3];
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 5a03c5f..26eb73f 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -66,35 +66,69 @@ void BKE_object_eval_local_transform(EvaluationContext *eval_ctx,
                                      Object *ob)
 {
 	PRINT("%s on %s\n", __func__, ob->id.name);
-
-	(void) eval_ctx;  /* Ignored. */
-	(void) scene;  /* Ignored. */
+	
+	/* calculate local matrix */
+	BKE_object_to_mat4(ob, ob->obmat);
 }
 
+/* XXX: expose this in a proper header, or shuffle the code around to get it working */
+extern void ob_get_parent_matrix(Scene *scene, Object *ob, Object *par, float parentmat[4][4]);
+
+/* Evaluate parent */
+/* NOTE: based on solve_parenting(), but with the cruft stripped out */
 void BKE_object_eval_parent(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
+	Object *par = ob->parent;
+	
+	float totmat[4][4];
+	float tmat[4][4];
+	float locmat[4][4];
+	
 	PRINT("%s on %s\n", __func__, ob->id.name);
-
-	(void) eval_ctx;  /* Ignored. */
-	(void) scene;  /* Ignored. */
-	(void) ob; /* Ignored. */
+	
+	/* get local matrix (but don't calculate it, as that was done already!) */
+	// XXX: redundant?
+	copy_m4_m4(locmat, ob->obmat);
+	
+	/* get parent effect matrix */
+	ob_get_parent_matrix(scene, ob, par, totmat);
+	
+	/* total */
+	mul_m4_m4m4(tmat, totmat, ob->parentinv);
+	mul_m4_m4m4(ob->obmat, tmat, locmat);
+	
+	/* origin, for help line */	
+	if ((ob->partype & PARTYPE) == PARSKEL) {
+		copy_v3_v3(ob->orig, par->obmat[3]);
+	}
+	else {
+		copy_v3_v3(ob->orig, totmat[3]);
+	}
 }
 
 void BKE_object_eval_constraints(EvaluationContext *eval_ctx,
                                  Scene *scene,
                                  Object *ob)
 {
+	bConstraintOb *cob;
+	float ctime = BKE_scene_frame_get(scene);
+	
 	PRINT("%s on %s\n", __func__, ob->id.name);
-	(void) eval_ctx;  /* Ignored. */
-	(void) scene;  /* Ignored. */
-	(void) ob;  /* Ignored. */
+	
+	/* evaluate constraints stack */
+	// TODO: split this into pre (i.e. BKE_constraints_make_evalob, per-constraint (i.e. inner body of BKE_constraints_solve), post (i.e. BKE_constraints_clear_evalob)
+	cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+	BKE_constraints_solve(&ob->constraints, cob, ctime);
+	BKE_constraints_clear_evalob(cob);
 }
 
 void BKE_object_eval_done(EvaluationContext *eval_ctx, Object *ob)
 {
 	PRINT("%s on %s\n", __func__, ob->id.name);
-	(void) eval_ctx; /* Ignored. */
-	(void) ob;  /* Ignored. */
+	
+	/* set negative scale flag in object */
+	if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
+	else ob->transflag &= ~OB_NEG_SCALE;
 }
 
 void BKE_object_eval_modifier(struct EvaluationContext *eval_ctx,
@@ -257,9 +291,10 @@ void BKE_object_eval_uber_transform(EvaluationContext *eval_ctx,
                                     Scene *scene,
                                     Object *ob)
 {
-	(void) eval_ctx;  /* Ignored. */
-	(void) scene;  /* Ignored. */
 	/* TODO(sergey): Currently it's a duplicate of logic in BKE_object_handle_update_ex(). */
+	// XXX: it's almost redundant now...
+	
+	
 	/* Handle proxy copy for target, */
 	if (ob->id.lib && ob->proxy_from) {
 		if (ob->proxy_from->proxy_group) {
@@ -275,8 +310,6 @@ void BKE_object_eval_uber_transform(EvaluationContext *eval_ctx,
 		else
 			copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
 	}
-	else
-		BKE_object_where_is_calc_ex(scene, scene->rigidbody_world, ob, NULL);
 }
 
 void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 08cc4c1..728107c 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -49,6 +49,7 @@ extern "C" {
 #include "BKE_fcurve.h"
 #include "BKE_scene.h"
 #include "BKE_object.h"
+#include "BKE_rigidbody.h"
 
 /* TODO(sergey): This is rather temp solution anyway. */
 #include "../../ikplugin/BIK_api.h"
@@ -257,10 +258,13 @@ void BKE_rigidbody_eval_simulation(EvaluationContext *eval_ctx, Scene *scene) {}
 
 void BKE_rigidbody_object_sync_transforms(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
+	RigidBodyWorld *rbw = scene->rigidbody_world;
+	float ctime = BKE_scene_frame_get(scene);
+	
 	printf("%s on %s\n", __func__, ob->id.name);
 	
-	(void) eval_ctx; /* Ignored. */
-	(void) scene; /* Ignored. */
+	/* read values pushed into RBO from sim/cache... */
+	BKE_rigidbody_sync_transforms(rbw, ob, ctime);
 }
 
 void BKE_mesh_eval_geometry(EvaluationContext *eval_ctx, Mesh *mesh) {}




More information about the Bf-blender-cvs mailing list