diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-10 06:05:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-10 06:05:16 +0400 |
commit | aabddad346f20111d5ef8aae01e39a265f2b145c (patch) | |
tree | f2d8ded73d794405630eabd5c335ff95b426a5fd /source/blender/editors | |
parent | b0312d59914419884098ae42fbbd648eb32256bc (diff) |
draw loopcut display on the deformed mesh when in editmode.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 41 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 4 |
4 files changed, 47 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 51d5d42394c..fd08039c24b 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -95,6 +95,7 @@ void EDBM_selectmode_to_scene(struct bContext *C); void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob); void EDBM_mesh_free(struct BMEditMesh *em); void EDBM_mesh_load(struct Object *ob); +struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em); void EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype); void EDBM_index_arrays_init(struct BMEditMesh *em, const char htype); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 2829aed4999..97e6a6e8aad 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -42,6 +42,7 @@ #include "BKE_modifier.h" #include "BKE_report.h" #include "BKE_editmesh.h" +#include "BKE_DerivedMesh.h" #include "BIF_gl.h" @@ -155,9 +156,30 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, } } +static void edgering_vcos_get(DerivedMesh *dm, BMVert *v[2][2], float r_cos[2][2][3]) +{ + if (dm) { + int j, k; + for (j = 0; j < 2; j++) { + for (k = 0; k < 2; k++) { + dm->getVertCo(dm, BM_elem_index_get(v[j][k]), r_cos[j][k]); + } + } + } + else { + int j, k; + for (j = 0; j < 2; j++) { + for (k = 0; k < 2; k++) { + copy_v3_v3(r_cos[j][k], v[j][k]->co); + } + } + } +} + static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select) { BMEditMesh *em = lcd->em; + DerivedMesh *dm = EDBM_mesh_deform_dm_get(em); BMEdge *eed_start = lcd->eed; BMEdge *eed, *eed_last; BMVert *v[2][2], *v_last; @@ -195,6 +217,10 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select) return; } + if (dm) { + EDBM_index_arrays_ensure(lcd->em, BM_VERT); + } + BMW_init(&walker, em->bm, BMW_EDGERING, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_FLAG_TEST_HIDDEN, @@ -222,8 +248,12 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select) for (i = 1; i <= previewlines; i++) { const float fac = (i / ((float)previewlines + 1)); - interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac); - interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac); + float v_cos[2][2][3]; + + edgering_vcos_get(dm, v, v_cos); + + interp_v3_v3v3(edges[tot][0], v_cos[0][0], v_cos[0][1], fac); + interp_v3_v3v3(edges[tot][1], v_cos[1][0], v_cos[1][1], fac); tot++; } } @@ -244,13 +274,16 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select) for (i = 1; i <= previewlines; i++) { const float fac = (i / ((float)previewlines + 1)); + float v_cos[2][2][3]; if (!v[0][0] || !v[0][1] || !v[1][0] || !v[1][1]) { continue; } - interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac); - interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac); + edgering_vcos_get(dm, v, v_cos); + + interp_v3_v3v3(edges[tot][0], v_cos[0][0], v_cos[0][1], fac); + interp_v3_v3v3(edges[tot][1], v_cos[1][0], v_cos[1][1], fac); tot++; } } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index effbe3a619d..6e294d15dab 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -171,6 +171,14 @@ void EDBM_stats_update(BMEditMesh *em) } } +DerivedMesh *EDBM_mesh_deform_dm_get(BMEditMesh *em) +{ + return ((em->derivedFinal != NULL) && + (em->derivedFinal) && + (em->derivedFinal->type == DM_TYPE_EDITBMESH) && + (em->derivedFinal->deformedOnly != false)) ? em->derivedFinal : NULL; +} + bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt, ...) { BMesh *bm = em->bm; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 55e1fae38e4..54a3260439e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2700,9 +2700,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0; float clip_planes[4][4]; /* allow for displaying shape keys and deform mods */ - DerivedMesh *dm = ((em->derivedFinal != NULL) && - (em->derivedFinal->type == DM_TYPE_EDITBMESH) && - (em->derivedFinal->deformedOnly != false)) ? em->derivedFinal : NULL; + DerivedMesh *dm = EDBM_mesh_deform_dm_get(em); BMIter iter; int i; |