diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-18 02:05:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-18 02:14:47 +0400 |
commit | 7da21752716a0e9e6e6ad8ccbda20fb1c5e8e123 (patch) | |
tree | d72216f3cdf2e5887282fbce2e0eec28d025392d /source/blender/blenkernel/intern | |
parent | a861e5572a70111bbe3ae84d82595eddc43b7d88 (diff) |
KDTree: deprecate 'normal' argument
Normals for each kdtree node were allocated but never used,
and search args only use in particles/boids code.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/boids.c | 33 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 6 |
6 files changed, 41 insertions, 34 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 157de3e2f1c..5731455fc01 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 b56522034c5..24ccc663878 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 de9dd011e04..fb4fde91d8b 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 3a6e710d68c..2c7d58586cf 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 3f4c53692e5..92b2876cb78 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(ParticleThread *threads, Scene *scene, D tree=BLI_kdtree_new(totpart); for (p=0,pa=psys->particles; p<totpart; p++,pa++) { - psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,ornor); + psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,NULL); BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1); - BLI_kdtree_insert(tree, p, orco, ornor); + BLI_kdtree_insert(tree, p, orco); } BLI_kdtree_balance(tree); @@ -1170,7 +1170,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else copy_v3_v3(co,mv[p].co); - BLI_kdtree_insert(tree,p,co,NULL); + BLI_kdtree_insert(tree, p, co); } BLI_kdtree_balance(tree); @@ -2249,9 +2249,9 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra) LOOP_SHOWN_PARTICLES { if (pa->alive == PARS_ALIVE) { if (pa->state.time == cfra) - BLI_kdtree_insert(psys->tree, p, pa->prev_state.co, NULL); + BLI_kdtree_insert(psys->tree, p, pa->prev_state.co); else - BLI_kdtree_insert(psys->tree, p, pa->state.co, NULL); + BLI_kdtree_insert(psys->tree, p, pa->state.co); } } BLI_kdtree_balance(psys->tree); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 0ec277aeed6..d8c27d4468c 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1297,7 +1297,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke mul_mat3_m4_v3(sds->imat, &particle_vel[valid_particles * 3]); if (sfs->flags & MOD_SMOKE_FLOW_USE_PART_SIZE) { - BLI_kdtree_insert(tree, valid_particles, pos, NULL); + BLI_kdtree_insert(tree, valid_particles, pos); } /* calculate emission map bounds */ @@ -1379,7 +1379,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke /* find particle distance from the kdtree */ KDTreeNearest nearest; float range = solid + smooth; - BLI_kdtree_find_nearest(tree, ray_start, NULL, &nearest); + BLI_kdtree_find_nearest(tree, ray_start, &nearest); if (nearest.dist < range) { em->influence[index] = (nearest.dist < solid) ? 1.0f : (1.0f - (nearest.dist-solid) / smooth); @@ -1404,7 +1404,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke /* find particle distance from the kdtree */ KDTreeNearest nearest; float range = solid + hr_smooth; - BLI_kdtree_find_nearest(tree, ray_start, NULL, &nearest); + BLI_kdtree_find_nearest(tree, ray_start, &nearest); if (nearest.dist < range) { em->influence_high[index] = (nearest.dist < solid) ? 1.0f : (1.0f - (nearest.dist-solid) / smooth); |