forked from bartvdbraak/blender
BLI_kdopbvh: Pass center to to range callback
Useful when BLI_bvhtree_range_query callback calculates a new position to measure from.
This commit is contained in:
parent
6aeb1f7f56
commit
1a7596951a
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user