Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-01-09 10:41:51 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-01-09 10:41:51 +0300
commite32bbef017df64a99acedd4f3f4ba32713c50a3b (patch)
tree881bf3c46da067ae6715a77a1763f2eb04d7600c /source/blender/blenkernel/intern/particle.c
parent76a762aa51a4cb774dfd7940fb77916037efad8c (diff)
Fix for [#25544] Blender crashes when changing the particles emission amount
* I've getting bad feelings about the point cache index_array for a while (cause for this bug too), so from now on memory cache uses a simple binary search directly on the index data to handle queries to specific data points. * This is a bit slower than just checking from a dedicated array, but it's much less error prone, uses less memory and makes the code more readable too, so it's not a tough choice.
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r--source/blender/blenkernel/intern/particle.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 018b882f7a2..26f96d0c304 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1056,6 +1056,7 @@ typedef struct ParticleInterpolationData {
static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *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;
@@ -1070,15 +1071,19 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
pm = *cur;
- BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame);
- if(pm->prev->index_array && pm->prev->index_array[index] == 0)
+ index2 = BKE_ptcache_mem_index_find(pm, index);
+ index1 = BKE_ptcache_mem_index_find(pm->prev, index);
+
+ BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
+ if(index1 < 0)
copy_particle_key(key1, key2, 1);
else
- BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame);
+ 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;
- BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame);
+ 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);
}
}
@@ -1089,14 +1094,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float
int ret = 0;
for(pm=cache->mem_cache.first; pm; pm=pm->next) {
- if(pm->index_array) {
- if(pm->index_array[index]) {
- *start = pm->frame;
- ret++;
- break;
- }
- }
- else {
+ if(BKE_ptcache_mem_index_find(pm, index) >= 0) {
*start = pm->frame;
ret++;
break;
@@ -1104,14 +1102,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float
}
for(pm=cache->mem_cache.last; pm; pm=pm->prev) {
- if(pm->index_array) {
- if(pm->index_array[index]) {
- *end = pm->frame;
- ret++;
- break;
- }
- }
- else {
+ if(BKE_ptcache_mem_index_find(pm, index) >= 0) {
*end = pm->frame;
ret++;
break;
@@ -1126,13 +1117,8 @@ float psys_get_dietime_from_cache(PointCache *cache, int index) {
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) {
- if(pm->index_array) {
- if(pm->index_array[index])
- return (float)pm->frame;
- }
- else {
+ if(BKE_ptcache_mem_index_find(pm, index) >= 0)
return (float)pm->frame;
- }
}
return (float)dietime;