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-09-07 03:50:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-07 03:50:28 +0400
commitaca97317afd7c282d072e927d002fb2571a29a49 (patch)
tree751e4bc81e78512972ccf68c8d558064589ed9fd
parent0ecbc047e8a540175b00ed967050abb5f7363dbc (diff)
code cleanup: move vertex and face picking functions into meshtools.c
-rw-r--r--source/blender/editors/include/ED_mesh.h5
-rw-r--r--source/blender/editors/mesh/editface.c41
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c3
-rw-r--r--source/blender/editors/mesh/meshtools.c79
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c32
5 files changed, 90 insertions, 70 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index c25401d570f..d8e03b01a84 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -276,6 +276,11 @@ void EDBM_redo_state_restore(struct BMBackup, struct BMEditMesh *em, int recalct
/* delete the backup, optionally flushing it to an editmesh */
void EDBM_redo_state_free(struct BMBackup *, struct BMEditMesh *em, int recalctess);
+/* mesh_tools.c */
+int ED_mesh_pick_face(struct bContext *C, struct Mesh *me, struct Object *ob, const int mval[2], unsigned int *index, short rect);
+int ED_mesh_pick_vert(struct bContext *C, struct Mesh *me, const int mval[2], unsigned int *index, int size);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 3431bea18ea..36fbfeedcb6 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -123,43 +123,6 @@ void paintface_flush_flags(Object *ob)
}
}
-/* returns 0 if not found, otherwise 1 */
-static int facesel_face_pick(struct bContext *C, Mesh *me, Object *ob, const int mval[2], unsigned int *index, short rect)
-{
- Scene *scene = CTX_data_scene(C);
- ViewContext vc;
- view3d_set_viewcontext(C, &vc);
-
- if (!me || me->totpoly == 0)
- return 0;
-
- makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH, 0);
-
- // XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
-// XXX drawview.c! check_backbuf();
-// XXX persp(PERSP_VIEW);
-// XXX }
-
- if (rect) {
- /* sample rect to increase changes of selecting, so that when clicking
- * on an edge in the backbuf, we can still select a face */
-
- int dist;
- *index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly + 1, &dist, 0, NULL, NULL);
- }
- else {
- /* sample only on the exact position */
- *index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
- }
-
- if ((*index) <= 0 || (*index) > (unsigned int)me->totpoly)
- return 0;
-
- (*index)--;
-
- return 1;
-}
-
void paintface_hide(Object *ob, const int unselected)
{
Mesh *me;
@@ -331,7 +294,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2]
if (mode == 0 || mode == 1) {
/* XXX - Causes glitches, not sure why */
#if 0
- if (!facesel_face_pick(C, me, mval, &index, 1))
+ if (!ED_mesh_pick_face(C, me, mval, &index, 1))
return;
#endif
}
@@ -518,7 +481,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in
/* Get the face under the cursor */
me = BKE_mesh_from_object(ob);
- if (!facesel_face_pick(C, me, ob, mval, &index, 1))
+ if (!ED_mesh_pick_face(C, me, ob, mval, &index, 1))
return 0;
if (index >= me->totpoly)
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index 397f224ef2e..40c1ea7eff2 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -749,10 +749,13 @@ static int edbm_vertex_slide_exec_ex(bContext *C, wmOperator *op, const int do_u
return OPERATOR_FINISHED;
}
+
+#if 0
static int edbm_vertex_slide_exec(bContext *C, wmOperator *op)
{
return edbm_vertex_slide_exec_ex(C, op, TRUE);
}
+#endif
void MESH_OT_vert_slide(wmOperatorType *ot)
{
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 2e75a779fed..87a657c0acd 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1146,3 +1146,82 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em)
return mirrorfaces;
}
+
+/* selection, vertex and face */
+/* returns 0 if not found, otherwise 1 */
+
+/**
+ * Face selection in object mode,
+ * currently only weight-paint and vertex-paint use this.
+ *
+ * \return boolean TRUE == Found
+ */
+int ED_mesh_pick_face(bContext *C, Mesh *me, Object *ob, const int mval[2], unsigned int *index, short rect)
+{
+ Scene *scene = CTX_data_scene(C);
+ ViewContext vc;
+ view3d_set_viewcontext(C, &vc);
+
+ if (!me || me->totpoly == 0)
+ return 0;
+
+ makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH, 0);
+
+ // XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
+// XXX drawview.c! check_backbuf();
+// XXX persp(PERSP_VIEW);
+// XXX }
+
+ if (rect) {
+ /* sample rect to increase changes of selecting, so that when clicking
+ * on an edge in the backbuf, we can still select a face */
+
+ int dist;
+ *index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly + 1, &dist, 0, NULL, NULL);
+ }
+ else {
+ /* sample only on the exact position */
+ *index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
+ }
+
+ if ((*index) <= 0 || (*index) > (unsigned int)me->totpoly)
+ return 0;
+
+ (*index)--;
+
+ return 1;
+}
+
+/**
+ * Vertex selection in object mode,
+ * currently only weight paint uses this.
+ *
+ * \return boolean TRUE == Found
+ */
+int ED_mesh_pick_vert(bContext *C, Mesh *me, const int mval[2], unsigned int *index, int size)
+{
+ ViewContext vc;
+ view3d_set_viewcontext(C, &vc);
+
+ if (!me || me->totvert == 0)
+ return 0;
+
+ if (size > 0) {
+ /* sample rect to increase changes of selecting, so that when clicking
+ * on an face in the backbuf, we can still select a vert */
+
+ int dist;
+ *index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dist, 0, NULL, NULL);
+ }
+ else {
+ /* sample only on the exact position */
+ *index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
+ }
+
+ if ((*index) <= 0 || (*index) > (unsigned int)me->totvert)
+ return 0;
+
+ (*index)--;
+
+ return 1;
+}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index df0908e445e..05066c799a0 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2027,36 +2027,6 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
WM_operator_properties_gesture_border(ot, TRUE);
}
-/* much like facesel_face_pick()*/
-/* returns 0 if not found, otherwise 1 */
-static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], unsigned int *index, int size)
-{
- ViewContext vc;
- view3d_set_viewcontext(C, &vc);
-
- if (!me || me->totvert == 0)
- return 0;
-
- if (size > 0) {
- /* sample rect to increase changes of selecting, so that when clicking
- * on an face in the backbuf, we can still select a vert */
-
- int dist;
- *index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dist, 0, NULL, NULL);
- }
- else {
- /* sample only on the exact position */
- *index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
- }
-
- if ((*index) <= 0 || (*index) > (unsigned int)me->totvert)
- return 0;
-
- (*index)--;
-
- return 1;
-}
-
/* mouse selection in weight paint */
/* gets called via generic mouse select operator */
static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, short deselect, short toggle, Object *obact)
@@ -2065,7 +2035,7 @@ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], shor
unsigned int index = 0;
MVert *mv;
- if (vertsel_vert_pick(C, me, mval, &index, 50)) {
+ if (ED_mesh_pick_vert(C, me, mval, &index, 50)) {
mv = me->mvert + index;
if (extend) {
mv->flag |= SELECT;