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.
This commit is contained in:
Janne Karhu 2010-04-13 20:06:55 +00:00
parent 18fb3aa5bf
commit 953d938ad1
4 changed files with 27 additions and 38 deletions

View File

@ -2489,6 +2489,8 @@ void object_handle_update(Scene *scene, Object *ob)
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 @@ void object_handle_update(Scene *scene, Object *ob)
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 */

View File

@ -2325,39 +2325,6 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
/* 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 @@ void BKE_ptcache_quick_cache_all(Scene *scene)
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

View File

@ -924,6 +924,8 @@ void scene_update_tagged(Scene *scene)
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 @@ void scene_update_tagged(Scene *scene)
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 */

View File

@ -735,7 +735,7 @@ typedef struct UnitSettings {
typedef struct PhysicsSettings {
float gravity[3];
int flag;
int flag, quick_cache_step, rt;
} PhysicsSettings;
typedef struct Scene {