diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/bmesh/operators/bmo_bisect_plane.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/bmesh/operators/bmo_bisect_plane.c')
-rw-r--r-- | source/blender/bmesh/operators/bmo_bisect_plane.c | 132 |
1 files changed, 65 insertions, 67 deletions
diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c index 800f5bac715..f3062cac85c 100644 --- a/source/blender/bmesh/operators/bmo_bisect_plane.c +++ b/source/blender/bmesh/operators/bmo_bisect_plane.c @@ -37,71 +37,69 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) { - const float dist = BMO_slot_float_get(op->slots_in, "dist"); - const bool use_snap_center = BMO_slot_bool_get(op->slots_in, "use_snap_center"); - const bool clear_outer = BMO_slot_bool_get(op->slots_in, "clear_outer"); - const bool clear_inner = BMO_slot_bool_get(op->slots_in, "clear_inner"); - - float plane_co[3]; - float plane_no[3]; - float plane[4]; - - BMO_slot_vec_get(op->slots_in, "plane_co", plane_co); - BMO_slot_vec_get(op->slots_in, "plane_no", plane_no); - - if (is_zero_v3(plane_no)) { - BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Zero normal given"); - return; - } - - plane_from_point_normal_v3(plane, plane_co, plane_no); - - /* tag geometry to bisect */ - BM_mesh_elem_hflag_disable_all(bm, BM_EDGE | BM_FACE, BM_ELEM_TAG, false); - BMO_slot_buffer_hflag_enable(bm, op->slots_in, "geom", BM_EDGE | BM_FACE, BM_ELEM_TAG, false); - - BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_ALL_NOLOOP, ELE_INPUT); - - - BM_mesh_bisect_plane(bm, plane, use_snap_center, true, - ELE_CUT, ELE_NEW, dist); - - - if (clear_outer || clear_inner) { - /* Use an array of vertices because 'geom' contains both vers and edges that may use them. - * Removing a vert may remove and edge which is later checked by BMO_ITER. - * over-alloc the total possible vert count */ - const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_count(op->slots_in, "geom")); - BMVert **vert_arr = MEM_mallocN(sizeof(*vert_arr) * (size_t)vert_arr_max, __func__); - BMOIter siter; - BMVert *v; - float plane_inner[4]; - float plane_outer[4]; - - STACK_DECLARE(vert_arr); - - copy_v3_v3(plane_outer, plane); - copy_v3_v3(plane_inner, plane); - plane_outer[3] = plane[3] - dist; - plane_inner[3] = plane[3] + dist; - - STACK_INIT(vert_arr, vert_arr_max); - - BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { - if ((clear_outer && plane_point_side_v3(plane_outer, v->co) > 0.0f) || - (clear_inner && plane_point_side_v3(plane_inner, v->co) < 0.0f)) - { - STACK_PUSH(vert_arr, v); - } - } - - while ((v = STACK_POP(vert_arr))) { - BM_vert_kill(bm, v); - } - - MEM_freeN(vert_arr); - } - - BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW | ELE_INPUT); - BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_cut.out", BM_VERT | BM_EDGE, ELE_CUT); + const float dist = BMO_slot_float_get(op->slots_in, "dist"); + const bool use_snap_center = BMO_slot_bool_get(op->slots_in, "use_snap_center"); + const bool clear_outer = BMO_slot_bool_get(op->slots_in, "clear_outer"); + const bool clear_inner = BMO_slot_bool_get(op->slots_in, "clear_inner"); + + float plane_co[3]; + float plane_no[3]; + float plane[4]; + + BMO_slot_vec_get(op->slots_in, "plane_co", plane_co); + BMO_slot_vec_get(op->slots_in, "plane_no", plane_no); + + if (is_zero_v3(plane_no)) { + BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Zero normal given"); + return; + } + + plane_from_point_normal_v3(plane, plane_co, plane_no); + + /* tag geometry to bisect */ + BM_mesh_elem_hflag_disable_all(bm, BM_EDGE | BM_FACE, BM_ELEM_TAG, false); + BMO_slot_buffer_hflag_enable(bm, op->slots_in, "geom", BM_EDGE | BM_FACE, BM_ELEM_TAG, false); + + BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_ALL_NOLOOP, ELE_INPUT); + + BM_mesh_bisect_plane(bm, plane, use_snap_center, true, ELE_CUT, ELE_NEW, dist); + + if (clear_outer || clear_inner) { + /* Use an array of vertices because 'geom' contains both vers and edges that may use them. + * Removing a vert may remove and edge which is later checked by BMO_ITER. + * over-alloc the total possible vert count */ + const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_count(op->slots_in, "geom")); + BMVert **vert_arr = MEM_mallocN(sizeof(*vert_arr) * (size_t)vert_arr_max, __func__); + BMOIter siter; + BMVert *v; + float plane_inner[4]; + float plane_outer[4]; + + STACK_DECLARE(vert_arr); + + copy_v3_v3(plane_outer, plane); + copy_v3_v3(plane_inner, plane); + plane_outer[3] = plane[3] - dist; + plane_inner[3] = plane[3] + dist; + + STACK_INIT(vert_arr, vert_arr_max); + + BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { + if ((clear_outer && plane_point_side_v3(plane_outer, v->co) > 0.0f) || + (clear_inner && plane_point_side_v3(plane_inner, v->co) < 0.0f)) { + STACK_PUSH(vert_arr, v); + } + } + + while ((v = STACK_POP(vert_arr))) { + BM_vert_kill(bm, v); + } + + MEM_freeN(vert_arr); + } + + BMO_slot_buffer_from_enabled_flag( + bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW | ELE_INPUT); + BMO_slot_buffer_from_enabled_flag( + bm, op, op->slots_out, "geom_cut.out", BM_VERT | BM_EDGE, ELE_CUT); } |