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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-06-16 15:05:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-06-16 15:08:44 +0300
commit046adde64f164e5dec2721abbc89bb7759979f92 (patch)
treeb41ba058cb26fc8118a79d54ab1518801380d6ae
parent5ea27bec1fc1e65ce85cccd3079883a41970cd6c (diff)
Fix some rare asserts with new simple/random particle distribution code.
Optimization in binary search could lead to equality instead of expected strictly greater than value. Harmless but noisy, and better be strict here. reported by sergey on irc (with koro cycles benchmark file), thanks.
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 0d7fe04a1e4..7830e4eb650 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -408,10 +408,10 @@ static int distribute_binary_search(float *sum, int n, float value)
return mid;
if (sum[mid] > value) {
- high = mid - 1;
+ high = mid;
}
else {
- low = mid + 1;
+ low = mid;
}
}
@@ -1056,7 +1056,8 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
const float pos = BLI_frand() * element_sum[totmapped - 1];
const int eidx = distribute_binary_search(element_sum, totmapped, pos);
particle_element[p] = element_map[eidx];
- BLI_assert(pos <= element_sum[eidx] && pos > (eidx ? element_sum[eidx - 1] : 0.0f));
+ BLI_assert(pos <= element_sum[eidx]);
+ BLI_assert(eidx ? (pos > element_sum[eidx - 1]) : (pos >= 0.0f));
jitter_offset[particle_element[p]] = pos;
}
}