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:
authorCampbell Barton <ideasman42@gmail.com>2014-03-24 06:21:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-24 06:21:58 +0400
commit3214d4fd5aa803237637da2eee5d1b9e0006ae26 (patch)
treeb4b1faed52c55eea7da18b10eb216bfff90e3bf7 /source/blender/blenkernel/intern/pbvh_bmesh.c
parent551d1a1ed56d7406f440c8e858ad64f177664c5b (diff)
Code Cleanup: PBVH, avoid sqrt and use bool for raycast functions
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh_bmesh.c')
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 4fedf76f376..0ea554cf89d 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1035,11 +1035,13 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3],
return hit;
}
-int BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3],
- const float ray_normal[3], float *detail, float *dist)
+bool BKE_pbvh_bmesh_node_raycast_detail(
+ PBVHNode *node,
+ const float ray_start[3], const float ray_normal[3],
+ float *detail, float *dist)
{
GHashIterator gh_iter;
- int hit = 0;
+ bool hit = false;
BMFace *f_hit = NULL;
if (node->flag & PBVH_FullyHidden)
@@ -1051,17 +1053,19 @@ int BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3],
BLI_assert(f->len == 3);
if (f->len == 3 && !paint_is_bmesh_face_hidden(f)) {
BMVert *v_tri[3];
- int hit_local;
+ bool hit_local;
BM_face_as_array_vert_tri(f, v_tri);
- hit_local = ray_face_intersection(ray_start, ray_normal,
- v_tri[0]->co,
- v_tri[1]->co,
- v_tri[2]->co,
- NULL, dist);
+ hit_local = ray_face_intersection(
+ ray_start, ray_normal,
+ v_tri[0]->co,
+ v_tri[1]->co,
+ v_tri[2]->co,
+ NULL, dist);
+
if (hit_local) {
f_hit = f;
+ hit = true;
}
- hit |= hit_local;
}
}
@@ -1069,12 +1073,12 @@ int BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3],
float len1, len2, len3;
BMVert *v_tri[3];
BM_face_as_array_vert_tri(f_hit, v_tri);
- len1 = len_v3v3(v_tri[0]->co, v_tri[1]->co);
- len2 = len_v3v3(v_tri[1]->co, v_tri[2]->co);
- len3 = len_v3v3(v_tri[2]->co, v_tri[0]->co);
+ len1 = len_squared_v3v3(v_tri[0]->co, v_tri[1]->co);
+ len2 = len_squared_v3v3(v_tri[1]->co, v_tri[2]->co);
+ len3 = len_squared_v3v3(v_tri[2]->co, v_tri[0]->co);
/* detail returned will be set to the maximum allowed size, so take max here */
- *detail = max_fff(len1, len2, len3);
+ *detail = sqrtf(max_fff(len1, len2, len3));
}
return hit;