From afa4b855caa874d32d0cd0e02524846da58628c1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 27 Sep 2010 09:58:37 +0000 Subject: Fixed: Showing pointcached frames in the timeline was terribly slow when using disk cache. * The existence of cached frames was checked each frame causing hundreds of disk operations per frame update. * Pointcache now keeps an updated array of the cached frames for fast "frame exists in cache" queries. * This fix also speeds up some other pointcache operations nicely. --- source/blender/editors/space_time/space_time.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_time') diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index de9c063f069..bbdd6891199 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -181,6 +181,7 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) SpaceTimeCache *stc; float *fp, *array; int i, len; + int sta, end; switch(pid->type) { case PTCACHE_TYPE_SOFTBODY: @@ -197,6 +198,11 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; break; } + + BKE_ptcache_id_time(pid, CTX_data_scene(C), 0, &sta, &end, NULL); + + if(pid->cache->cached_frames==NULL) + continue; stc= MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache"); @@ -208,14 +214,15 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) stc->flag |= PTCACHE_DISK_CACHE; /* first allocate with maximum number of frames needed */ - BKE_ptcache_id_time(pid, CTX_data_scene(C), 0, &stc->startframe, &stc->endframe, NULL); - len = (stc->endframe - stc->startframe + 1)*4; + stc->startframe = sta; + stc->endframe = end; + len = (end - sta + 1)*4; fp = array = MEM_callocN(len*2*sizeof(float), "temporary timeline cache array"); /* fill the vertex array with a quad for each cached frame */ - for (i=stc->startframe; i<=stc->endframe; i++) { + for (i=sta; i<=end; i++) { - if (BKE_ptcache_id_exist(pid, i)) { + if (pid->cache->cached_frames[i-sta]) { fp[0] = (float)i; fp[1] = 0.0; fp+=2; -- cgit v1.2.3