[Bf-blender-cvs] [b150c497dc4] blender2.8: Draw manager: De-duplicate segment counting

Sergey Sharybin noreply at git.blender.org
Wed May 9 10:35:09 CEST 2018


Commit: b150c497dc45fc014358c5df6037192fd5d74e4e
Author: Sergey Sharybin
Date:   Tue May 8 16:09:36 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb150c497dc45fc014358c5df6037192fd5d74e4e

Draw manager: De-duplicate segment counting

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

M	source/blender/draw/intern/draw_cache_impl_particles.c

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

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);
 		}
 	}
 }



More information about the Bf-blender-cvs mailing list