[Bf-blender-cvs] [001ff69] depsgraph_refactor: Depsgraph: Make scene evaluation closer to the master

Sergey Sharybin noreply at git.blender.org
Thu Nov 6 11:15:49 CET 2014


Commit: 001ff699088980f9b46b1b7a9045f38577536a0d
Author: Sergey Sharybin
Date:   Thu Nov 6 11:05:30 2014 +0100
Branches: depsgraph_refactor
https://developer.blender.org/rB001ff699088980f9b46b1b7a9045f38577536a0d

Depsgraph: Make scene evaluation closer to the master

This means BKE_scene_update_tagged() will now do the same callbacks and sound
system updates as the old implementation does and will only replace scene update
with new code.

This is aimed to solve the following issues:

- Adding new objects doesn't abort anymore, this is because   old code was
  rebuilding the depsgraph from the scene update function in cases DAG is NULL.

  Don't see why not to do the same with the new dependency graph for now.

- Callbacks are being executed properly, which should make scripts happy.

  Well, nobody uses this branch yet, but it's good thing to do and easy to
  support anyway.

- Hopefully rendered viewport will be also happier now because the render engine
  update is now called for new depsgraph as well.

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

M	source/blender/blenkernel/intern/scene.c

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index d1ea531..b68ca72 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1617,92 +1617,97 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
 
 void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *scene)
 {
-	if (DEG_get_eval_mode() == DEG_EVAL_MODE_OLD) {
-		Scene *sce_iter;
-		
-		/* keep this first */
-		BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
+	Scene *sce_iter;
+	bool use_new_eval = DEG_get_eval_mode() == DEG_EVAL_MODE_NEW;
 
-		/* (re-)build dependency graph if needed */
-		for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set)
-			DAG_scene_relations_update(bmain, sce_iter);
+	/* keep this first */
+	BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
+
+	/* (re-)build dependency graph if needed */
+	for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set)
+		DAG_scene_relations_update(bmain, sce_iter);
 
-		/* flush editing data if needed */
-		prepare_mesh_for_viewport_render(bmain, scene);
+	/* flush editing data if needed */
+	prepare_mesh_for_viewport_render(bmain, scene);
 
-		/* flush recalc flags to dependencies */
+	/* flush recalc flags to dependencies */
+	if (!use_new_eval) {
 		DAG_ids_flush_tagged(bmain);
+	}
+
+	/* removed calls to quick_cache, see pointcache.c */
 	
-		/* removed calls to quick_cache, see pointcache.c */
-		
-		/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later 
-		 * when trying to find materials with drivers that need evaluating [#32017] 
-		 */
-		BKE_main_id_tag_idcode(bmain, ID_MA, false);
-		BKE_main_id_tag_idcode(bmain, ID_LA, false);
-	
-		/* update all objects: drivers, matrices, displists, etc. flags set
-		 * by depgraph or manual, no layer check here, gets correct flushed
-		 *
-		 * in the future this should handle updates for all datablocks, not
-		 * only objects and scenes. - brecht */
+	/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later 
+	 * when trying to find materials with drivers that need evaluating [#32017] 
+	 */
+	BKE_main_id_tag_idcode(bmain, ID_MA, false);
+	BKE_main_id_tag_idcode(bmain, ID_LA, false);
+
+	/* update all objects: drivers, matrices, displists, etc. flags set
+	 * by depgraph or manual, no layer check here, gets correct flushed
+	 *
+	 * in the future this should handle updates for all datablocks, not
+	 * only objects and scenes. - brecht */
+	if (use_new_eval) {
+		DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph);
+	}
+	else {
 		scene_update_tagged_recursive(eval_ctx, bmain, scene, scene);
-		/* update sound system animation (TODO, move to depsgraph) */
-		sound_update_scene(bmain, scene);
-	
-		/* extra call here to recalc scene animation (for sequencer) */
+	}
+
+	/* update sound system animation (TODO, move to depsgraph) */
+	sound_update_scene(bmain, scene);
+
+	/* extra call here to recalc scene animation (for sequencer) */
+	{
+		AnimData *adt = BKE_animdata_from_id(&scene->id);
+		float ctime = BKE_scene_frame_get(scene);
+		
+		if (adt && (adt->recalc & ADT_RECALC_ANIM))
+			BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
+	}
+
+	/* Extra call here to recalc material animation.
+	 *
+	 * Need to do this so changing material settings from the graph/dopesheet
+	 * will update stuff in the viewport.
+	 */
+	if (!use_new_eval && DAG_id_type_tagged(bmain, ID_MA)) {
+		Material *material;
+		float ctime = BKE_scene_frame_get(scene);
+
+		for (material = bmain->mat.first;
+		     material;
+		     material = material->id.next)
 		{
-			AnimData *adt = BKE_animdata_from_id(&scene->id);
-			float ctime = BKE_scene_frame_get(scene);
-			
+			AnimData *adt = BKE_animdata_from_id(&material->id);
 			if (adt && (adt->recalc & ADT_RECALC_ANIM))
-				BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
+				BKE_animsys_evaluate_animdata(scene, &material->id, adt, ctime, 0);
 		}
-	
-		/* Extra call here to recalc material animation.
-		 *
-		 * Need to do this so changing material settings from the graph/dopesheet
-		 * will update stuff in the viewport.
-		 */
-		if (DAG_id_type_tagged(bmain, ID_MA)) {
-			Material *material;
-			float ctime = BKE_scene_frame_get(scene);
-	
-			for (material = bmain->mat.first;
-			     material;
-			     material = material->id.next)
-			{
-				AnimData *adt = BKE_animdata_from_id(&material->id);
-				if (adt && (adt->recalc & ADT_RECALC_ANIM))
-					BKE_animsys_evaluate_animdata(scene, &material->id, adt, ctime, 0);
-			}
-		}
-	
-		/* Also do the same for node trees. */
-		if (DAG_id_type_tagged(bmain, ID_NT)) {
-			float ctime = BKE_scene_frame_get(scene);
-	
-			FOREACH_NODETREE(bmain, ntree, id)
-			{
-				AnimData *adt = BKE_animdata_from_id(&ntree->id);
-				if (adt && (adt->recalc & ADT_RECALC_ANIM))
-					BKE_animsys_evaluate_animdata(scene, &ntree->id, adt, ctime, 0);
-			}
-			FOREACH_NODETREE_END
+	}
+
+	/* Also do the same for node trees. */
+	if (!use_new_eval && DAG_id_type_tagged(bmain, ID_NT)) {
+		float ctime = BKE_scene_frame_get(scene);
+
+		FOREACH_NODETREE(bmain, ntree, id)
+		{
+			AnimData *adt = BKE_animdata_from_id(&ntree->id);
+			if (adt && (adt->recalc & ADT_RECALC_ANIM))
+				BKE_animsys_evaluate_animdata(scene, &ntree->id, adt, ctime, 0);
 		}
-	
-		/* notify editors and python about recalc */
-		BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
+		FOREACH_NODETREE_END
+	}
+
+	/* notify editors and python about recalc */
+	BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
+
+	if (!use_new_eval) {
 		DAG_ids_check_recalc(bmain, scene, false);
-	
+
 		/* clear recalc flags */
 		DAG_ids_clear_recalc(bmain);
 	}
-	else {
-		/* new depsgraph */
-		BLI_assert(scene->depsgraph);
-		DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph);
-	}
 }
 
 /* applies changes right away, does all sets too */




More information about the Bf-blender-cvs mailing list