Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-04-14 09:37:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-14 09:37:43 +0400
commitba283d6c9be1d678210e08233916268f48ef4ee1 (patch)
tree979ed657034ae3e6df69b4e428fe2694ccee867e /source/blender/editors/transform
parentd2b14ed4f007d7eb1160b67c6b3722cec52df375 (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/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform_snap.c19
1 files changed, 9 insertions, 10 deletions
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);
}