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-05 07:57:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-05 07:57:56 +0400
commit5770e44f43d64066162a94c036d5e1a8730eda0f (patch)
tree912b81dca2633240cfe3e6e73ee377ea48825d92
parentb9113f205ceb7bc1f8620024a0adf4b4eb681792 (diff)
replace most uses of ED_view3d_project_float_noclip() with ED_view3d_project_float_global/object
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c31
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c60
-rw-r--r--source/blender/editors/mesh/meshtools.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c26
-rw-r--r--source/blender/editors/transform/transform.c18
6 files changed, 83 insertions, 65 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 02c7d52f08d..62818612509 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -174,7 +174,7 @@ void ED_spacetypes_init(void);
/* editmesh_tools.c (could be moved) */
-void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object *obedit, struct BMEditMesh *em);
+void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em);
/* editface.c */
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index bd1d13f3528..e42b95c6013 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -381,22 +381,23 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2])
BMEdge *edge = NULL;
float v1_proj[3], v2_proj[3];
- float dist = 0;
float min_dist = FLT_MAX;
for (i = 0; i < vso->disk_edges; i++) {
edge = vso->edge_frame[i];
mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co);
- ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj);
-
mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co);
- ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj);
- dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
- if (dist < min_dist) {
- min_dist = dist;
- cl_edge = edge;
+ /* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */
+ if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
+ (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ {
+ const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
+ if (dist < min_dist) {
+ min_dist = dist;
+ cl_edge = edge;
+ }
}
}
}
@@ -448,17 +449,21 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event)
/* Calculate interpolation value for preview */
float t_val;
- float mval_float[] = { (float)event->mval[0], (float)event->mval[1]};
+ float mval_float[2] = { (float)event->mval[0], (float)event->mval[1]};
float closest_2d[2];
other = BM_edge_other_vert(edge, vso->start_vtx);
/* Project points onto screen and do interpolation in 2D */
mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co);
- ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
-
mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co);
- ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
+
+ if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) ||
+ (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS))
+ {
+ /* not much we can do here */
+ return;
+ }
closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj);
@@ -470,7 +475,7 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event)
if (edge_len <= 0.0f)
edge_len = VTX_SLIDE_SNAP_THRSH;
- edge_len = (len_v3v3(edge->v1->co, edge->v2->co) * VTX_SLIDE_SNAP_THRSH) / edge_len;
+ edge_len = (BM_edge_calc_length(edge) * VTX_SLIDE_SNAP_THRSH) / edge_len;
vso->snap_threshold = edge_len;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 23348eed2b4..879e20fcf8b 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -153,19 +153,22 @@ void MESH_OT_subdivide(wmOperatorType *ot)
}
-void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMesh *em)
+void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
{
+ Object *obedit = em->ob;
BMIter iter;
BMVert *eve;
+ ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
+
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- float mval[2], vec[3], no_dummy[3];
+ float mval[2], co_proj[3], no_dummy[3];
int dist_dummy;
- mul_v3_m4v3(vec, obedit->obmat, eve->co);
- ED_view3d_project_float_noclip(ar, vec, mval);
- if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) {
- mul_v3_m4v3(eve->co, obedit->imat, vec);
+ if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (snapObjectsContext(C, mval, &dist_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
+ mul_v3_m4v3(eve->co, obedit->imat, co_proj);
+ }
}
}
}
@@ -731,7 +734,10 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
short use_proj;
em_setup_viewcontext(C, &vc);
-
+
+ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+
+
use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
(vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
@@ -760,26 +766,26 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
float co1[3], co2[3];
- mul_v3_m4v3(co1, vc.obedit->obmat, eed->v1->co);
- mul_v3_m4v3(co2, vc.obedit->obmat, eed->v2->co);
- ED_view3d_project_float_noclip(vc.ar, co1, co1);
- ED_view3d_project_float_noclip(vc.ar, co2, co2);
-
- /* 2D rotate by 90d while adding.
- * (x, y) = (y, -x)
- *
- * accumulate the screenspace normal in 2D,
- * with screenspace edge length weighting the result. */
- if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
- nor[0] += (co1[1] - co2[1]);
- nor[1] += -(co1[0] - co2[0]);
- }
- else {
- nor[0] += (co2[1] - co1[1]);
- nor[1] += -(co2[0] - co1[0]);
+
+ if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
+ (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ {
+ /* 2D rotate by 90d while adding.
+ * (x, y) = (y, -x)
+ *
+ * accumulate the screenspace normal in 2D,
+ * with screenspace edge length weighting the result. */
+ if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
+ nor[0] += (co1[1] - co2[1]);
+ nor[1] += -(co1[0] - co2[0]);
+ }
+ else {
+ nor[0] += (co2[1] - co1[1]);
+ nor[1] += -(co2[0] - co1[0]);
+ }
+ done = TRUE;
}
}
- done = TRUE;
}
if (done) {
@@ -836,7 +842,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
/* also project the source, for retopo workflow */
if (use_proj)
- EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em);
+ EMBM_project_snap_verts(C, vc.ar, vc.em);
}
edbm_extrude_edge(vc.obedit, vc.em, BM_ELEM_SELECT, nor);
@@ -869,7 +875,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
}
if (use_proj)
- EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em);
+ EMBM_project_snap_verts(C, vc.ar, vc.em);
/* This normally happens when pushing undo but modal operators
* like this one don't push undo data until after modal mode is
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index ef826c07cc1..42d82fff38e 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1237,11 +1237,12 @@ int ED_mesh_pick_face_vert(bContext *C, Mesh *me, Object *ob, const int mval[2],
const int v_idx = me->mloop[mp->loopstart + fidx].v;
dm->getVertCo(dm, v_idx, co);
mul_m4_v3(ob->obmat, co);
- ED_view3d_project_float_noclip(ar, co, sco);
- len = len_squared_v2v2(mval_f, sco);
- if (len < len_best) {
- len_best = len;
- v_idx_best = v_idx;
+ if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ len = len_squared_v2v2(mval_f, sco);
+ if (len < len_best) {
+ len_best = len;
+ v_idx_best = v_idx;
+ }
}
} while (fidx--);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 8aed92df3af..f1ee8f522d9 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -846,20 +846,22 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_nor[3],
const float mval[2], const float brush_size_pressure)
{
- Brush *brush = paint_brush(&vp->paint);
- float dist_squared;
- float vertco[2], delta[2];
+ float vertco[2];
- ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco);
- sub_v2_v2v2(delta, mval, vertco);
- dist_squared = dot_v2v2(delta, delta); /* len squared */
- if (dist_squared > brush_size_pressure * brush_size_pressure) {
- return 0.0f;
- }
- else {
- const float dist = sqrtf(dist_squared);
- return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
+ if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ float delta[2];
+ float dist_squared;
+
+ sub_v2_v2v2(delta, mval, vertco);
+ dist_squared = dot_v2v2(delta, delta); /* len squared */
+ if (dist_squared <= brush_size_pressure * brush_size_pressure) {
+ Brush *brush = paint_brush(&vp->paint);
+ const float dist = sqrtf(dist_squared);
+ return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
+ }
}
+
+ return 0.0f;
}
static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 32392b2fd66..631418598e5 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -351,7 +351,11 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
case SPACE_VIEW3D:
{
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- ED_view3d_project_float_noclip(t->ar, vec, adr);
+ if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ /* XXX, 2.64 and prior did this, weak! */
+ adr[0] = t->ar->winx / 2.0f;
+ adr[1] = t->ar->winy / 2.0f;
+ }
return;
}
break;
@@ -4793,12 +4797,12 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
sv->edge_len = len_v3v3(dw_p, up_p);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
- ED_view3d_project_float_noclip(t->ar, v_proj, v_proj);
-
- dist = len_squared_v2v2(mval, v_proj);
- if (dist < min_dist) {
- min_dist = dist;
- sld->curr_sv_index = i;
+ if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ dist = len_squared_v2v2(mval, v_proj);
+ if (dist < min_dist) {
+ min_dist = dist;
+ sld->curr_sv_index = i;
+ }
}
}
}