From 47a41ad055f40a140b862499ca3955081e860a76 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 14 Aug 2009 16:25:59 +0000 Subject: Proper copy code for multiple point caches. --- source/blender/blenkernel/BKE_pointcache.h | 2 +- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/object.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 13 ++++++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index b83afb6b28f..c8a7a1cbf90 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -192,7 +192,7 @@ struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches); void BKE_ptache_free_mem(struct PointCache *cache); void BKE_ptcache_free(struct PointCache *cache); void BKE_ptcache_free_list(struct ListBase *ptcaches); -struct PointCache *BKE_ptcache_copy(struct PointCache *cache); +struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct ListBase *ptcaches_old); /********************** Baking *********************/ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0c975a10c0a..ecba1c1a6ad 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5978,7 +5978,7 @@ static void clothModifier_copyData(ModifierData *md, ModifierData *target) tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->point_cache = BKE_ptcache_copy(clmd->point_cache); + tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches); tclmd->clothObject = NULL; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 150a5aa97aa..9423f80cba2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1026,7 +1026,7 @@ SoftBody *copy_softbody(SoftBody *sb) sbn->scratch= NULL; - sbn->pointcache= BKE_ptcache_copy(sb->pointcache); + sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); return sbn; } @@ -1085,7 +1085,7 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) psysn->reactevents.first = psysn->reactevents.last = NULL; psysn->renderdata = NULL; - psysn->pointcache= BKE_ptcache_copy(psys->pointcache); + psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); id_us_plus((ID *)psysn->part); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7aa01de71d0..59e2c3f6d72 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1630,7 +1630,7 @@ void BKE_ptcache_free_list(ListBase *ptcaches) BLI_freelistN(ptcaches); } -PointCache *BKE_ptcache_copy(PointCache *cache) +static PointCache *ptcache_copy(PointCache *cache) { PointCache *ncache; @@ -1645,7 +1645,18 @@ PointCache *BKE_ptcache_copy(PointCache *cache) return ncache; } +/* returns first point cache */ +PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old) +{ + PointCache *cache = ptcaches_old->first; + + ptcaches_new->first = ptcaches_new->last = NULL; + for(; cache; cache=cache->next) + BLI_addtail(ptcaches_new, ptcache_copy(cache)); + + return ptcaches_new->first; +} /* Baking */ -- cgit v1.2.3