Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano <germano.costa@ig.com.br>2018-05-04 15:22:48 +0300
committerGermano <germano.costa@ig.com.br>2018-05-04 15:22:48 +0300
commit02baf714093e7bfbcd6a72ea8032b2cff74a1f00 (patch)
treebf511df466a11a64d93d67cd2df6ebe649c7c9a6
parent3f95daa31fa98b1bd67fc71835f0011287c1d136 (diff)
parentaea637456e7db640f9a1a83416769245a9b18a7d (diff)
Merge branch 'master' into blender2.8
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h2
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c32
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c4
4 files changed, 14 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index b9f07e07f12..57a6c413ce0 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -148,8 +148,6 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(
const BLI_bitmap *mask, int looptri_num_active,
float epsilon, int tree_type, int axis, BVHCache **bvhCache);
-BVHTree *bvhtree_from_mesh_looptri(
- struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis);
BVHTree *bvhtree_from_mesh_looptri_ex(
struct BVHTreeFromMesh *data,
const struct MVert *vert, const bool vert_allocated,
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 416ac3cbaa0..440db911298 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -1127,7 +1127,7 @@ BVHTree *bvhtree_from_editmesh_looptri(
*
* \note for editmesh this is currently a duplicate of bvhtree_from_mesh_faces
*/
-BVHTree *bvhtree_from_mesh_looptri(
+static BVHTree *bvhtree_from_mesh_looptri(
BVHTreeFromMesh *data, DerivedMesh *dm,
float epsilon, int tree_type, int axis)
{
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 84994e80784..1b05745550d 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_get(&treedata[0], dm_src, BVHTREE_FROM_LOOPTRI, 2);
}
}
@@ -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;
@@ -2013,13 +2008,7 @@ void BKE_mesh_remap_calc_polys_from_dm(
BVHTreeRayHit rayhit = {0};
float hit_dist;
- if (mode & MREMAP_USE_NORPROJ) {
- bvhtree_from_mesh_looptri(
- &treedata, dm_src, MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius), 2, 6);
- }
- else {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
- }
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
if (mode == MREMAP_MODE_POLY_NEAREST) {
nearest.index = -1;
@@ -2062,6 +2051,7 @@ 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))
{
@@ -2211,8 +2201,9 @@ 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, ray_radius / w, max_dist, &hit_dist))
+ &treedata, &rayhit, tmp_co, tmp_no, treedata.sphere_radius, max_dist, &hit_dist))
{
const MLoopTri *lt = &treedata.looptri[rayhit.index];
@@ -2262,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
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 7b04bf80af6..04507d1ed7e 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -311,7 +311,7 @@ static void rna_Object_ray_cast(
BVHTreeFromMesh treeData = {NULL};
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
- bvhtree_from_mesh_looptri(&treeData, ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4);
/* may fail if the mesh has no faces, in that case the ray-cast misses */
if (treeData.tree != NULL) {
@@ -360,7 +360,7 @@ static void rna_Object_closest_point_on_mesh(
}
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
- bvhtree_from_mesh_looptri(&treeData, ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4);
if (treeData.tree == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point",