static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); PaintMaskFloodMode mode; float value; DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; int totnode, i; mode = RNA_enum_get(op->ptr, "mode"); value = RNA_float_get(op->ptr, "value"); dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; BLI_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); sculpt_undo_push_begin("Mask flood fill"); for (i = 0; i < totnode; i++) { PBVHVertexIter vi; sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); BLI_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { mask_flood_fill_set_elem(vi.mask, mode, value); } BLI_pbvh_vertex_iter_end; BLI_pbvh_node_mark_update(nodes[i]); if (BLI_pbvh_type(pbvh) == PBVH_GRIDS) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); }
static int hide_show_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); Mesh *me = ob->data; PartialVisAction action; PartialVisArea area; PBVH *pbvh; PBVHNode **nodes; DerivedMesh *dm; PBVHType pbvh_type; float clip_planes[4][4]; rcti rect; int totnode, i; /* read operator properties */ action = RNA_enum_get(op->ptr, "action"); area = RNA_enum_get(op->ptr, "area"); rect_from_props(&rect, op->ptr); clip_planes_from_rect(C, clip_planes, &rect); dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; get_pbvh_nodes(pbvh, &nodes, &totnode, clip_planes, area); pbvh_type = BLI_pbvh_type(pbvh); /* start undo */ switch (action) { case PARTIALVIS_HIDE: sculpt_undo_push_begin("Hide area"); break; case PARTIALVIS_SHOW: sculpt_undo_push_begin("Show area"); break; } for (i = 0; i < totnode; i++) { switch (pbvh_type) { case PBVH_FACES: partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes); break; case PBVH_GRIDS: partialvis_update_grids(ob, pbvh, nodes[i], action, area, clip_planes); break; } } if (nodes) MEM_freeN(nodes); /* end undo */ sculpt_undo_push_end(); /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ if (pbvh_type == PBVH_FACES) { BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop, me->medge, me->totedge, me->mpoly, me->totpoly); } ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }