[Bf-blender-cvs] [7da2175] master: KDTree: deprecate 'normal' argument

Campbell Barton noreply at git.blender.org
Mon Mar 17 23:15:32 CET 2014


Commit: 7da21752716a0e9e6e6ad8ccbda20fb1c5e8e123
Author: Campbell Barton
Date:   Tue Mar 18 09:05:07 2014 +1100
https://developer.blender.org/rB7da21752716a0e9e6e6ad8ccbda20fb1c5e8e123

KDTree: deprecate 'normal' argument

Normals for each kdtree node were allocated but never used,
and search args only use in particles/boids code.

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

M	source/blender/blenkernel/intern/boids.c
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/blenlib/BLI_kdtree.h
M	source/blender/blenlib/intern/BLI_kdtree.c
M	source/blender/editors/mesh/meshtools.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/python/mathutils/mathutils_kdtree.c

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

diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 157de3e..5731455 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -255,8 +255,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
 
 	//check boids in own system
 	if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
-		neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, pa->prev_state.co, pa->prev_state.ave,
-		                                    &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
+		neighbors = BLI_kdtree_range_search__normal(
+		        bbd->sim->psys->tree, pa->prev_state.co, pa->prev_state.ave,
+		        &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
 		if (neighbors > 1) for (n=1; n<neighbors; n++) {
 			copy_v3_v3(co1, pa->prev_state.co);
 			copy_v3_v3(vel1, pa->prev_state.vel);
@@ -302,8 +303,10 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
 		ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
 
 		if (epsys) {
-			neighbors = BLI_kdtree_range_search(epsys->tree, pa->prev_state.co, pa->prev_state.ave,
-			                                    &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
+			neighbors = BLI_kdtree_range_search__normal(
+			        epsys->tree, pa->prev_state.co, pa->prev_state.ave,
+			        &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
+
 			if (neighbors > 0) for (n=0; n<neighbors; n++) {
 				copy_v3_v3(co1, pa->prev_state.co);
 				copy_v3_v3(vel1, pa->prev_state.vel);
@@ -358,8 +361,9 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
 	ParticleTarget *pt;
 	float len = 2.0f * val->personal_space * pa->size + 1.0f;
 	float vec[3] = {0.0f, 0.0f, 0.0f};
-	int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, pa->prev_state.co, NULL,
-	                                        &ptn, 2.0f * val->personal_space * pa->size);
+	int neighbors = BLI_kdtree_range_search(
+	            bbd->sim->psys->tree, pa->prev_state.co,
+	            &ptn, 2.0f * val->personal_space * pa->size);
 	int ret = 0;
 
 	if (neighbors > 1 && ptn[1].dist!=0.0f) {
@@ -377,8 +381,9 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
 		ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
 
 		if (epsys) {
-			neighbors = BLI_kdtree_range_search(epsys->tree, pa->prev_state.co, NULL,
-			                                    &ptn, 2.0f * val->personal_space * pa->size);
+			neighbors = BLI_kdtree_range_search(
+			        epsys->tree, pa->prev_state.co,
+			        &ptn, 2.0f * val->personal_space * pa->size);
 			
 			if (neighbors > 0 && ptn[0].dist < len) {
 				sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
@@ -398,7 +403,7 @@ static int rule_flock(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UN
 {
 	KDTreeNearest ptn[11];
 	float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
-	int neighbors = BLI_kdtree_find_nearest_n(bbd->sim->psys->tree, pa->state.co, pa->prev_state.ave, ptn, 11);
+	int neighbors = BLI_kdtree_find_nearest_n__normal(bbd->sim->psys->tree, pa->state.co, pa->prev_state.ave, ptn, 11);
 	int n;
 	int ret = 0;
 
@@ -625,8 +630,9 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
 	int n, ret = 0;
 
 	/* calculate own group strength */
-	int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, pa->prev_state.co, NULL,
-	                                        &ptn, fbr->distance);
+	int neighbors = BLI_kdtree_range_search(
+	            bbd->sim->psys->tree, pa->prev_state.co,
+	            &ptn, fbr->distance);
 	for (n=0; n<neighbors; n++) {
 		bpa = bbd->sim->psys->particles[ptn[n].index].boid;
 		health += bpa->data.health;
@@ -642,8 +648,9 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
 		if (epsys) {
 			epars = epsys->particles;
 
-			neighbors = BLI_kdtree_range_search(epsys->tree, pa->prev_state.co, NULL,
-			                                    &ptn, fbr->distance);
+			neighbors = BLI_kdtree_range_search(
+			        epsys->tree, pa->prev_state.co,
+			        &ptn, fbr->distance);
 			
 			health = 0.0f;
 
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index b565220..24ccc66 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -3716,7 +3716,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
 		/* make sure particle is close enough to canvas */
 		if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range)) continue;
 
-		BLI_kdtree_insert(tree, p, pa->state.co, NULL);
+		BLI_kdtree_insert(tree, p, pa->state.co);
 
 		/* calc particle system bounds */
 		boundInsert(&part_bb, pa->state.co);
@@ -3773,7 +3773,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
 					float smooth_range, part_solidradius;
 
 					/* Find nearest particle and get distance to it	*/
-					BLI_kdtree_find_nearest(tree, bData->realCoord[bData->s_pos[index]].v, NULL, &nearest);
+					BLI_kdtree_find_nearest(tree, bData->realCoord[bData->s_pos[index]].v, &nearest);
 					/* if outside maximum range, no other particle can influence either */
 					if (nearest.dist > range) continue;
 
@@ -3813,7 +3813,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
 					/* Make gcc happy! */
 					dist = max_range;
 
-					particles = BLI_kdtree_range_search(tree, bData->realCoord[bData->s_pos[index]].v, NULL,
+					particles = BLI_kdtree_range_search(tree, bData->realCoord[bData->s_pos[index]].v,
 					                                    &nearest, max_range);
 
 					/* Find particle that produces highest influence */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index de9dd01..fb4fde9 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3667,7 +3667,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 					if (index[i] != ORIGINDEX_NONE) {
 						float co[3];
 						mul_v3_m4v3(co, ob->obmat, mvert[i].co);
-						BLI_kdtree_insert(tree, index[i], co, NULL);
+						BLI_kdtree_insert(tree, index[i], co);
 						tot++;
 					}
 				}
@@ -3681,7 +3681,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 				for (i = 0; i < tot; i++) {
 					float co[3];
 					mul_v3_m4v3(co, ob->obmat, mvert[i].co);
-					BLI_kdtree_insert(tree, i, co, NULL);
+					BLI_kdtree_insert(tree, i, co);
 				}
 			}
 
@@ -3711,7 +3711,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 					while (a--) {
 						float co[3];
 						mul_v3_m4v3(co, ob->obmat, bezt->vec[1]);
-						BLI_kdtree_insert(tree, i++, co, NULL);
+						BLI_kdtree_insert(tree, i++, co);
 						bezt++;
 					}
 				}
@@ -3723,7 +3723,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 					while (a--) {
 						float co[3];
 						mul_v3_m4v3(co, ob->obmat, bp->vec);
-						BLI_kdtree_insert(tree, i++, co, NULL);
+						BLI_kdtree_insert(tree, i++, co);
 						bp++;
 					}
 				}
@@ -3747,7 +3747,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 			for (bp = lt->def; i < tot; bp++) {
 				float co[3];
 				mul_v3_m4v3(co, ob->obmat, bp->vec);
-				BLI_kdtree_insert(tree, i++, co, NULL);
+				BLI_kdtree_insert(tree, i++, co);
 			}
 
 			BLI_kdtree_balance(tree);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3a6e710..2c7d585 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2406,14 +2406,14 @@ void psys_find_parents(ParticleSimulationData *sim)
 
 	for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
 		psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0);
-		BLI_kdtree_insert(tree, p, orco, NULL);
+		BLI_kdtree_insert(tree, p, orco);
 	}
 
 	BLI_kdtree_balance(tree);
 
 	for (; p < totchild; p++, cpa++) {
 		psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0);
-		cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL, NULL);
+		cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL);
 	}
 
 	BLI_kdtree_free(tree);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 3f4c536..92b2876 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -815,7 +815,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
 
 			psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
 			BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
-			maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,NULL,ptn,3);
+			maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 
 			for (w=0; w<maxw; w++) {
 				pa->verts[w]=ptn->num;
@@ -940,7 +940,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
 
 			psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL);
 			BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
-			maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,NULL,ptn,3);
+			maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 
 			maxd=ptn[maxw-1].dist;
 			/* mind=ptn[0].dist; */ /* UNUSED */
@@ -1077,7 +1077,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
 	int totelem=0, totpart, *particle_element=0, children=0, totseam=0;
 	int jitlevel= 1, distr;
 	float *element_weight=NULL,*element_sum=NULL,*jitter_offset=NULL, *vweight=NULL;
-	float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3], ornor[3];
+	float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3];
 	
 	if (ELEM3(NULL, ob, psys, psys->part))
 		return 0;
@@ -1128,9 +1128,9 @@ static int distribute_threads_init_data(Particl

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list