diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-01-12 11:37:56 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-01-12 12:09:00 +0300 |
commit | c6c223ade6470e7a9b61ea4a4a3ab6ed62abe79d (patch) | |
tree | fb9323466d1c45ff6a99db96fc649fe3e6374249 /source/blender/editors | |
parent | 90250f856817b68f29924be8a60152ec3a2486a8 (diff) |
Fix T47164: [Scene.raycast] - True result when it should be False.
We cannot use FLT_MAX as initi distance for raycast...
Renamed TRANSFORM_DIST_MAX_RAY to BVH_RAYCAST_DIST_MAX, moved it into BLI_kdopbvh,
and use in RNA raycast callbacks (and all other places using that API).
Diffstat (limited to 'source/blender/editors')
5 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 4bda8285029..9500fd59b8b 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1008,7 +1008,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, const isect_mdef.vec_length = normalize_v3_v3(vec_normal, isect_mdef.vec); hit.index = -1; - hit.dist = FLT_MAX; + hit.dist = BVH_RAYCAST_DIST_MAX; if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, vec_normal, 0.0, &hit, harmonic_ray_callback, &data) != -1) { diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 73f7cd2ba7c..db8085a6696 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -109,6 +109,7 @@ struct TransInfo; struct Base; struct Scene; struct Object; +struct wmOperator; /* UNUSED */ // int BIF_snappingSupported(struct Object *obedit); @@ -175,7 +176,6 @@ typedef enum SnapSelect { } SnapSelect; #define SNAP_MIN_DISTANCE 30 -#define TRANSFORM_DIST_MAX_RAY (FLT_MAX / 2.0f) bool peelObjectsTransForm( struct TransInfo *t, const float mval[2], SnapSelect snap_select, diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6b98d2b9784..0f407658228 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -41,6 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_kdopbvh.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -5183,7 +5184,7 @@ bool ED_view3d_snap_from_ray( float r_co[3]) { float r_no_dummy[3]; - float ray_dist = TRANSFORM_DIST_MAX_RAY; + float ray_dist = BVH_RAYCAST_DIST_MAX; bool ret; struct Object *obedit = scene->obedit; @@ -5223,7 +5224,7 @@ bool ED_view3d_snap_from_region( float r_co[3], float r_no[3]) { float r_no_dummy[3]; - float ray_dist = TRANSFORM_DIST_MAX_RAY; + float ray_dist = BVH_RAYCAST_DIST_MAX; bool is_hit = false; float *r_no_ptr = r_no ? r_no : r_no_dummy; @@ -5236,7 +5237,7 @@ bool ED_view3d_snap_from_region( for (int i = 0; i < 3; i++) { if (elem_test[i] && (is_hit == false || use_depth)) { if (use_depth == false) { - ray_dist = TRANSFORM_DIST_MAX_RAY; + ray_dist = BVH_RAYCAST_DIST_MAX; } if (snapObjectsEx( scene, v3d, ar, NULL, obedit, diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 8b3ea2a1fee..022b305e5ac 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -33,6 +33,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_kdopbvh.h" #include "BLI_utildefines.h" #include "BKE_context.h" @@ -410,7 +411,7 @@ static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *w float dvec_tmp[3]; bool ret; - *r_distance = TRANSFORM_DIST_MAX_RAY; + *r_distance = BVH_RAYCAST_DIST_MAX; copy_v3_v3(ray_start, rv3d->viewinv[3]); @@ -441,7 +442,7 @@ static bool walk_ray_cast(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float float mat[3][3]; /* 3x3 copy of the view matrix so we can move along the view axis */ bool ret; - *ray_distance = TRANSFORM_DIST_MAX_RAY; + *ray_distance = BVH_RAYCAST_DIST_MAX; copy_v3_v3(ray_start, rv3d->viewinv[3]); copy_m3_m4(mat, rv3d->viewinv); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 359e191c90d..869f03e416a 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1544,7 +1544,7 @@ static bool snapDerivedMesh( if (totvert > 0) { float imat[4][4]; float timat[3][3]; /* transpose inverse matrix for normals */ - float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY; + float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = BVH_RAYCAST_DIST_MAX; invert_m4_m4(imat, obmat); transpose_m3_m4(timat, imat); @@ -1637,7 +1637,7 @@ static bool snapDerivedMesh( hit.index = -1; hit.dist = *ray_depth; - if (hit.dist != TRANSFORM_DIST_MAX_RAY) { + if (hit.dist != BVH_RAYCAST_DIST_MAX) { hit.dist *= local_scale; hit.dist -= len_diff; } @@ -2081,7 +2081,7 @@ bool snapObjectsTransform( TransInfo *t, const float mval[2], SnapSelect snap_select, float r_loc[3], float r_no[3], float *r_dist_px) { - float ray_dist = TRANSFORM_DIST_MAX_RAY; + float ray_dist = BVH_RAYCAST_DIST_MAX; Object *obedit = NULL; Base *base_act = NULL; @@ -2109,7 +2109,7 @@ bool snapObjectsContext( Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); Object *obedit = CTX_data_edit_object(C); - float ray_dist = TRANSFORM_DIST_MAX_RAY; + float ray_dist = BVH_RAYCAST_DIST_MAX; return snapObjects( scene, v3d, ar, scene->basact, obedit, |