[Bf-blender-cvs] [31123f09cd] master: Remove unused functions related to distance between BoundBox and ray

Germano Cavalcante noreply at git.blender.org
Fri Feb 17 13:49:42 CET 2017


Commit: 31123f09cd431191e99135c17e80b96441f985f5
Author: Germano Cavalcante
Date:   Fri Feb 17 09:49:20 2017 -0300
Branches: master
https://developer.blender.org/rB31123f09cd431191e99135c17e80b96441f985f5

Remove unused functions related to distance between BoundBox and ray

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

M	source/blender/blenkernel/BKE_bvhutils.h
M	source/blender/blenkernel/intern/bvhutils.c
M	source/blender/blenlib/BLI_kdopbvh.h
M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/BLI_kdopbvh.c
M	source/blender/blenlib/intern/math_geom.c

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

diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index ad729ad37d..cb72f0859d 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -54,7 +54,6 @@ typedef struct BVHTreeFromEditMesh {
 	/* default callbacks to bvh nearest and raycast */
 	BVHTree_NearestPointCallback nearest_callback;
 	BVHTree_RayCastCallback raycast_callback;
-	BVHTree_NearestToRayCallback nearest_to_ray_callback;
 
 	struct BMEditMesh *em;
 
@@ -75,7 +74,6 @@ typedef struct BVHTreeFromMesh {
 	/* default callbacks to bvh nearest and raycast */
 	BVHTree_NearestPointCallback nearest_callback;
 	BVHTree_RayCastCallback raycast_callback;
-	BVHTree_NearestToRayCallback nearest_to_ray_callback;
 
 	/* Vertex array, so that callbacks have instante access to data */
 	const struct MVert *vert;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 5a0006e679..c0e4ef37a9 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -376,45 +376,6 @@ static void mesh_edges_spherecast(void *userdata, int index, const BVHTreeRay *r
 	}
 }
 
-#define V3_MUL_ELEM(a, b) \
-	(a)[0] * (b)[0], \
-	(a)[1] * (b)[1], \
-	(a)[2] * (b)[2]
-
-/* Callback to bvh tree nearest edge to ray.
- * The tree must have been built using bvhtree_from_mesh_edges.
- * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */
-static void mesh_edges_nearest_to_ray(
-        void *userdata, const float ray_co[3], const float ray_dir[3],
-        const float scale[3], int index, BVHTreeNearest *nearest)
-{
-	struct BVHTreeFromMesh *data = userdata;
-	const MVert *vert = data->vert;
-	const MEdge *e = &data->edge[index];
-
-	const float t0[3]        = {V3_MUL_ELEM(vert[e->v1].co, scale)};
-	const float t1[3]        = {V3_MUL_ELEM(vert[e->v2].co, scale)};
-	const float origin_sc[3] = {V3_MUL_ELEM(ray_co, scale)};
-	const float dir_sc[3]    = {V3_MUL_ELEM(ray_dir, scale)};
-
-	float depth, point[3];
-	const float dist_sq = dist_squared_ray_to_seg_v3(origin_sc, dir_sc, t0, t1, point, &depth);
-
-	if (dist_sq < nearest->dist_sq) {
-		nearest->dist_sq = dist_sq;
-		nearest->index = index;
-
-		point[0] /= scale[0];
-		point[1] /= scale[1];
-		point[2] /= scale[2];
-
-		copy_v3_v3(nearest->co, point);
-		sub_v3_v3v3(nearest->no, t0, t1);
-	}
-}
-
-#undef V3_MUL_ELEM
-
 /** \} */
 
 /*
@@ -499,7 +460,6 @@ static void bvhtree_from_mesh_verts_setup_data(
 	 * remember the min distance to point is the same as the min distance to BV of point */
 	data->nearest_callback = NULL;
 	data->raycast_callback = mesh_verts_spherecast;
-	data->nearest_to_ray_callback = NULL;
 
 	data->vert = vert;
 	data->vert_allocated = vert_allocated;
@@ -524,7 +484,6 @@ BVHTree *bvhtree_from_editmesh_verts_ex(
 		data->em = em;
 		data->nearest_callback = NULL;
 		data->raycast_callback = editmesh_verts_spherecast;
-		data->nearest_to_ray_callback = NULL;
 	}
 
 	return tree;
@@ -707,7 +666,6 @@ static void bvhtree_from_mesh_edges_setup_data(
 
 	data->nearest_callback = mesh_edges_nearest_point;
 	data->raycast_callback = mesh_edges_spherecast;
-	data->nearest_to_ray_callback = mesh_edges_nearest_to_ray;
 
 	data->vert = vert;
 	data->vert_allocated = vert_allocated;
@@ -735,8 +693,6 @@ BVHTree *bvhtree_from_editmesh_edges_ex(
 		data->em = em;
 		data->nearest_callback = NULL;  /* TODO */
 		data->raycast_callback = NULL;  /* TODO */
-		/* TODO: not urgent however since users currently define own callbacks */
-		data->nearest_to_ray_callback = NULL;
 	}
 
 	return tree;
@@ -893,7 +849,6 @@ static void bvhtree_from_mesh_faces_setup_data(
 
 	data->nearest_callback = mesh_faces_nearest_point;
 	data->raycast_callback = mesh_faces_spherecast;
-	data->nearest_to_ray_callback = NULL;
 
 	data->vert = vert;
 	data->vert_allocated = vert_allocated;
@@ -1098,7 +1053,6 @@ static void bvhtree_from_mesh_looptri_setup_data(
 
 	data->nearest_callback = mesh_looptri_nearest_point;
 	data->raycast_callback = mesh_looptri_spherecast;
-	data->nearest_to_ray_callback = NULL;
 
 	data->vert = vert;
 	data->vert_allocated = vert_allocated;
@@ -1152,7 +1106,6 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(
 		data->tree = tree;
 		data->nearest_callback = editmesh_looptri_nearest_point;
 		data->raycast_callback = editmesh_looptri_spherecast;
-		data->nearest_to_ray_callback = NULL;
 		data->sphere_radius = 0.0f;
 		data->em = em;
 		data->cached = bvhCache != NULL;
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 91d3980164..ba565fca52 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -95,10 +95,6 @@ typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const fl
 /* callback must update hit in case it finds a nearest successful hit */
 typedef void (*BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit);
 
-/* callback must update nearest in case it finds a nearest result */
-typedef void (*BVHTree_NearestToRayCallback)(void *userdata, const float ray_co[3], const float ray_dir[3],
-                                             const float scale[3], int index, BVHTreeNearest *nearest);
-
 /* callback to check if 2 nodes overlap (use thread if intersection results need to be stored) */
 typedef bool (*BVHTree_OverlapCallback)(void *userdata, int index_a, int index_b, int thread);
 
@@ -143,18 +139,6 @@ int BLI_bvhtree_find_nearest(
         BVHTree *tree, const float co[3], BVHTreeNearest *nearest,
         BVHTree_NearestPointCallback callback, void *userdata);
 
-int BLI_bvhtree_find_nearest_to_ray_angle(
-        BVHTree *tree, const float co[3], const float dir[3],
-        const bool ray_is_normalized, const float scale[3],
-        BVHTreeNearest *nearest,
-        BVHTree_NearestToRayCallback callback, void *userdata);
-
-int BLI_bvhtree_find_nearest_to_ray(
-        BVHTree *tree, const float co[3], const float dir[3],
-        const bool ray_is_normalized, const float scale[3],
-        BVHTreeNearest *nearest,
-        BVHTree_NearestToRayCallback callback, void *userdata);
-
 int BLI_bvhtree_ray_cast_ex(
         BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
         BVHTree_RayCastCallback callback, void *userdata,
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 4a85e859c1..f1d9c9571f 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -298,23 +298,6 @@ bool isect_ray_aabb_v3_simple(
         const float bb_min[3], const float bb_max[3],
         float *tmin, float *tmax);
 
-struct NearestRayToAABB_Precalc {
-	float ray_origin[3];
-	float ray_direction[3];
-	float ray_inv_dir[3];
-	float cdot_axis[3];
-	float idiag_sq[3];
-	bool sign[3];
-};
-
-void dist_squared_ray_to_aabb_v3_precalc(
-        struct NearestRayToAABB_Precalc *data,
-        const float ray_origin[3], const float ray_direction[3]);
-float dist_squared_ray_to_aabb_v3(
-        const struct NearestRayToAABB_Precalc *data,
-        const float bb_min[3], const float bb_max[3],
-        bool r_axis_closest[3]);
-
 /* other */
 bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius,
                                   const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3]);
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index b14007a88c..19d9711922 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -159,29 +159,6 @@ typedef struct BVHRayCastData {
 	BVHTreeRayHit hit;
 } BVHRayCastData;
 
-typedef struct BVHNearestRayData {
-	BVHTree *tree;
-	BVHTree_NearestToRayCallback callback;
-	void    *userdata;
-
-	struct {
-		bool sign[3];
-		float origin[3];
-		float direction[3];
-
-		float direction_scaled_square[3];
-		float inv_dir[3];
-
-		float cdot_axis[3];
-	} ray;
-
-	bool pick_smallest[3];
-
-	BVHTreeNearest nearest;
-
-	float scale[3];
-} BVHNearestRayData;
-
 /** \} */
 
 
@@ -1900,453 +1877,6 @@ void BLI_bvhtree_ray_cast_all(
 
 /* -------------------------------------------------------------------- */
 
-/** \name BLI_bvhtree_find_nearest_to_ray functions
- *
- * \{ */
-
-static void dist_squared_ray_to_aabb_scaled_v3_precalc(
-        BVHNearestRayData *data,
-        const float ray_origin[3], const float ray_direction[3],
-        const bool ray_is_normalized, const float scale[3])
-{
-	if (scale) {
-		copy_v3_v3(data->scale, scale);
-	}
-	else {
-		copy_v3_fl(data->scale, 1.0f);
-	}
-	/* un-normalize ray */
-	if (ray_is_normalized && scale &&
-	    (data->scale[0] != 1.0f || data->scale[1] != 1.0f || data->scale[2] != 1.0f))
-	{
-		data->ray.direction[0] = ray_direction[0] * data->scale[0];
-		data->ray.direction[1] = ray_direction[1] * data->scale[1];
-		data->ray.direction[2] = ray_direction[2] * data->scale[2];
-
-		mul_v3_v3fl(data->ray.direction, ray_direction, 1 / len_v3(data->ray.direction));
-	}
-	else {
-		copy_v3_v3(data->ray.direction, ray_direction);
-	}
-
-	float dir_sq[3];
-
-	for (int i = 0; i < 3; i++) {
-		data->ray.origin[i] = ray_origin[i];
-		data->ray.inv_dir[i] = (data->ray.direction[i] != 0.0f) ?
-		                       (1.0f / data->ray.direction[i]) : FLT_MAX;
-		/* It has to be in function of `ray.inv_dir`,
-		 * since the division of 1 by 0.0f, can be -inf or +inf */
-		data->ray.sign[i] = (data->ray.inv_dir[i] < 0.0f);
-
-		data->ray.direction_scaled_square[i] = data->ray.direction[i] * data->scale[i];
-
-		dir_sq[i] = SQUARE(data->ray.direction_scaled_square[i]);
-
-		data->ray.direction_scaled_square[i] *= data->scale[i];
-	}
-
-	/* `diag_sq` Length square of each face diagonal */
-	float diag_sq[3] = {
-		dir_sq[1] + dir_sq[2],
-		dir_sq[0] + dir_sq[2],
-		dir_sq[0] + dir_sq[1],
-	};
-
-	data->ray.cdot_axis[0] = (diag_sq[0] != 0.0f) ? data->ray.direction[0] / diag_sq[0] : FLT_MAX;
-	data->ray.cdot_axis[1] = (diag_sq[1] != 0.0f) ? data->ray.direction[1] / diag_sq[

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list