diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-04-14 00:06:55 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-04-14 00:06:55 +0400 |
commit | 953d938ad19bc1dd81267ceb97e418fd84957532 (patch) | |
tree | 261dce022487b300b58910aa4a67ff65a494a3cf /source/blender | |
parent | 18fb3aa5bfc2d5cdf0f5319bf59e3c6a82ea33dd (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 37 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 |
4 files changed, 27 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ac679adb9c1..ef630a18ab4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -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 */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6b8d5b3b70f..515d1f820aa 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -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 diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fc6b7e7d789..e5d9686a18d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -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 */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 7d7af0ddf82..44cf1398495 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -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 { |