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>2012-10-04 21:52:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-04 21:52:12 +0400
commite77004157e483c610a6478b733a42554ab21c365 (patch)
tree49658faa8166b7176d8b3202308f97561db22bb0
parent709903c6bba4dca12a6f367000f99a83da2af034 (diff)
make ED_view3d_project_int equivalent to ED_view3d_project_short functions.
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c48
-rw-r--r--source/blender/editors/include/ED_view3d.h12
-rw-r--r--source/blender/editors/physics/particle_edit.c32
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c27
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c13
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c67
-rw-r--r--source/blender/editors/transform/transform.c8
-rw-r--r--source/blender/editors/transform/transform_snap.c21
9 files changed, 130 insertions, 105 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5909c4fc270..0595f4e18bd 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -278,11 +278,15 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
gp_get_3d_reference(p, rvec);
/* method taken from editview.c - mouse_cursor() */
- ED_view3d_project_int_noclip(p->ar, rvec, mval_prj);
-
- VECSUB2D(mval_f, mval_prj, mval);
- ED_view3d_win_to_delta(p->ar, mval_f, dvec);
- sub_v3_v3v3(out, rvec, dvec);
+ /* TODO, use ED_view3d_project_float_global */
+ if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ VECSUB2D(mval_f, mval_prj, mval);
+ ED_view3d_win_to_delta(p->ar, mval_f, dvec);
+ sub_v3_v3v3(out, rvec, dvec);
+ }
+ else {
+ zero_v3(out);
+ }
}
}
@@ -808,9 +812,14 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
else if (gps->totpoints == 1) {
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- ED_view3d_project_int(p->ar, &gps->points->x, xyval);
- x0 = xyval[0];
- y0 = xyval[1];
+ if (ED_view3d_project_int_global(p->ar, &gps->points->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ x0 = xyval[0];
+ y0 = xyval[1];
+ }
+ else {
+ x0 = V2D_IS_CLIPPED;
+ y0 = V2D_IS_CLIPPED;
+ }
}
else if (gps->flag & GP_STROKE_2DSPACE) {
UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0);
@@ -847,13 +856,22 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- ED_view3d_project_int(p->ar, &pt1->x, xyval);
- x0 = xyval[0];
- y0 = xyval[1];
-
- ED_view3d_project_int(p->ar, &pt2->x, xyval);
- x1 = xyval[0];
- y1 = xyval[1];
+ if (ED_view3d_project_int_global(p->ar, &pt1->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ x0 = xyval[0];
+ y0 = xyval[1];
+ }
+ else {
+ x0 = V2D_IS_CLIPPED;
+ y0 = V2D_IS_CLIPPED;
+ }
+ if (ED_view3d_project_int_global(p->ar, &pt2->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ x1 = xyval[0];
+ y1 = xyval[1];
+ }
+ else {
+ x1 = V2D_IS_CLIPPED;
+ y1 = V2D_IS_CLIPPED;
+ }
}
else if (gps->flag & GP_STROKE_2DSPACE) {
UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index ca5d8691df7..30eb38a14bb 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -132,14 +132,18 @@ typedef enum {
} eV3DProjTest;
+/* *** short *** */
eV3DProjStatus ED_view3d_project_short_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
const float co[3], short r_co[2], eV3DProjTest flag);
eV3DProjStatus ED_view3d_project_short_global(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag);
eV3DProjStatus ED_view3d_project_short_object(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag);
-void _ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]); // V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN
-void _ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]); //
-void ED_view3d_project_int(struct ARegion *ar, const float co[3], int r_co[2]);
-void ED_view3d_project_int_noclip(struct ARegion *ar, const float co[3], int r_co[2]);
+
+/* *** int *** */
+eV3DProjStatus ED_view3d_project_int_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], int r_co[2], eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_int_global(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_int_object(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
+
void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]);
void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float r_co[2]);
void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 6d3f4b38583..6c1d2e651cb 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -398,6 +398,8 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
/*************************** selection utilities *******************************/
+/* TODO, many of the callers to this function already have a 2d projection that
+ * could be passed as an arg, save calling ED_view3d_project_short_global again. */
static int key_test_depth(PEData *data, const float co[3])
{
View3D *v3d= data->vc.v3d;
@@ -448,11 +450,11 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float *
float dx, dy, dist;
int sco[2];
- ED_view3d_project_int(data->vc.ar, co, sco);
-
- if (sco[0] == IS_CLIPPED)
+ /* TODO, should this check V3D_PROJ_TEST_CLIP_BB too? */
+ if (ED_view3d_project_int_global(data->vc.ar, co, sco, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) {
return 0;
-
+ }
+
dx= data->mval[0] - sco[0];
dy= data->mval[1] - sco[1];
dist= sqrt(dx*dx + dy*dy);
@@ -474,10 +476,9 @@ static int key_inside_rect(PEData *data, const float co[3])
{
int sco[2];
- ED_view3d_project_int(data->vc.ar, co, sco);
-
- if (sco[0] == IS_CLIPPED)
+ if (ED_view3d_project_int_global(data->vc.ar, co, sco, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) {
return 0;
+ }
if (sco[0] > data->rect->xmin && sco[0] < data->rect->xmax &&
sco[1] > data->rect->ymin && sco[1] < data->rect->ymax)
@@ -1667,8 +1668,8 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
LOOP_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- ED_view3d_project_int(ar, co, vertco);
- if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
+ if ((ED_view3d_project_int_global(ar, co, vertco, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) &&
+ BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
if (select && !(key->flag & PEK_SELECT)) {
@@ -1687,8 +1688,8 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- ED_view3d_project_int(ar, co, vertco);
- if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
+ if ((ED_view3d_project_int_global(ar, co, vertco, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) &&
+ BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
if (select && !(key->flag & PEK_SELECT)) {
@@ -2799,11 +2800,13 @@ static void brush_cut(PEData *data, int pa_index)
if (edit->points[pa_index].flag & PEP_HIDE)
return;
+ if (ED_view3d_project_int_global(ar, key->co, vertco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS)
+ return;
+
rad2= data->rad * data->rad;
cut=0;
- ED_view3d_project_int_noclip(ar, key->co, vertco);
x0= (float)vertco[0];
x1= (float)vertco[1];
@@ -2821,9 +2824,10 @@ static void brush_cut(PEData *data, int pa_index)
else {
/* calculate path time closest to root that was inside the circle */
for (k=1, key++; k<=keys; k++, key++) {
- ED_view3d_project_int_noclip(ar, key->co, vertco);
- if (key_test_depth(data, key->co) == 0) {
+ if ((ED_view3d_project_int_global(ar, key->co, vertco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) ||
+ key_test_depth(data, key->co) == 0)
+ {
x0= (float)vertco[0];
x1= (float)vertco[1];
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 25ad85d3db8..cb197ab93b0 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -553,32 +553,23 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
{
- int mx, my, co[2];
- int flag;
-
+ int co[2];
+
/* we don't want the clipping for cursor */
- flag = v3d->flag;
- v3d->flag = 0;
- ED_view3d_project_int(ar, give_cursor(scene, v3d), co);
- v3d->flag = flag;
-
- mx = co[0];
- my = co[1];
-
- if (mx != IS_CLIPPED) {
+ if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
setlinestyle(0);
cpack(0xFF);
- circ((float)mx, (float)my, 10.0);
+ circ((float)co[0], (float)co[1], 10.0);
setlinestyle(4);
cpack(0xFFFFFF);
- circ((float)mx, (float)my, 10.0);
+ circ((float)co[0], (float)co[1], 10.0);
setlinestyle(0);
cpack(0x0);
- sdrawline(mx - 20, my, mx - 5, my);
- sdrawline(mx + 5, my, mx + 20, my);
- sdrawline(mx, my - 20, mx, my - 5);
- sdrawline(mx, my + 5, mx, my + 20);
+ sdrawline(co[0] - 20, co[1], co[0] - 5, co[1]);
+ sdrawline(co[0] + 5, co[1], co[0] + 20, co[1]);
+ sdrawline(co[0], co[1] - 20, co[0], co[1] - 5);
+ sdrawline(co[0], co[1] + 5, co[0], co[1] + 20);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index d3ff64c9f40..800b4ac53c8 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3524,12 +3524,14 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
int mval[2];
// short ctrl= 0; // XXX
int flip;
+ eV3DProjStatus ret;
fp = give_cursor(scene, v3d);
// if (obedit && ctrl) lr_click= 1;
copy_v3_v3(oldcurs, fp);
- ED_view3d_project_int_noclip(ar, fp, mval);
+ mval[0] = IS_CLIPPED;
+ ret = ED_view3d_project_int_global(ar, fp, mval, V3D_PROJ_TEST_NOP);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
/* reset the depth based on the view offset */
@@ -3537,7 +3539,8 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
negate_v3_v3(fp, rv3d->ofs);
/* re initialize */
- ED_view3d_project_int_noclip(ar, fp, mval);
+ mval[0] = IS_CLIPPED;
+ ED_view3d_project_int_global(ar, fp, mval, V3D_PROJ_TEST_NOP);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
(void)flip;
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index b31b932d71f..2332ca98a66 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -110,15 +110,16 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
{
float dvec[3];
int mval_cpy[2];
+ eV3DProjStatus ret;
mval_cpy[0] = mval[0];
mval_cpy[1] = mval[1];
- ED_view3d_project_int_noclip(vc->ar, fp, mval_cpy);
+ ret = ED_view3d_project_int_global(vc->ar, fp, mval_cpy, V3D_PROJ_TEST_NOP);
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
- if (mval_cpy[0] != IS_CLIPPED) {
+ if (ret == V3D_PROJ_RET_SUCCESS) {
const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]),
(float)(mval_cpy[1] - mval[1])};
ED_view3d_win_to_delta(vc->ar, mval_f, dvec);
@@ -333,10 +334,14 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
+
+ /* XXX, todo, use ED_view3d_project_int_object */
+ sco1[0] = sco2[0] = IS_CLIPPED;
+
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
- ED_view3d_project_int(vc->ar, vec, sco1);
+ ED_view3d_project_int_global(vc->ar, vec, sco1, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
- ED_view3d_project_int(vc->ar, vec, sco2);
+ ED_view3d_project_int_global(vc->ar, vec, sco2, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN);
if (BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) {
if (select) pchan->bone->flag |= BONE_SELECTED;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 2ed8048fee4..b3dd54c6261 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -971,6 +971,26 @@ eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], con
return ret;
}
+eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], int r_co[2], eV3DProjTest flag)
+{
+ float tvec[2];
+ eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
+ if (ret == V3D_PROJ_RET_SUCCESS) {
+ if ((tvec[0] > -2140000000.0 && tvec[0] < 2140000000.0f) &&
+ (tvec[1] > -2140000000.0 && tvec[1] < 2140000000.0f))
+ {
+ r_co[0] = (int)floor(tvec[0]);
+ r_co[1] = (int)floor(tvec[1]);
+ }
+ else {
+ return V3D_PROJ_RET_OVERFLOW;
+ }
+ }
+ return ret;
+}
+
+/* --- short --- */
eV3DProjStatus ED_view3d_project_short_global(ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag)
{
RegionView3D *rv3d = ar->regiondata;
@@ -983,52 +1003,17 @@ eV3DProjStatus ED_view3d_project_short_object(ARegion *ar, const float co[3], sh
return ED_view3d_project_short_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
}
-void ED_view3d_project_int(ARegion *ar, const float co[3], int r_co[2])
+/* --- int --- */
+eV3DProjStatus ED_view3d_project_int_global(ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag)
{
RegionView3D *rv3d = ar->regiondata;
- float fx, fy, vec4[4];
-
- copy_v3_v3(vec4, co);
- vec4[3] = 1.0;
- r_co[0] = (int)2140000000.0f;
-
- mul_m4_v4(rv3d->persmat, vec4);
-
- if (vec4[3] > (float)BL_NEAR_CLIP) {
- fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
-
- if (fx > -2140000000.0f && fx < 2140000000.0f) {
- fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
-
- if (fy > -2140000000.0f && fy < 2140000000.0f) {
- r_co[0] = (int)floor(fx);
- r_co[1] = (int)floor(fy);
- }
- }
- }
+ return ED_view3d_project_int_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
}
-
-void ED_view3d_project_int_noclip(ARegion *ar, const float co[3], int r_co[2])
+/* object space, use ED_view3d_init_mats_rv3d before calling */
+eV3DProjStatus ED_view3d_project_int_object(ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag)
{
RegionView3D *rv3d = ar->regiondata;
- float fx, fy, vec4[4];
-
- copy_v3_v3(vec4, co);
- vec4[3] = 1.0;
-
- mul_m4_v4(rv3d->persmat, vec4);
-
- if (fabs(vec4[3]) > BL_NEAR_CLIP) {
- fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
- fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
-
- r_co[0] = (int)floor(fx);
- r_co[1] = (int)floor(fy);
- }
- else {
- r_co[0] = ar->winx / 2;
- r_co[1] = ar->winy / 2;
- }
+ return ED_view3d_project_int_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
}
void ED_view3d_project_float(ARegion *ar, const float co[3], float r_co[2])
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 343fa6681f3..32392b2fd66 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -225,8 +225,12 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype == SPACE_VIEW3D) {
- if (t->ar->regiontype == RGN_TYPE_WINDOW)
- ED_view3d_project_int_noclip(t->ar, vec, adr);
+ if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ adr[0] = (int)2140000000.0f; /* this is what was done in 2.64, perhaps we can be smarter? */
+ adr[1] = (int)2140000000.0f;
+ }
+ }
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 1d75be05534..cee1c91abe7 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -601,7 +601,9 @@ int updateSelectedSnapPoint(TransInfo *t)
int dx, dy;
int dist;
- ED_view3d_project_int(t->ar, p->co, screen_loc);
+ if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ continue;
+ }
dx = t->mval[0] - screen_loc[0];
dy = t->mval[1] - screen_loc[1];
@@ -1232,8 +1234,12 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
new_depth = len_v3v3(location, ray_start);
- ED_view3d_project_int(ar, location, screen_loc);
- new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ }
+ else {
+ new_dist = 1000;
+ }
/* 10% threshold if edge is closer but a bit further
* this takes care of series of connected edges a bit slanted w.r.t the viewport
@@ -1289,8 +1295,13 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
new_depth = len_v3v3(location, ray_start);
- ED_view3d_project_int(ar, location, screen_loc);
- new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ }
+ else {
+ new_dist = 1000;
+ }
+
if (new_dist <= *r_dist && new_depth < *r_depth) {
*r_depth = new_depth;