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.
This commit is contained in:
Germano Cavalcante 2017-02-14 10:25:00 -03:00
parent 6c104f62b9
commit 4d325693e1
3 changed files with 9 additions and 70 deletions

@ -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]);

@ -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;

@ -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,