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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-05-08 17:09:36 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-05-09 11:34:45 +0300
commitb150c497dc45fc014358c5df6037192fd5d74e4e (patch)
tree859705d75093b0e23be87665f2ec02406c8cf1b8 /source/blender/draw/intern/draw_cache_impl_particles.c
parent5e1445e374996b17c043710005c1cfb7b41a0f45 (diff)
Draw manager: De-duplicate segment counting
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_particles.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 45e04ba7fff..8f21b19c636 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -151,6 +151,19 @@ void DRW_particle_batch_cache_free(ParticleSystem *psys)
MEM_SAFE_FREE(psys->batch_cache);
}
+static void count_cache_segment_keys(ParticleCacheKey **pathcache,
+ const int num_path_cache_keys,
+ ParticleBatchCache *cache)
+{
+ for (int i = 0; i < num_path_cache_keys; i++) {
+ ParticleCacheKey *path = pathcache[i];
+ if (path->segments > 0) {
+ cache->elems_count += path->segments + 2;
+ cache->point_count += path->segments + 1;
+ }
+ }
+}
+
static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
{
if (cache->pos == NULL || cache->indices == NULL) {
@@ -158,27 +171,11 @@ static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
cache->point_count = 0;
if (psys->pathcache && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) {
- for (int i = 0; i < psys->totpart; i++) {
- ParticleCacheKey *path = psys->pathcache[i];
-
- if (path->segments > 0) {
- cache->elems_count += path->segments + 2;
- cache->point_count += path->segments + 1;
- }
- }
+ count_cache_segment_keys(psys->pathcache, psys->totpart, cache);
}
-
if (psys->childcache) {
- int child_count = psys->totchild * psys->part->disp / 100;
-
- for (int i = 0; i < child_count; i++) {
- ParticleCacheKey *path = psys->childcache[i];
-
- if (path->segments > 0) {
- cache->elems_count += path->segments + 2;
- cache->point_count += path->segments + 1;
- }
- }
+ const int child_count = psys->totchild * psys->part->disp / 100;
+ count_cache_segment_keys(psys->childcache, child_count, cache);
}
}
}