Commit: 3dd6912fce9285c52cdff26739068703ca378a86
Author: Germano
Date:   Fri May 4 09:01:56 2018 -0300
Branches: master
https://developer.blender.org/rB3dd6912fce9285c52cdff26739068703ca378a86

Mesh Remap: Face Corner Data: Do not use large epsilon values to create 
bvhtrees.

Use ray radius instead.

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

M       source/blender/blenkernel/intern/mesh_remap.c

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

diff --git a/source/blender/blenkernel/intern/mesh_remap.c 
b/source/blender/blenkernel/intern/mesh_remap.c
index 8e93be14f6b..cf4c70c4aaa 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -422,9 +422,6 @@ typedef struct IslandResult {
 #define MREMAP_RAYCAST_APPROXIMATE_NR 3
 /* Each approximated raycasts will have n times bigger radius than previous 
one. */
 #define MREMAP_RAYCAST_APPROXIMATE_FAC 5.0f
-/* BVH epsilon value we have to give to bvh 'constructor' when doing 
approximated raycasting. */
-#define MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(_ray_radius) \
-       ((float)MREMAP_RAYCAST_APPROXIMATE_NR * MREMAP_RAYCAST_APPROXIMATE_FAC 
* (_ray_radius))
 
 /* min 16 rays/face, max 400. */
 #define MREMAP_RAYCAST_TRI_SAMPLES_MIN 4
@@ -547,9 +544,7 @@ 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) {
-                               if (mode & MREMAP_USE_NORPROJ) {
-                                       treedata.sphere_radius = ray_radius;
-                               }
+                               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);
@@ -1205,8 +1200,6 @@ void BKE_mesh_remap_calc_loops_from_dm(
                IslandResult **islands_res;
                size_t islands_res_buff_size = MREMAP_DEFAULT_BUFSIZE;
 
-               const float bvh_epsilon = (mode & MREMAP_USE_NORPROJ) ? 
MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius) : 0.0f;
-
                if (!use_from_vert) {
                        vcos_src = MEM_mallocN(sizeof(*vcos_src) * 
(size_t)num_verts_src, __func__);
                        dm_src->getVertCos(dm_src, vcos_src);
@@ -1356,7 +1349,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
                                        }
                                        /* verts 'ownership' is transfered to 
treedata here, which will handle its freeing. */
                                        
bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, 
verts_allocated_src,
-                                                                  
verts_active, num_verts_active, bvh_epsilon, 2, 6);
+                                                                  
verts_active, num_verts_active, 0.0, 2, 6);
                                        if (verts_allocated_src) {
                                                verts_allocated_src = false;  
/* Only 'give' our verts once, to first tree! */
                                        }
@@ -1403,7 +1396,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
                                                verts_src, verts_allocated_src,
                                                loops_src, loops_allocated_src,
                                                looptri_src, num_looptri_src, 
false,
-                                               looptri_active, 
num_looptri_active, bvh_epsilon, 2, 6);
+                                               looptri_active, 
num_looptri_active, 0.0, 2, 6);
                                        if (verts_allocated_src) {
                                                verts_allocated_src = false;  
/* Only 'give' our verts once, to first tree! */
                                        }
@@ -1416,7 +1409,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
                        }
                        else {
                                BLI_assert(num_trees == 1);
-                               bvhtree_from_mesh_looptri(&treedata[0], dm_src, 
bvh_epsilon, 2, 6);
+                               bvhtree_from_mesh_looptri(&treedata[0], dm_src, 
0.0, 2, 6);
                        }
                }
 
@@ -1572,8 +1565,10 @@ 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, ray_radius / w, max_dist, &hit_dist))
+                                                               tdata, &rayhit, 
tmp_co, tmp_no, radius, 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;
@@ -2258,7 +2253,6 @@ void BKE_mesh_remap_calc_polys_from_dm(
 
 #undef MREMAP_RAYCAST_APPROXIMATE_NR
 #undef MREMAP_RAYCAST_APPROXIMATE_FAC
-#undef MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON
 #undef MREMAP_RAYCAST_TRI_SAMPLES_MIN
 #undef MREMAP_RAYCAST_TRI_SAMPLES_MAX
 #undef MREMAP_DEFAULT_BUFSIZE

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

Reply via email to