[Bf-blender-cvs] [67655f2] alembic_pointcache: Removed remaining pointcache->mem_cache access in particles. Instead the particle system should now use its own local mem_cache list for storing cache data in memory. The actual PointCache struct does not make this distinction any more.

Lukas Tönne noreply at git.blender.org
Thu Oct 16 16:53:34 CEST 2014


Commit: 67655f2a7ff3d4e0e062578c9edc48a74cfee4ed
Author: Lukas Tönne
Date:   Thu Nov 28 08:58:27 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB67655f2a7ff3d4e0e062578c9edc48a74cfee4ed

Removed remaining pointcache->mem_cache access in particles. Instead the
particle system should now use its own local mem_cache list for storing
cache data in memory. The actual PointCache struct does not make this
distinction any more.

Eventually the particle system should have clean methods for reading
cache data into other structures for editing and displaying cache data,
but this can not be cleaned up easily without major refactoring. For now
the important thing is to keep psys away from the PointCache internals
so we can implement a nice API for it without psys interfering.

===================================================================

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index d4965cf..5fec084 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -356,7 +356,7 @@ void psys_mat_hair_to_object(struct Object *ob, struct DerivedMesh *dm, short fr
 void psys_mat_hair_to_global(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[4][4]);
 void psys_mat_hair_to_orco(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[4][4]);
 
-float psys_get_dietime_from_cache(struct PointCache *cache, int index);
+float psys_get_dietime_from_cache(struct ListBase *mem_cache, int index);
 
 void psys_free_pdd(struct ParticleSystem *psys);
 
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 251d7b1..010a67e 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1099,15 +1099,15 @@ typedef struct ParticleInterpolationData {
 	float birthtime, dietime;
 	int bspline;
 } ParticleInterpolationData;
-/* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */
+/* Assumes mem_cache exists, so call psys_make_temp_pointcache() before use */
 /* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */
-static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
+static void get_pointcache_keys_for_time(Object *UNUSED(ob), ListBase *mem_cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
 {
 	static PTCacheMem *pm = NULL;
 	int index1, index2;
 
 	if (index < 0) { /* initialize */
-		*cur = cache->mem_cache.first;
+		*cur = mem_cache->first;
 
 		if (*cur)
 			*cur = (*cur)->next;
@@ -1128,20 +1128,20 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
 			else
 				BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame);
 		}
-		else if (cache->mem_cache.first) {
-			pm = cache->mem_cache.first;
+		else if (mem_cache->first) {
+			pm = mem_cache->first;
 			index2 = BKE_ptcache_mem_index_find(pm, index);
 			BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
 			copy_particle_key(key1, key2, 1);
 		}
 	}
 }
-static int get_pointcache_times_for_particle(PointCache *cache, int index, float *start, float *end)
+static int get_pointcache_times_for_particle(ListBase *mem_cache, int index, float *start, float *end)
 {
 	PTCacheMem *pm;
 	int ret = 0;
 
-	for (pm = cache->mem_cache.first; pm; pm = pm->next) {
+	for (pm = mem_cache->first; pm; pm = pm->next) {
 		if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
 			*start = pm->frame;
 			ret++;
@@ -1149,7 +1149,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float
 		}
 	}
 
-	for (pm = cache->mem_cache.last; pm; pm = pm->prev) {
+	for (pm = mem_cache->last; pm; pm = pm->prev) {
 		if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
 			*end = pm->frame;
 			ret++;
@@ -1160,12 +1160,12 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float
 	return ret == 2;
 }
 
-float psys_get_dietime_from_cache(PointCache *cache, int index)
+float psys_get_dietime_from_cache(ListBase *mem_cache, int index)
 {
 	PTCacheMem *pm;
 	int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */
 
-	for (pm = cache->mem_cache.last; pm; pm = pm->prev) {
+	for (pm = mem_cache->last; pm; pm = pm->prev) {
 		if (BKE_ptcache_mem_index_find(pm, index) >= 0)
 			return (float)pm->frame;
 	}
@@ -1195,11 +1195,11 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
 	}
 	else if (pind->cache) {
 		float start = 0.0f, end = 0.0f;
-		get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL);
+		get_pointcache_keys_for_time(ob, &psys->mem_pointcache, &pind->pm, -1, 0.0f, NULL, NULL);
 		pind->birthtime = pa ? pa->time : pind->cache->startframe;
 		pind->dietime = pa ? pa->dietime : pind->cache->endframe;
 
-		if (get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
+		if (get_pointcache_times_for_particle(&psys->mem_pointcache, pa - psys->particles, &start, &end)) {
 			pind->birthtime = MAX2(pind->birthtime, start);
 			pind->dietime = MIN2(pind->dietime, end);
 		}
@@ -1332,7 +1332,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
 		memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey));
 	}
 	else if (pind->cache) {
-		get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys + 1, keys + 2);
+		get_pointcache_keys_for_time(NULL, &psys->mem_pointcache, &pind->pm, p, real_t, keys + 1, keys + 2);
 	}
 	else {
 		hair_to_particle(keys + 1, pind->hkey[0]);
@@ -2968,7 +2968,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
 			return;
 
 	keyed = psys->flag & PSYS_KEYED;
-	baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR;
+	baked = psys->mem_pointcache.first && psys->part->type != PART_HAIR;
 
 	/* clear out old and create new empty path cache */
 	psys_free_path_cache(psys, psys->edit);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 6b31d35..ebdeee5 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2026,8 +2026,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
 	pa->dietime = pa->time + pa->lifetime;
 
 	if (sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED &&
-		sim->psys->pointcache->mem_cache.first) {
-		float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p);
+		sim->psys->mem_pointcache.first) {
+		float dietime = psys_get_dietime_from_cache(&sim->psys->mem_pointcache, p);
 		pa->dietime = MIN2(pa->dietime, dietime);
 	}




More information about the Bf-blender-cvs mailing list