Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/operators/bmo_subdivide.c
| Show All 14 Lines | |||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup bmesh | * \ingroup bmesh | ||||
| * | * | ||||
| * Edge based subdivision with various subdivision patterns. | * Edge based subdivision with various subdivision patterns. | ||||
| */ | */ | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_array.h" | #include "BLI_array.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_noise.h" | #include "BLI_noise.h" | ||||
| #include "BLI_rand.h" | #include "BLI_rand.h" | ||||
| #include "BLI_stack.h" | #include "BLI_stack.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| #include "intern/bmesh_operators_private.h" | #include "intern/bmesh_operators_private.h" | ||||
| #include "intern/bmesh_private.h" | #include "intern/bmesh_private.h" | ||||
| static CLG_LogRef LOG = {"bmesh.bmo_subdivide"}; | |||||
| typedef struct SubDParams { | typedef struct SubDParams { | ||||
| int numcuts; | int numcuts; | ||||
| float smooth; | float smooth; | ||||
| int smooth_falloff; | int smooth_falloff; | ||||
| float fractal; | float fractal; | ||||
| float along_normal; | float along_normal; | ||||
| // int beauty; | // int beauty; | ||||
| bool use_smooth; | bool use_smooth; | ||||
| ▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | static void bm_subdivide_multicut( | ||||
| for (i = 0; i < numcuts; i++) { | for (i = 0; i < numcuts; i++) { | ||||
| v = subdivide_edge_num(bm, eed, &e_tmp, i, params->numcuts, params, v_a, v_b, &e_new); | v = subdivide_edge_num(bm, eed, &e_tmp, i, params->numcuts, params, v_a, v_b, &e_new); | ||||
| BMO_vert_flag_enable(bm, v, SUBD_SPLIT | ELE_SPLIT); | BMO_vert_flag_enable(bm, v, SUBD_SPLIT | ELE_SPLIT); | ||||
| BMO_edge_flag_enable(bm, eed, SUBD_SPLIT | ELE_SPLIT); | BMO_edge_flag_enable(bm, eed, SUBD_SPLIT | ELE_SPLIT); | ||||
| BMO_edge_flag_enable(bm, e_new, SUBD_SPLIT | ELE_SPLIT); | BMO_edge_flag_enable(bm, e_new, SUBD_SPLIT | ELE_SPLIT); | ||||
| BM_CHECK_ELEMENT(v); | BM_CHECK_ELEMENT(&LOG, v); | ||||
| if (v->e) { | if (v->e) { | ||||
| BM_CHECK_ELEMENT(v->e); | BM_CHECK_ELEMENT(&LOG, v->e); | ||||
| } | } | ||||
| if (v->e && v->e->l) { | if (v->e && v->e->l) { | ||||
| BM_CHECK_ELEMENT(v->e->l->f); | BM_CHECK_ELEMENT(&LOG, v->e->l->f); | ||||
| } | } | ||||
| } | } | ||||
| alter_co(v1, &e_tmp, params, 0, &v1_tmp, &v2_tmp); | alter_co(v1, &e_tmp, params, 0, &v1_tmp, &v2_tmp); | ||||
| alter_co(v2, &e_tmp, params, 1.0, &v1_tmp, &v2_tmp); | alter_co(v2, &e_tmp, params, 1.0, &v1_tmp, &v2_tmp); | ||||
| } | } | ||||
| /* note: the patterns are rotated as necessary to | /* note: the patterns are rotated as necessary to | ||||
| ▲ Show 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | for (; !BLI_stack_is_empty(facedata); BLI_stack_discard(facedata)) { | ||||
| BLI_array_grow_items(verts, face->len); | BLI_array_grow_items(verts, face->len); | ||||
| BM_ITER_ELEM_INDEX (l_new, &liter, face, BM_LOOPS_OF_FACE, j) { | BM_ITER_ELEM_INDEX (l_new, &liter, face, BM_LOOPS_OF_FACE, j) { | ||||
| b = (j - a + face->len) % face->len; | b = (j - a + face->len) % face->len; | ||||
| verts[b] = l_new->v; | verts[b] = l_new->v; | ||||
| } | } | ||||
| BM_CHECK_ELEMENT(face); | BM_CHECK_ELEMENT(&LOG, face); | ||||
| pat->connectexec(bm, face, verts, ¶ms); | pat->connectexec(bm, face, verts, ¶ms); | ||||
| } | } | ||||
| /* copy original-geometry displacements to current coordinates */ | /* copy original-geometry displacements to current coordinates */ | ||||
| BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { | ||||
| const float *co = BM_ELEM_CD_GET_VOID_P(v, params.shape_info.cd_vert_shape_offset_tmp); | const float *co = BM_ELEM_CD_GET_VOID_P(v, params.shape_info.cd_vert_shape_offset_tmp); | ||||
| copy_v3_v3(v->co, co); | copy_v3_v3(v->co, co); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines | |||||