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-03 20:33:52 +0300
committerGermano <germano.costa@ig.com.br>2018-05-03 20:33:52 +0300
commita9d264f5ca1d631e1151bff55fd8cb3c87193bce (patch)
tree9c70cb490d8056f7f54a117eac4bdcba7a2c3237 /source/blender/blenkernel
parent20185a8681f15f3e4e129e064fbe9a150dc4c963 (diff)
parentac19483e632bd3e2388a6a0de2db753efe33a860 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h4
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c23
-rw-r--r--source/blender/blenkernel/intern/constraint.c6
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c18
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c12
5 files changed, 39 insertions, 24 deletions
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 33e88a6b8f8..ab3f9bc1a87 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -161,7 +161,9 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
const BLI_bitmap *mask, int looptri_num_active,
float epsilon, int tree_type, int axis);
-BVHTree *bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, int type);
+BVHTree *bvhtree_from_mesh_get(
+ struct BVHTreeFromMesh *data, struct DerivedMesh *mesh,
+ const int type, const int tree_type);
/**
* Frees data allocated by a call to bvhtree_from_mesh_*.
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 90a75b8d3cc..7f50fcfcb2b 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -1229,19 +1229,30 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
* Builds or queries a bvhcache for the cache bvhtree of the request type.
*/
BVHTree *bvhtree_from_mesh_get(
- struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, int type)
+ struct BVHTreeFromMesh *data, struct DerivedMesh *mesh,
+ const int type, const int tree_type)
{
+ BVHTree *tree = NULL;
switch (type) {
case BVHTREE_FROM_VERTS:
- return bvhtree_from_mesh_verts(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_verts(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_EDGES:
- return bvhtree_from_mesh_edges(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_edges(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_FACES:
- return bvhtree_from_mesh_faces(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_faces(data, mesh, 0.0f, tree_type, 6);
+ break;
case BVHTREE_FROM_LOOPTRI:
- return bvhtree_from_mesh_looptri(data, mesh, 0.0f, 2, 6);
+ tree = bvhtree_from_mesh_looptri(data, mesh, 0.0f, tree_type, 6);
+ break;
}
- return NULL;
+#ifdef DEBUG
+ if (BLI_bvhtree_get_tree_type(tree) != tree_type) {
+ printf("tree_type %d obtained instead of %d\n", BLI_bvhtree_get_tree_type(tree), tree_type);
+ }
+#endif
+ return tree;
}
/** \} */
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 12a16e9a8b1..b192cb7cef2 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3431,9 +3431,9 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstrai
nearest.dist_sq = FLT_MAX;
if (scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
- bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_VERTS, 2);
else
- bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
fail = true;
@@ -4095,7 +4095,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
sub_v3_v3v3(ray_nor, ray_end, ray_start);
normalize_v3(ray_nor);
- bvhtree_from_mesh_looptri(&treeData, target, 0.0f, 4, 6);
+ bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 4);
hit.dist = BVH_RAYCAST_DIST_MAX;
hit.index = -1;
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index f99dd5574b2..c503799d28f 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -131,7 +131,7 @@ float BKE_mesh_remap_calc_difference_from_dm(
float result = 0.0f;
int i;
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -460,7 +460,7 @@ void BKE_mesh_remap_calc_verts_from_dm(
float tmp_co[3], tmp_no[3];
if (mode == MREMAP_MODE_VERT_NEAREST) {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -485,7 +485,7 @@ void BKE_mesh_remap_calc_verts_from_dm(
float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__);
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2);
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
@@ -548,7 +548,7 @@ void BKE_mesh_remap_calc_verts_from_dm(
&treedata, dm_src, ray_radius, 2, 6);
}
else {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
}
if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
@@ -682,7 +682,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2);
nearest.index = -1;
for (i = 0; i < numedges_dst; i++) {
@@ -782,7 +782,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
MEM_freeN(vert_to_edge_src_map_mem);
}
else if (mode == MREMAP_MODE_EDGE_NEAREST) {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2);
nearest.index = -1;
for (i = 0; i < numedges_dst; i++) {
@@ -809,7 +809,7 @@ void BKE_mesh_remap_calc_edges_from_dm(
float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__);
dm_src->getVertCos(dm_src, vcos_src);
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
for (i = 0; i < numedges_dst; i++) {
interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].v1].co, verts_dst[edges_dst[i].v2].co, 0.5f);
@@ -1366,7 +1366,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
}
else {
BLI_assert(num_trees == 1);
- bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_VERTS);
+ bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_VERTS, 2);
}
}
else { /* We use polygons. */
@@ -2018,7 +2018,7 @@ void BKE_mesh_remap_calc_polys_from_dm(
&treedata, dm_src, MREMAP_RAYCAST_APPROXIMATE_BVHEPSILON(ray_radius), 2, 6);
}
else {
- bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2);
}
if (mode == MREMAP_MODE_POLY_NEAREST) {
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 0d381248ef2..ef4ddc36d08 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -158,7 +158,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
return;
}
- TIMEIT_BENCH(bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_VERTS), bvhtree_verts);
+ TIMEIT_BENCH(bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_VERTS, 2), bvhtree_verts);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
@@ -437,8 +437,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
}
}
else {
- if ((targ_tree = bvhtree_from_mesh_looptri(
- &treedata_stack.dmtreedata, calc->target, 0.0, 4, 6)))
+ if (targ_tree = bvhtree_from_mesh_get(
+ &treedata_stack.dmtreedata, calc->target, BVHTREE_FROM_LOOPTRI, 4))
{
targ_callback = treedata_stack.dmtreedata.raycast_callback;
treeData = &treedata_stack.dmtreedata;
@@ -459,7 +459,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
}
}
else {
- if ((aux_tree = bvhtree_from_mesh_looptri(&auxdata_stack.dmtreedata, auxMesh, 0.0, 4, 6)) != NULL) {
+ if ((aux_tree = bvhtree_from_mesh_get(
+ &auxdata_stack.dmtreedata, auxMesh, BVHTREE_FROM_LOOPTRI, 4)) != NULL)
+ {
aux_callback = auxdata_stack.dmtreedata.raycast_callback;
auxData = &auxdata_stack.dmtreedata;
}
@@ -588,7 +590,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Create a bvh-tree of the given target */
- bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_LOOPTRI);
+ bvhtree_from_mesh_get(&treeData, calc->target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;