From 2849201339f21eec8d5287e3e2199573b625fc40 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 22 Jun 2010 09:12:22 +0000 Subject: hopefully fix some flickering in timeline cache display --- source/blender/editors/space_time/space_time.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_time/space_time.c') diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 245a60df6e5..454dc6117ba 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -169,8 +169,6 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) Object *ob = CTX_data_active_object(C); PTCacheID *pid; ListBase pidlist; - float *fp; - int i; time_cache_free(stime); @@ -183,6 +181,8 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) * add spacetimecache and vertex array for each */ for(pid=pidlist.first; pid; pid=pid->next) { SpaceTimeCache *stc; + float *fp, *array; + int i, len; switch(pid->type) { case PTCACHE_TYPE_SOFTBODY: @@ -211,11 +211,12 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) /* first allocate with maximum number of frames needed */ BKE_ptcache_id_time(pid, CTX_data_scene(C), 0, &stc->startframe, &stc->endframe, NULL); - stc->len = (stc->endframe - stc->startframe + 1)*4; - fp = stc->array = MEM_callocN(stc->len*2*sizeof(float), "SpaceTimeCache array"); - + len = (stc->endframe - stc->startframe + 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++) { + if (BKE_ptcache_id_exist(pid, i)) { fp[0] = (float)i; fp[1] = 0.0; @@ -236,7 +237,11 @@ static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) } /* update with final number of frames */ stc->len = i*4; - stc->array = MEM_reallocN(stc->array, stc->len*2*sizeof(float)); + stc->array = MEM_mallocN(stc->len*2*sizeof(float), "SpaceTimeCache array"); + memcpy(stc->array, array, stc->len*2*sizeof(float)); + + MEM_freeN(array); + array = NULL; stc->ok = 1; -- cgit v1.2.3