[Bf-blender-cvs] [8c6073d] master: BMesh: BM_loop/edge_point_side_of_loop_test
Campbell Barton
noreply at git.blender.org
Mon Mar 2 14:28:22 CET 2015
Commit: 8c6073db118488861af244232fa758bd7af7e61d
Author: Campbell Barton
Date: Mon Mar 2 23:50:52 2015 +1100
Branches: master
https://developer.blender.org/rB8c6073db118488861af244232fa758bd7af7e61d
BMesh: BM_loop/edge_point_side_of_loop_test
change behavior to use a negative number when outside,
and return the signed, squared distance.
===================================================================
M source/blender/bmesh/intern/bmesh_queries.c
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index c3fa1e6..781f6eb 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -273,30 +273,31 @@ static float bm_face_calc_split_dot(BMLoop *l_a, BMLoop *l_b)
* Check if a point is inside the corner defined by a loop
* (within the 2 planes defined by the loops corner & face normal).
*
- * \return less than 0.0 when inside.
+ * \return signed, squared distance to the loops planes, less than 0.0 when outside.
*/
float BM_loop_point_side_of_loop_test(const BMLoop *l, const float co[3])
{
const float *axis = l->f->no;
- return (angle_signed_on_axis_v3v3v3_v3(l->prev->v->co, l->v->co, co, axis) -
- angle_signed_on_axis_v3v3v3_v3(l->prev->v->co, l->v->co, l->next->v->co, axis));
+ return dist_signed_squared_to_corner_v3v3v3(co, l->prev->v->co, l->v->co, l->next->v->co, axis);
}
/**
* Check if a point is inside the edge defined by a loop
* (within the plane defined by the loops edge & face normal).
*
- * \return less than 0.0 when inside.
+ * \return signed, squared distablce to the edge plane, less than 0.0 when outside.
*/
float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3])
{
const float *axis = l->f->no;
float dir[3];
- float plane[3];
- sub_v3_v3v3(dir, l->v->co, l->next->v->co);
+ float plane[4];
+
+ sub_v3_v3v3(dir, l->next->v->co, l->v->co);
cross_v3_v3v3(plane, axis, dir);
- return (dot_v3v3(plane, co) -
- dot_v3v3(plane, l->v->co));
+
+ plane[3] = -dot_v3v3(plane, l->v->co);
+ return dist_signed_squared_to_plane_v3(co, plane);
}
/**
More information about the Bf-blender-cvs
mailing list