Commit: 1a7596951aafcd0f9c0f112a79c9b6e79d6ac323
Author: Campbell Barton
Date:   Sat Mar 19 17:16:50 2016 +1100
Branches: master
https://developer.blender.org/rB1a7596951aafcd0f9c0f112a79c9b6e79d6ac323

BLI_kdopbvh: Pass center to to range callback

Useful when BLI_bvhtree_range_query callback calculates a new position to 
measure from.

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

M       source/blender/blenkernel/BKE_particle.h
M       source/blender/blenkernel/intern/particle_system.c
M       source/blender/blenlib/BLI_kdopbvh.h
M       source/blender/blenlib/intern/BLI_kdopbvh.c
M       source/blender/render/intern/source/pointdensity.c

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

diff --git a/source/blender/blenkernel/BKE_particle.h 
b/source/blender/blenkernel/BKE_particle.h
index b6b40ad..e17fb9f 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 e9ce532..10ca88c 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 f1ef1d9..be79266 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 22862b8..bba3fdb 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 52c9edb..91ae29a 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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to