[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28175] trunk/blender/source/blender: Testing for the need to quick cache was causing slowdowns on files with many duplis .

Janne Karhu jhkarh at gmail.com
Tue Apr 13 22:06:56 CEST 2010


Revision: 28175
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28175
Author:   jhk
Date:     2010-04-13 22:06:55 +0200 (Tue, 13 Apr 2010)

Log Message:
-----------
Testing for the need to quick cache was causing slowdowns on files with many duplis.
* The test is now only done when some object that uses cache has actually changed.
* The added scene->physics_settings->quick_cache_step is only an internal counter, not a user changeable value.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/blenkernel/intern/scene.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2010-04-13 19:44:16 UTC (rev 28174)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2010-04-13 20:06:55 UTC (rev 28175)
@@ -2489,6 +2489,8 @@
 			ID *data_id= (ID *)ob->data;
 			AnimData *adt= BKE_animdata_from_id(data_id);
 			float ctime= (float)scene->r.cfra; // XXX this is bad...
+			ListBase pidlist;
+			PTCacheID *pid;
 			
 			if (G.f & G_DEBUG)
 				printf("recalcdata %s\n", ob->id.name+2);
@@ -2577,6 +2579,24 @@
 						psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
 				}
 			}
+
+			/* check if quick cache is needed */
+			BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
+
+			for(pid=pidlist.first; pid; pid=pid->next) {
+				if((pid->cache->flag & PTCACHE_BAKED)
+					|| (pid->cache->flag & PTCACHE_QUICK_CACHE)==0)
+					continue;
+
+				if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
+					scene->physics_settings.quick_cache_step =
+						scene->physics_settings.quick_cache_step ?
+						MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) :
+						pid->cache->step;
+				}
+			}
+
+			BLI_freelistN(&pidlist);
 		}
 
 		/* the no-group proxy case, we call update */

Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-04-13 19:44:16 UTC (rev 28174)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-04-13 20:06:55 UTC (rev 28175)
@@ -2325,39 +2325,6 @@
 
 
 /* Baking */
-static int count_quick_cache(Scene *scene, int *quick_step)
-{
-	Base *base;
-	PTCacheID *pid;
-	ListBase pidlist;
-	int autocache_count= 0;
-	Scene *sce; /* for macro only */
-
-	for(SETLOOPER(scene, base)) {
-		if(base->object) {
-			BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
-
-			for(pid=pidlist.first; pid; pid=pid->next) {
-				if((pid->cache->flag & PTCACHE_BAKED)
-					|| (pid->cache->flag & PTCACHE_QUICK_CACHE)==0)
-					continue;
-
-				if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
-					if(!autocache_count)
-						*quick_step = pid->cache->step;
-					else
-						*quick_step = MIN2(*quick_step, pid->cache->step);
-
-					autocache_count++;
-				}
-			}
-
-			BLI_freelistN(&pidlist);
-		}
-	}
-
-	return autocache_count;
-}
 void BKE_ptcache_quick_cache_all(Scene *scene)
 {
 	PTCacheBaker baker;
@@ -2372,9 +2339,9 @@
 	baker.render=0;
 	baker.anim_init = 0;
 	baker.scene=scene;
+	baker.quick_step=scene->physics_settings.quick_cache_step;
 
-	if(count_quick_cache(scene, &baker.quick_step))
-		BKE_ptcache_make_cache(&baker);
+	BKE_ptcache_make_cache(&baker);
 }
 
 /* Simulation thread, no need for interlocks as data written in both threads

Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/scene.c	2010-04-13 19:44:16 UTC (rev 28174)
+++ trunk/blender/source/blender/blenkernel/intern/scene.c	2010-04-13 20:06:55 UTC (rev 28175)
@@ -924,6 +924,8 @@
 	Object *ob;
 	float ctime = frame_to_float(scene, scene->r.cfra); 
 
+	scene->physics_settings.quick_cache_step= 0;
+
 	/* update all objects: drivers, matrices, displists, etc. flags set
 	   by depgraph or manual, no layer check here, gets correct flushed */
 
@@ -957,8 +959,8 @@
 			BKE_animsys_evaluate_animdata(&scene->id, adt, ctime, 0);
 	}
 
-	/* XXX - this is called far to often, should be made apart of the depgraph */
-	BKE_ptcache_quick_cache_all(scene);
+	if(scene->physics_settings.quick_cache_step)
+		BKE_ptcache_quick_cache_all(scene);
 
 	/* in the future this should handle updates for all datablocks, not
 	   only objects and scenes. - brecht */

Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h	2010-04-13 19:44:16 UTC (rev 28174)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h	2010-04-13 20:06:55 UTC (rev 28175)
@@ -735,7 +735,7 @@
 
 typedef struct PhysicsSettings {
 	float gravity[3];
-	int flag;
+	int flag, quick_cache_step, rt;
 } PhysicsSettings;
 
 typedef struct Scene {





More information about the Bf-blender-cvs mailing list