diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-03-19 09:16:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-03-19 10:31:56 +0300 |
commit | 1a7596951aafcd0f9c0f112a79c9b6e79d6ac323 (patch) | |
tree | 0621c6f79127f9216b481e8df137be14b11699d4 /source | |
parent | 6aeb1f7f5609dc1e82b9b2d915e2ee54b3c467de (diff) |
BLI_kdopbvh: Pass center to to range callback
Useful when BLI_bvhtree_range_query callback calculates a new position to measure from.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_particle.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_kdopbvh.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 4 |
5 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index b6b40ad081d..e17fb9f7a02 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -101,7 +101,7 @@ typedef struct SPHData { /* Integrator callbacks. This allows different SPH implementations. */ void (*force_cb) (void *sphdata_v, ParticleKey *state, float *force, float *impulse); - void (*density_cb) (void *rangedata_v, int index, float squared_dist); + void (*density_cb) (void *rangedata_v, int index, const float co[3], float squared_dist); } SPHData; typedef struct ParticleTexture { diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e9ce5329ad0..10ca88cdeeb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1584,13 +1584,15 @@ static void sph_evaluate_func(BVHTree *tree, ParticleSystem **psys, float co[3], } } } -static void sph_density_accum_cb(void *userdata, int index, float squared_dist) +static void sph_density_accum_cb(void *userdata, int index, const float co[3], float squared_dist) { SPHRangeData *pfr = (SPHRangeData *)userdata; ParticleData *npa = pfr->npsys->particles + index; float q; float dist; + UNUSED_VARS(co); + if (npa == pfr->pa || squared_dist < FLT_EPSILON) return; @@ -1767,7 +1769,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa sphdata->pass++; } -static void sphclassical_density_accum_cb(void *userdata, int index, float UNUSED(squared_dist)) +static void sphclassical_density_accum_cb(void *userdata, int index, const float co[3], float UNUSED(squared_dist)) { SPHRangeData *pfr = (SPHRangeData *)userdata; ParticleData *npa = pfr->npsys->particles + index; @@ -1779,7 +1781,7 @@ static void sphclassical_density_accum_cb(void *userdata, int index, float UNUSE /* Exclude particles that are more than 2h away. Can't use squared_dist here * because it is not accurate enough. Use current state, i.e. the output of * basic_integrate() - z0r */ - sub_v3_v3v3(vec, npa->state.co, pfr->pa->state.co); + sub_v3_v3v3(vec, npa->state.co, co); rij = len_v3(vec); rij_h = rij / pfr->h; if (rij_h > 2.0f) @@ -1798,7 +1800,7 @@ static void sphclassical_density_accum_cb(void *userdata, int index, float UNUSE pfr->data[1] += q / npa->sphdensity; } -static void sphclassical_neighbour_accum_cb(void *userdata, int index, float UNUSED(squared_dist)) +static void sphclassical_neighbour_accum_cb(void *userdata, int index, const float co[3], float UNUSED(squared_dist)) { SPHRangeData *pfr = (SPHRangeData *)userdata; ParticleData *npa = pfr->npsys->particles + index; @@ -1811,7 +1813,7 @@ static void sphclassical_neighbour_accum_cb(void *userdata, int index, float UNU /* Exclude particles that are more than 2h away. Can't use squared_dist here * because it is not accurate enough. Use current state, i.e. the output of * basic_integrate() - z0r */ - sub_v3_v3v3(vec, npa->state.co, pfr->pa->state.co); + sub_v3_v3v3(vec, npa->state.co, co); rij = len_v3(vec); rij_h = rij / pfr->h; if (rij_h > 2.0f) diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index f1ef1d9f9b9..be792669ef1 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -102,7 +102,7 @@ typedef void (*BVHTree_NearestToRayCallback)(void *userdata, int index, const BV typedef bool (*BVHTree_OverlapCallback)(void *userdata, int index_a, int index_b, int thread); /* callback to range search query */ -typedef void (*BVHTree_RangeQuery)(void *userdata, int index, float dist_sq); +typedef void (*BVHTree_RangeQuery)(void *userdata, int index, const float co[3], float dist_sq); /* callbacks to BLI_bvhtree_walk_dfs */ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 22862b8e0d7..bba3fdb37bc 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -2009,7 +2009,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node) /* Its a leaf.. call the callback */ if (node->children[i]->totnode == 0) { data->hits++; - data->callback(data->userdata, node->children[i]->index, dist_sq); + data->callback(data->userdata, node->children[i]->index, data->center, dist_sq); } else dfs_range_query(data, node->children[i]); @@ -2040,7 +2040,7 @@ int BLI_bvhtree_range_query( /* Its a leaf.. call the callback */ if (root->totnode == 0) { data.hits++; - data.callback(data.userdata, root->index, dist_sq); + data.callback(data.userdata, root->index, co, dist_sq); } else dfs_range_query(&data, root); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 52c9edbef6e..91ae29afea3 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -435,12 +435,14 @@ typedef struct PointDensityRangeData { float velscale; } PointDensityRangeData; -static void accum_density(void *userdata, int index, float squared_dist) +static void accum_density(void *userdata, int index, const float co[3], float squared_dist) { PointDensityRangeData *pdr = (PointDensityRangeData *)userdata; const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f; float density = 0.0f; + UNUSED_VARS(co); + if (pdr->point_data_used & POINT_DATA_VEL) { pdr->vec[0] += pdr->point_data[index * 3 + 0]; // * density; pdr->vec[1] += pdr->point_data[index * 3 + 1]; // * density; |