From 6ded71fb62e7f8e6791bd5a6d721b1bd9efe0b85 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 30 Dec 2012 18:29:56 +0000 Subject: Hiding support for dynamic topology --- source/blender/editors/sculpt_paint/paint_hide.c | 72 ++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'source/blender/editors/sculpt_paint/paint_hide.c') diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index 36fe4715fc0..9cc908746e8 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -232,6 +232,75 @@ static void partialvis_update_grids(Object *ob, } } +static void partialvis_update_bmesh_verts(BMesh *bm, + GHash *verts, + PartialVisAction action, + PartialVisArea area, + float planes[4][4], + int *any_changed, + int *any_visible) +{ + GHashIterator gh_iter; + + GHASH_ITER (gh_iter, verts) { + BMVert *v = BLI_ghashIterator_getKey(&gh_iter); + float *vmask = CustomData_bmesh_get(&bm->vdata, + v->head.data, + CD_PAINT_MASK); + + /* hide vertex if in the hide volume */ + if (is_effected(area, planes, v->co, *vmask)) { + if (action == PARTIALVIS_HIDE) + BM_elem_flag_enable(v, BM_ELEM_HIDDEN); + else + BM_elem_flag_disable(v, BM_ELEM_HIDDEN); + (*any_changed) = TRUE; + } + + if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) + (*any_visible) = TRUE; + } +} + +static void partialvis_update_bmesh(Object *ob, + PBVH *pbvh, + PBVHNode *node, + PartialVisAction action, + PartialVisArea area, + float planes[4][4]) +{ + BMesh *bm; + GHash *unique, *other; + int any_changed = 0, any_visible = 0; + + bm = BLI_pbvh_get_bmesh(pbvh); + unique = BLI_pbvh_bmesh_node_unique_verts(node); + other = BLI_pbvh_bmesh_node_other_verts(node); + + sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); + + partialvis_update_bmesh_verts(bm, + unique, + action, + area, + planes, + &any_changed, + &any_visible); + + partialvis_update_bmesh_verts(bm, + other, + action, + area, + planes, + &any_changed, + &any_visible); + + if (any_changed) { + BLI_pbvh_node_mark_rebuild_draw(node); + BLI_pbvh_node_fully_hidden_set(node, !any_visible); + } +} + static void rect_from_props(rcti *rect, PointerRNA *ptr) { rect->xmin = RNA_int_get(ptr, "xmin"); @@ -330,6 +399,9 @@ static int hide_show_exec(bContext *C, wmOperator *op) case PBVH_GRIDS: partialvis_update_grids(ob, pbvh, nodes[i], action, area, clip_planes); break; + case PBVH_BMESH: + partialvis_update_bmesh(ob, pbvh, nodes[i], action, area, clip_planes); + break; } } -- cgit v1.2.3