[Bf-blender-cvs] [1c410d9] depsgraph_refactor: Depsgraph: Add ubernode which evaluates the whole object

Sergey Sharybin noreply at git.blender.org
Thu Nov 6 14:12:20 CET 2014


Commit: 1c410d9385d5ad1c6a229137b9885a717147d804
Author: Sergey Sharybin
Date:   Thu Nov 6 13:49:48 2014 +0100
Branches: depsgraph_refactor
https://developer.blender.org/rB1c410d9385d5ad1c6a229137b9885a717147d804

Depsgraph: Add ubernode which evaluates the whole object

This way we mimic old depsgraph behavior where each object is effectively
a single node in the dependency graph which takes care of all the updates.

But actually this node only takes care of the modifiers, expecting that the
constraints and so are solved by the local object transform node.

Not sure how much valid the assumption at this state, but it's something
to aim to.

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

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

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 1bfd26d..a9591b6 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -170,6 +170,9 @@ void BKE_object_tfm_protected_restore(struct Object *ob,
                                       const ObjectTfmProtectedChannels *obtfm,
                                       const short protectflag);
 
+void BKE_object_eval_geometry(struct EvaluationContext *eval_ctx,
+                                  struct Scene *scene,
+                                  struct Object *ob);
 void BKE_object_handle_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_object_handle_update_ex(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 72f7d54..f442bb2 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2942,6 +2942,150 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob)
 	return BKE_object_parent_loop_check(par->parent, ob);
 }
 
+void BKE_object_eval_geometry(EvaluationContext *eval_ctx,
+                                  Scene *scene,
+                                  Object *ob)
+{
+	ID *data_id = (ID *)ob->data;
+	AnimData *adt = BKE_animdata_from_id(data_id);
+	Key *key;
+	float ctime = BKE_scene_frame_get(scene);
+
+	if (G.debug & G_DEBUG_DEPSGRAPH)
+		printf("recalcdata %s\n", ob->id.name + 2);
+
+	if (adt) {
+		/* evaluate drivers - datalevel */
+		/* XXX: for mesh types, should we push this to derivedmesh instead? */
+		BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
+	}
+
+	key = BKE_key_from_object(ob);
+	if (key && key->block.first) {
+		if (!(ob->shapeflag & OB_SHAPE_LOCK))
+			BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
+	}
+
+	/* includes all keys and modifiers */
+	switch (ob->type) {
+	case OB_MESH:
+		{
+			BMEditMesh *em = (ob == scene->obedit) ? BKE_editmesh_from_object(ob) : NULL;
+			uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
+#ifdef WITH_FREESTYLE
+			/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
+			if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
+				data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
+			}
+#endif
+			if (em) {
+				makeDerivedMesh(scene, ob, em,  data_mask, 0); /* was CD_MASK_BAREMESH */
+			}
+			else {
+				makeDerivedMesh(scene, ob, NULL, data_mask, 0);
+			}
+			break;
+		}
+	case OB_ARMATURE:
+		if (ob->id.lib && ob->proxy_from) {
+			if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
+				printf("Proxy copy error, lib Object: %s proxy Object: %s\n",
+				       ob->id.name + 2, ob->proxy_from->id.name + 2);
+			}
+		}
+		else {
+			BKE_pose_where_is(scene, ob);
+		}
+		break;
+
+	case OB_MBALL:
+		BKE_displist_make_mball(eval_ctx, scene, ob);
+		break;
+
+	case OB_CURVE:
+	case OB_SURF:
+	case OB_FONT:
+		BKE_displist_make_curveTypes(scene, ob, 0);
+		break;
+
+	case OB_LATTICE:
+		BKE_lattice_modifiers_calc(scene, ob);
+		break;
+
+	case OB_EMPTY:
+		if (ob->empty_drawtype == OB_EMPTY_IMAGE && ob->data)
+			if (BKE_image_is_animated(ob->data))
+				BKE_image_user_check_frame_calc(ob->iuser, (int)ctime, 0);
+		break;
+	}
+
+	/* related materials */
+	/* XXX: without depsgraph tagging, this will always need to be run, which will be slow!
+	 * However, not doing anything (or trying to hack around this lack) is not an option
+	 * anymore, especially due to Cycles [#31834]
+	 */
+	if (ob->totcol) {
+		int a;
+		for (a = 1; a <= ob->totcol; a++) {
+			Material *ma = give_current_material(ob, a);
+			if (ma) {
+				/* recursively update drivers for this material */
+				material_drivers_update(scene, ma, ctime);
+			}
+		}
+	}
+	else if (ob->type == OB_LAMP)
+		lamp_drivers_update(scene, ob->data, ctime);
+
+	/* particles */
+	if (ob != scene->obedit && ob->particlesystem.first) {
+		ParticleSystem *tpsys, *psys;
+		DerivedMesh *dm;
+		ob->transflag &= ~OB_DUPLIPARTS;
+		psys = ob->particlesystem.first;
+		while (psys) {
+			/* ensure this update always happens even if psys is disabled */
+			if (psys->recalc & PSYS_RECALC_TYPE) {
+				psys_changed_type(ob, psys);
+			}
+
+			if (psys_check_enabled(ob, psys)) {
+				/* check use of dupli objects here */
+				if (psys->part && (psys->part->draw_as == PART_DRAW_REND || eval_ctx->mode == DAG_EVAL_RENDER) &&
+				    ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) ||
+				     (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
+					{
+						ob->transflag |= OB_DUPLIPARTS;
+					}
+
+				particle_system_update(scene, ob, psys);
+				psys = psys->next;
+			}
+			else if (psys->flag & PSYS_DELETE) {
+				tpsys = psys->next;
+				BLI_remlink(&ob->particlesystem, psys);
+				psys_free(ob, psys);
+				psys = tpsys;
+			}
+			else
+				psys = psys->next;
+		}
+
+		if (eval_ctx->mode == DAG_EVAL_RENDER && ob->transflag & OB_DUPLIPARTS) {
+			/* this is to make sure we get render level duplis in groups:
+			 * the derivedmesh must be created before init_render_mesh,
+			 * since object_duplilist does dupliparticles before that */
+			dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
+			dm->release(dm);
+
+			for (psys = ob->particlesystem.first; psys; psys = psys->next)
+				psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
+		}
+	}
+
+	/* quick cache removed */
+}
+
 /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
 /*           local_object->proxy      == pointer to library object, saved in files and read */
 
@@ -2998,147 +3142,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
 		}
 		
 		if (ob->recalc & OB_RECALC_DATA) {
-			ID *data_id = (ID *)ob->data;
-			AnimData *adt = BKE_animdata_from_id(data_id);
-			Key *key;
-			float ctime = BKE_scene_frame_get(scene);
-			
-			if (G.debug & G_DEBUG_DEPSGRAPH)
-				printf("recalcdata %s\n", ob->id.name + 2);
-
-			if (adt) {
-				/* evaluate drivers - datalevel */
-				/* XXX: for mesh types, should we push this to derivedmesh instead? */
-				BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
-			}
-			
-			key = BKE_key_from_object(ob);
-			if (key && key->block.first) {
-				if (!(ob->shapeflag & OB_SHAPE_LOCK))
-					BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
-			}
-
-			/* includes all keys and modifiers */
-			switch (ob->type) {
-				case OB_MESH:
-				{
-					BMEditMesh *em = (ob == scene->obedit) ? BKE_editmesh_from_object(ob) : NULL;
-					uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
-#ifdef WITH_FREESTYLE
-					/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
-					if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
-						data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
-					}
-#endif
-					if (em) {
-						makeDerivedMesh(scene, ob, em,  data_mask, 0); /* was CD_MASK_BAREMESH */
-					}
-					else {
-						makeDerivedMesh(scene, ob, NULL, data_mask, 0);
-					}
-					break;
-				}
-				case OB_ARMATURE:
-					if (ob->id.lib && ob->proxy_from) {
-						if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
-							printf("Proxy copy error, lib Object: %s proxy Object: %s\n",
-							       ob->id.name + 2, ob->proxy_from->id.name + 2);
-						}
-					}
-					else {
-						BKE_pose_where_is(scene, ob);
-					}
-					break;
-
-				case OB_MBALL:
-					BKE_displist_make_mball(eval_ctx, scene, ob);
-					break;
-
-				case OB_CURVE:
-				case OB_SURF:
-				case OB_FONT:
-					BKE_displist_make_curveTypes(scene, ob, 0);
-					break;
-				
-				case OB_LATTICE:
-					BKE_lattice_modifiers_calc(scene, ob);
-					break;
-
-				case OB_EMPTY:
-					if (ob->empty_drawtype == OB_EMPTY_IMAGE && ob->data)
-						if (BKE_image_is_animated(ob->data))
-							BKE_image_user_check_frame_calc(ob->iuser, (int)ctime, 0);
-					break;
-			}
-			
-			/* related materials */
-			/* XXX: without depsgraph tagging, this will always need to be run, which will be slow! 
-			 * However, not doing anything (or trying to hack around this lack) is not an option 
-			 * anymore, especially due to Cycles [#31834] 
-			 */
-			if (ob->totcol) {
-				int a;
-				
-				for (a = 1; a <= ob->totcol; a++) {
-					Material *ma = give_current_material(ob, a);
-					
-					if (ma) {
-						/* recursively update drivers for this material */
-						material_drivers_update(scene, ma, ctime);
-					}
-				}
-			}
-			else if (ob->type == OB_LAMP)
-				lamp_drivers_update(scene, ob->data, ctime);
-			
-			/* particles */
-			if (ob != scene->obedit && ob->particlesystem.first) {
-				ParticleSystem *tpsys, *psys;
-				DerivedMesh *dm;
-				ob->transflag &= ~OB_DUPLIPARTS;
-				
-				psys = ob->particlesystem.first;
-				while (psys) {
-					/* ensure this update always happens even if psys is disabled */
-					if (psys->recalc & PSYS_RECALC_TYPE) {
-						psys_changed_type(ob, psys);
-					}
-
-					if (psys_check_enabled(ob, psys)) {
-						/* check use of dupli objects here */
-						if (psys->part && (psys->part->draw_as == PART_DRAW_REND || eval_ctx->mode == DAG_EVAL_RENDER) &&
-						    ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) ||
-						     (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
-						{
-							ob->transflag |= OB_DUPLIPARTS;
-						}
-
-						particle_system_update(scene, ob, psys);
-						psys = psys->next;
-					}
-					else if (psys->flag & PSYS_DELETE) {
-						tpsys = psys->next;
-						BLI_remlink(&ob->particlesystem, psys);
-						psys_free(ob, psys);
-						psys = tpsys;
-					}
-					else
-						psys = psys->next;
-				}
-
-				if (eval_ctx->mode == DAG_EVAL_RENDER && ob->transflag & OB_DUPLIPARTS) {
-					/* this is to make sure we get render level duplis in groups:
-					 * the derivedmesh must be created before init_render_mesh,
-					 * since 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list