Commit: b27b4743a233bc9ba0d63aa33162324347bf371f
Author: Germano
Date:   Fri May 4 11:57:01 2018 -0300
Branches: master
https://developer.blender.org/rBb27b4743a233bc9ba0d63aa33162324347bf371f

BKE: bvhuils: remove member `sphere_radius`.

This member currently doubles the value of `ray->radius` or is not even used.

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

M       source/blender/blenkernel/BKE_bvhutils.h
M       source/blender/blenkernel/intern/bvhutils.c
M       source/blender/blenkernel/intern/constraint.c
M       source/blender/blenkernel/intern/mesh_remap.c

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

diff --git a/source/blender/blenkernel/BKE_bvhutils.h 
b/source/blender/blenkernel/BKE_bvhutils.h
index 57a6c413ce0..1b4bb08756b 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -57,9 +57,6 @@ typedef struct BVHTreeFromEditMesh {
 
        struct BMEditMesh *em;
 
-       /* radius for raycast */
-       float sphere_radius;
-
        /* Private data */
        bool cached;
 
@@ -87,9 +84,6 @@ typedef struct BVHTreeFromMesh {
        bool loop_allocated;
        bool looptri_allocated;
 
-       /* radius for raycast */
-       float sphere_radius;
-
        /* Private data */
        bool cached;
 
diff --git a/source/blender/blenkernel/intern/bvhutils.c 
b/source/blender/blenkernel/intern/bvhutils.c
index 938f185a111..0240bb4b624 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -194,10 +194,10 @@ static void mesh_faces_spherecast(void *userdata, int 
index, const BVHTreeRay *r
        
        do {
                float dist;
-               if (data->sphere_radius == 0.0f)
+               if (ray->radius == 0.0f)
                        dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, 
t1, t2);
                else
-                       dist = bvhtree_sphereray_tri_intersection(ray, 
data->sphere_radius, hit->dist, t0, t1, t2);
+                       dist = bvhtree_sphereray_tri_intersection(ray, 
ray->radius, hit->dist, t0, t1, t2);
 
                if (dist >= 0 && dist < hit->dist) {
                        hit->index = index;
@@ -226,10 +226,10 @@ static void mesh_looptri_spherecast(void *userdata, int 
index, const BVHTreeRay
        };
        float dist;
 
-       if (data->sphere_radius == 0.0f)
+       if (ray->radius == 0.0f)
                dist = bvhtree_ray_tri_intersection(ray, hit->dist, 
UNPACK3(vtri_co));
        else
-               dist = bvhtree_sphereray_tri_intersection(ray, 
data->sphere_radius, hit->dist, UNPACK3(vtri_co));
+               dist = bvhtree_sphereray_tri_intersection(ray, ray->radius, 
hit->dist, UNPACK3(vtri_co));
 
        if (dist >= 0 && dist < hit->dist) {
                hit->index = index;
@@ -254,10 +254,10 @@ static void editmesh_looptri_spherecast(void *userdata, 
int index, const BVHTree
 
        {
                float dist;
-               if (data->sphere_radius == 0.0f)
+               if (ray->radius == 0.0f)
                        dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, 
t1, t2);
                else
-                       dist = bvhtree_sphereray_tri_intersection(ray, 
data->sphere_radius, hit->dist, t0, t1, t2);
+                       dist = bvhtree_sphereray_tri_intersection(ray, 
ray->radius, hit->dist, t0, t1, t2);
 
                if (dist >= 0 && dist < hit->dist) {
                        hit->index = index;
@@ -340,7 +340,7 @@ static void mesh_edges_spherecast(void *userdata, int 
index, const BVHTreeRay *r
        const MVert *vert = data->vert;
        const MEdge *edge = &data->edge[index];
 
-       const float radius_sq = SQUARE(data->sphere_radius);
+       const float radius_sq = SQUARE(ray->radius);
        float dist;
        const float *v1, *v2, *r1;
        float r2[3], i1[3], i2[3];
@@ -448,7 +448,7 @@ static BVHTree *bvhtree_from_mesh_verts_create_tree(
 }
 
 static void bvhtree_from_mesh_verts_setup_data(
-        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached, float 
epsilon,
+        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached,
         const MVert *vert, const bool vert_allocated)
 {
        memset(data, 0, sizeof(*data));
@@ -464,8 +464,6 @@ static void bvhtree_from_mesh_verts_setup_data(
        data->vert = vert;
        data->vert_allocated = vert_allocated;
        //data->face = DM_get_tessface_array(dm, &data->face_allocated);  /* 
XXX WHY???? */
-
-       data->sphere_radius = epsilon;
 }
 
 /* Builds a bvh tree where nodes are the vertices of the given em */
@@ -515,7 +513,7 @@ BVHTree *bvhtree_from_mesh_verts_ex(
 
        /* Setup BVHTreeFromMesh */
        bvhtree_from_mesh_verts_setup_data(
-               data, tree, false, epsilon, vert, vert_allocated);
+               data, tree, false, vert, vert_allocated);
 
        return tree;
 }
@@ -599,7 +597,7 @@ static BVHTree *bvhtree_from_mesh_edges_create_tree(
 
 static void bvhtree_from_mesh_edges_setup_data(
         BVHTreeFromMesh *data, BVHTree *tree,
-        const bool is_cached, float epsilon,
+        const bool is_cached,
         const MVert *vert, const bool vert_allocated,
         const MEdge *edge, const bool edge_allocated)
 {
@@ -616,8 +614,6 @@ static void bvhtree_from_mesh_edges_setup_data(
        data->vert_allocated = vert_allocated;
        data->edge = edge;
        data->edge_allocated = edge_allocated;
-
-       data->sphere_radius = epsilon;
 }
 
 /* Builds a bvh tree where nodes are the edges of the given em */
@@ -672,7 +668,7 @@ BVHTree *bvhtree_from_mesh_edges_ex(
 
        /* Setup BVHTreeFromMesh */
        bvhtree_from_mesh_edges_setup_data(
-               data, tree, false, epsilon, vert, vert_allocated, edge, 
edge_allocated);
+               data, tree, false, vert, vert_allocated, edge, edge_allocated);
 
        return tree;
 }
@@ -730,7 +726,7 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(
 }
 
 static void bvhtree_from_mesh_faces_setup_data(
-        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached, float 
epsilon,
+        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached,
         const MVert *vert, const bool vert_allocated,
         const MFace *face, const bool face_allocated)
 {
@@ -746,8 +742,6 @@ static void bvhtree_from_mesh_faces_setup_data(
        data->vert_allocated = vert_allocated;
        data->face = face;
        data->face_allocated = face_allocated;
-
-       data->sphere_radius = epsilon;
 }
 
 /**
@@ -770,7 +764,7 @@ BVHTree *bvhtree_from_mesh_faces_ex(
 
        /* Setup BVHTreeFromMesh */
        bvhtree_from_mesh_faces_setup_data(
-               data, tree, false, epsilon, vert, vert_allocated, face, 
face_allocated);
+               data, tree, false, vert, vert_allocated, face, face_allocated);
 
        return tree;
 }
@@ -876,7 +870,7 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(
 }
 
 static void bvhtree_from_mesh_looptri_setup_data(
-        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached, float 
epsilon,
+        BVHTreeFromMesh *data, BVHTree *tree, const bool is_cached,
         const MVert *vert, const bool vert_allocated,
         const MLoop *mloop, const bool loop_allocated,
         const MLoopTri *looptri, const bool looptri_allocated)
@@ -895,8 +889,6 @@ static void bvhtree_from_mesh_looptri_setup_data(
        data->loop_allocated = loop_allocated;
        data->looptri = looptri;
        data->looptri_allocated = looptri_allocated;
-
-       data->sphere_radius = epsilon;
 }
 
 /**
@@ -941,7 +933,6 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(
                data->tree = tree;
                data->nearest_callback = editmesh_looptri_nearest_point;
                data->raycast_callback = editmesh_looptri_spherecast;
-               data->sphere_radius = 0.0f;
                data->em = em;
                data->cached = bvhCache != NULL;
        }
@@ -977,7 +968,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
 
        /* Setup BVHTreeFromMesh */
        bvhtree_from_mesh_looptri_setup_data(
-               data, tree, false, epsilon,
+               data, tree, false,
                vert, vert_allocated,
                mloop, loop_allocated,
                looptri, looptri_allocated);
@@ -1145,8 +1136,6 @@ BVHTree *bvhtree_from_mesh_get(
                data->loop_allocated = loop_allocated;
                data->looptri_allocated = looptri_allocated;
 
-               data->sphere_radius = 0.0;
-
                data->cached = true;
        }
        else {
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 88b2ca20563..13358311f92 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3568,8 +3568,7 @@ static void shrinkwrap_get_tarmat(bConstraint *con, 
bConstraintOb *cob, bConstra
                                                break;
                                        }
 
-                                       treeData.sphere_radius = scon->dist;
-                                       if (BKE_shrinkwrap_project_normal(0, 
co, no, treeData.sphere_radius, &transform, treeData.tree,
+                                       if (BKE_shrinkwrap_project_normal(0, 
co, no, scon->dist, &transform, treeData.tree,
                                                                          &hit, 
treeData.raycast_callback, &treeData) == false)
                                        {
                                                fail = true;
diff --git a/source/blender/blenkernel/intern/mesh_remap.c 
b/source/blender/blenkernel/intern/mesh_remap.c
index 1b05745550d..eef8657482f 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -544,7 +544,6 @@ void BKE_mesh_remap_calc_verts_from_dm(
                        bvhtree_from_mesh_get(&treedata, dm_src, 
BVHTREE_FROM_LOOPTRI, 2);
 
                        if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
-                               treedata.sphere_radius = ray_radius;
                                for (i = 0; i < numverts_dst; i++) {
                                        copy_v3_v3(tmp_co, verts_dst[i].co);
                                        normal_short_to_float_v3(tmp_no, 
verts_dst[i].no);
@@ -909,10 +908,8 @@ void BKE_mesh_remap_calc_edges_from_dm(
                                        interp_v3_v3v3_slerp_safe(tmp_no, 
v1_no, v2_no, fac);
 
                                        while (n--) {
-                                               float radius = (ray_radius / w);
-                                               treedata.sphere_radius = radius;
                                                if 
(mesh_remap_bvhtree_query_raycast(
-                                                       &treedata, &rayhit, 
tmp_co, tmp_no, radius, max_dist, &hit_dist))
+                                                       &treedata, &rayhit, 
tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
                                                {
                                                        weights[rayhit.index] 
+= w;
                                                        totweights += w;
@@ -1565,10 +1562,8 @@ void BKE_mesh_remap_calc_loops_from_dm(
                                                }
 
                                                while (n--) {
-                                                       float radius = 
ray_radius / w;
-                                                       tdata->sphere_radius = 
radius;
                                                        if 
(mesh_remap_bvhtree_query_raycast(
-                                                               tdata, &rayhit, 
tmp_co, tmp_no, radius, max_dist, &hit_dist))
+                                                               tdata, &rayhit, 
tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
                                                        {
                                                                
islands_res[tindex][plidx_dst].factor = (hit_dist ? (1.0f / hit_dist) : 1e18f) 
* w;
                                                                
islands_res[tindex][plidx_dst].hit_dist = hit_dist;
@@ -2051,7 +2046,6 @@ void BKE_mesh_remap_calc_polys_from_dm(
                                        
BLI_space_transform_apply_normal(space_transform, tmp_no);
                                }
 
-                               treedata.sphere_radius = ray_radius;
                                if (mesh_remap_bvhtree_query_raycast(
                                        &treedata, &rayhit, tmp_co, tmp_no, 
ray_radius, max_dist, &hit_dist))
                                {
@@ -2201,9 +2195,8 @@ void BKE_mesh_remap_calc_polys_from_dm(
 
                                                /* At this point, tmp_co is a 
point on our poly surface, in mesh_src space! */
                                                while (n--) {
-                                                       treedata.sphere_radius 
= ray_radius / w;
                                                        if 
(mesh_remap_bvhtree_query_raycast(
-                                                               &treedata, 
&rayhit, tmp_co, tmp_no, treedata.sphere_radius, max_dist, &hit_dist))
+                                                               &treedata, 
&rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist))
                                                

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to