[Bf-blender-cvs] [4d325693e1] master: `BKE_boundbox_ensure_minimum_dimensions` is no longer necessary

Germano Cavalcante noreply at git.blender.org
Tue Feb 14 14:25:40 CET 2017


Commit: 4d325693e1a63453e506dd10c5689e5cedb29a1b
Author: Germano Cavalcante
Date:   Tue Feb 14 10:25:00 2017 -0300
Branches: master
https://developer.blender.org/rB4d325693e1a63453e506dd10c5689e5cedb29a1b

`BKE_boundbox_ensure_minimum_dimensions` is no longer necessary

The bug T46099 no longer applies since the addition of `dist_squared_to_projected_aabb_simple`
Has also been added comments that relates to an occlusion bug with the ruler. I'll investigate this.

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

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object.c
M	source/blender/editors/transform/transform_snap_object.c

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index d812ab832a..89adbc4338 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -139,8 +139,6 @@ void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], cons
 void BKE_boundbox_calc_center_aabb(const struct BoundBox *bb, float r_cent[3]);
 void BKE_boundbox_calc_size_aabb(const struct BoundBox *bb, float r_size[3]);
 void BKE_boundbox_minmax(const struct BoundBox *bb, float obmat[4][4], float r_min[3], float r_max[3]);
-struct BoundBox *BKE_boundbox_ensure_minimum_dimensions(
-        struct BoundBox *bb, struct BoundBox *bb_temp, const float epsilon);
 
 struct BoundBox *BKE_object_boundbox_get(struct Object *ob);
 void BKE_object_dimensions_get(struct Object *ob, float vec[3]);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ff8be5892e..6e754755cf 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2236,66 +2236,6 @@ void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3],
 	}
 }
 
-/**
- * Returns a BBox which each dimensions are at least epsilon.
- * \note In case a given dimension needs to be enlarged, its final value will be in [epsilon, 3 * epsilon] range.
- *
- * \param bb the input bbox to check.
- * \param bb_temp the temp bbox to modify (\a bb content is never changed).
- * \param epsilon the minimum dimension to ensure.
- * \return either bb (if nothing needed to be changed) or bb_temp.
- */
-BoundBox *BKE_boundbox_ensure_minimum_dimensions(BoundBox *bb, BoundBox *bb_temp, const float epsilon)
-{
-	if (fabsf(bb->vec[0][0] - bb->vec[4][0]) < epsilon) {
-		/* Flat along X axis... */
-		*bb_temp = *bb;
-		bb = bb_temp;
-		bb->vec[0][0] -= epsilon;
-		bb->vec[1][0] -= epsilon;
-		bb->vec[2][0] -= epsilon;
-		bb->vec[3][0] -= epsilon;
-		bb->vec[4][0] += epsilon;
-		bb->vec[5][0] += epsilon;
-		bb->vec[6][0] += epsilon;
-		bb->vec[7][0] += epsilon;
-	}
-
-	if (fabsf(bb->vec[0][1] - bb->vec[3][1]) < epsilon) {
-		/* Flat along Y axis... */
-		if (bb != bb_temp) {
-			*bb_temp = *bb;
-			bb = bb_temp;
-		}
-		bb->vec[0][1] -= epsilon;
-		bb->vec[1][1] -= epsilon;
-		bb->vec[4][1] -= epsilon;
-		bb->vec[5][1] -= epsilon;
-		bb->vec[2][1] += epsilon;
-		bb->vec[3][1] += epsilon;
-		bb->vec[6][1] += epsilon;
-		bb->vec[7][1] += epsilon;
-	}
-
-	if (fabsf(bb->vec[0][2] - bb->vec[1][2]) < epsilon) {
-		/* Flat along Z axis... */
-		if (bb != bb_temp) {
-			*bb_temp = *bb;
-			bb = bb_temp;
-		}
-		bb->vec[0][2] -= epsilon;
-		bb->vec[3][2] -= epsilon;
-		bb->vec[4][2] -= epsilon;
-		bb->vec[7][2] -= epsilon;
-		bb->vec[1][2] += epsilon;
-		bb->vec[2][2] += epsilon;
-		bb->vec[5][2] += epsilon;
-		bb->vec[6][2] += epsilon;
-	}
-
-	return bb;
-}
-
 BoundBox *BKE_object_boundbox_get(Object *ob)
 {
 	BoundBox *bb = NULL;
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index e21386b29f..53f6b37c22 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1114,13 +1114,7 @@ static bool snapDerivedMesh(
 	/* Test BoundBox */
 	BoundBox *bb = BKE_object_boundbox_get(ob);
 	if (bb) {
-		BoundBox bb_temp;
-
-		/* We cannot afford a bounding box with some null dimension, which may happen in some cases...
-		 * Threshold is rather high, but seems to be needed to get good behavior, see T46099. */
-		bb = BKE_boundbox_ensure_minimum_dimensions(bb, &bb_temp, 1e-1f);
-
-		/* In vertex and edges you need to get the pixel distance from ray to BoundBox, see T46816. */
+		/* In vertex and edges you need to get the pixel distance from ray to BoundBox, see: T46099, T46816 */
 		if (ELEM(snapdata->snap_to, SCE_SNAP_MODE_VERTEX, SCE_SNAP_MODE_EDGE)) {
 			float dist_px_sq = dist_squared_to_projected_aabb_simple(
 				    lpmat, snapdata->win_half, ray_min_dist, snapdata->mval,
@@ -1292,10 +1286,17 @@ static bool snapDerivedMesh(
 	}
 	/* SCE_SNAP_MODE_VERTEX or SCE_SNAP_MODE_EDGE */
 	else {
+
+		/* Warning: the depth_max is currently being used only in perspective view.
+		 * It is not correct to limit the maximum depth for elements obtained with nearest
+		 * since this limitation depends on the normal and the size of the occlusion face.
+		 * And more... ray_depth is being confused with Z-depth here... (varies only the precision) */
+		const float ray_depth_max_global = *ray_depth + snapdata->depth_range[0];
+
 		Nearest2dUserData neasrest2d = {
 		    .dist_px_sq = SQUARE(*dist_px),
 		    .r_axis_closest = {1.0f, 1.0f, 1.0f},
-		    .depth_range = {snapdata->depth_range[0], *ray_depth + snapdata->depth_range[0]},
+		    .depth_range = {snapdata->depth_range[0], ray_depth_max_global},
 		    .userdata = treedata,
 		    .get_edge_verts = (Nearest2DGetEdgeVertsCallback)get_dm_edge_verts,
 		    .copy_vert_no = (Nearest2DCopyVertNoCallback)copy_dm_vert_no,




More information about the Bf-blender-cvs mailing list