diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-14 09:37:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-14 09:37:43 +0400 |
commit | ba283d6c9be1d678210e08233916268f48ef4ee1 (patch) | |
tree | 979ed657034ae3e6df69b4e428fe2694ccee867e /source | |
parent | d2b14ed4f007d7eb1160b67c6b3722cec52df375 (diff) |
modify snapObjectsRayEx() to use a pointer to 'ray_dist' rather then passing the dist, this is to better support multiple calls to ray-cast where only closer distances are accepted.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 6 |
4 files changed, 16 insertions, 15 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 824d1db432f..f674f70ebee 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -178,6 +178,7 @@ typedef enum SnapMode { } SnapMode; #define SNAP_MIN_DISTANCE 30 +#define TRANSFORM_DIST_MAX_RAY (FLT_MAX / 2.0f) bool peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2], SnapMode mode); bool peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode); @@ -187,7 +188,7 @@ bool snapObjectsContext(struct bContext *C, const float mval[2], float *r_dist_p bool snapObjectsEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode); bool snapObjectsRayEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode, - const float ray_start[3], const float ray_normal[3], const float ray_dist, + const float ray_start[3], const float ray_normal[3], float *r_ray_dist, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode); bool snapNodesTransform(struct TransInfo *t, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index c71617bab6a..31843e7d56c 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -95,6 +95,7 @@ static bool ED_view3d_snap_ray(bContext *C, float r_co[3], { float dist_px = 12; /* snap dist */ float r_no_dummy[3]; + float ray_dist = TRANSFORM_DIST_MAX_RAY; bool ret; Scene *scene = CTX_data_scene(C); @@ -104,7 +105,7 @@ static bool ED_view3d_snap_ray(bContext *C, float r_co[3], /* try snap edge, then face if it fails */ ret = snapObjectsRayEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE, - ray_start, ray_normal, v3d->far, + ray_start, ray_normal, &ray_dist, NULL, &dist_px, r_co, r_no_dummy, SNAP_ALL); return ret; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 6b3c12d7e50..b4b4d2c2581 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -84,7 +84,6 @@ #define TRANSFORM_DIST_MAX_PX 1000.0f #define TRANSFORM_SNAP_MAX_PX 100.0f /* use half of flt-max so we can scale up without an exception */ -#define TRANSFORM_DIST_MAX_RAY (FLT_MAX / 2.0f) /********************* PROTOTYPES ***********************/ @@ -1550,17 +1549,16 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, i } static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, - const float ray_start[3], const float ray_normal[3], const float ray_dist, + const float ray_start[3], const float ray_normal[3], float *r_ray_dist, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode) { Base *base; - float depth = ray_dist; bool retval = false; if (mode == SNAP_ALL && obedit) { Object *ob = obedit; - retval |= snapObject(scene, snap_mode, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth); + retval |= snapObject(scene, snap_mode, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_ray_dist); } /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA @@ -1571,7 +1569,7 @@ static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D base = base_act; if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) { Object *ob = base->object; - retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth); + retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_ray_dist); } for (base = FIRSTBASE; base != NULL; base = base->next) { @@ -1590,13 +1588,13 @@ static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { Object *dob = dupli_ob->ob; - retval |= snapObject(scene, snap_mode, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth); + retval |= snapObject(scene, snap_mode, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_ray_dist); } free_object_duplilist(lb); } - retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth); + retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_ray_dist); } } @@ -1606,11 +1604,12 @@ static bool snapObjects(Scene *scene, short snap_mode, Base *base_act, View3D *v const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode) { float ray_start[3], ray_normal[3]; + float ray_dist = TRANSFORM_DIST_MAX_RAY; ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal); return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit, - ray_start, ray_normal, TRANSFORM_DIST_MAX_RAY, + ray_start, ray_normal, &ray_dist, mval, r_dist_px, r_loc, r_no, mode); } @@ -1636,11 +1635,11 @@ bool snapObjectsEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Objec mval, r_dist_px, r_loc, r_no, mode); } bool snapObjectsRayEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, short snap_mode, - const float ray_start[3], const float ray_normal[3], const float ray_dist, + const float ray_start[3], const float ray_normal[3], float *r_ray_dist, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode) { return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit, - ray_start, ray_normal, ray_dist, + ray_start, ray_normal, r_ray_dist, mval, r_dist_px, r_loc, r_no, mode); } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index a028be14cc7..9d920ff2519 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -96,13 +96,13 @@ static void rna_Scene_ray_cast(Scene *scene, ReportList *reports, float ray_star { float dummy_dist_px = 0; float ray_nor[3]; - float dist; + float ray_dist; sub_v3_v3v3(ray_nor, ray_end, ray_start); - dist = normalize_v3(ray_nor); + ray_dist = normalize_v3(ray_nor); if (snapObjectsRayEx(scene, NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE, - ray_start, ray_nor, dist, + ray_start, ray_nor, &ray_dist, NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL)) { *r_success = true; |