diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-05 07:42:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-05 07:51:50 +0300 |
commit | 4150facd617407d974f2ac8fc2e51562950c59f9 (patch) | |
tree | 53661da63d370ae6f22797d49f93b669e057ed67 /source | |
parent | 5370a7dd40a9e45066e4db1e18ac93636765070f (diff) |
BMesh: add use_shapekey to BMesh transform operators
Currently unused, needed for symmetrize to support shape keys.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_mirror.c | 10 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_symmetrize.c | 9 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_utils.c | 50 |
4 files changed, 66 insertions, 9 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4ce70e7bd5a..d8cdff1a4cc 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -326,6 +326,7 @@ static BMOpDefine bmo_mirror_def = { {"mirror_u", BMO_OP_SLOT_BOOL}, /* mirror UVs across the u axis */ {"mirror_v", BMO_OP_SLOT_BOOL}, /* mirror UVs across the v axis */ {"mirror_udim", BMO_OP_SLOT_BOOL}, /* mirror UVs in each tile */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, /* slots_out */ @@ -758,6 +759,7 @@ static BMOpDefine bmo_rotate_def = { {"matrix", BMO_OP_SLOT_MAT}, /* matrix defining rotation */ {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */ {"space", BMO_OP_SLOT_MAT}, /* matrix to define the space (typically object matrix) */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, {{{'\0'}}}, /* no output */ @@ -776,6 +778,7 @@ static BMOpDefine bmo_translate_def = { {{"vec", BMO_OP_SLOT_VEC}, /* translation offset */ {"space", BMO_OP_SLOT_MAT}, /* matrix to define the space (typically object matrix) */ {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, {{{'\0'}}}, /* no output */ @@ -794,6 +797,7 @@ static BMOpDefine bmo_scale_def = { {{"vec", BMO_OP_SLOT_VEC}, /* scale factor */ {"space", BMO_OP_SLOT_MAT}, /* matrix to define the space (typically object matrix) */ {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, {{{'\0'}}}, /* no output */ @@ -814,6 +818,7 @@ static BMOpDefine bmo_transform_def = { {{"matrix", BMO_OP_SLOT_MAT}, /* transform matrix */ {"space", BMO_OP_SLOT_MAT}, /* matrix to define the space (typically object matrix) */ {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, {{{'\0'}}}, /* no output */ @@ -2072,6 +2077,7 @@ static BMOpDefine bmo_symmetrize_def = { {{"input", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input geometry */ {"direction", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_neg_xyz_and_xyz}, /* axis to use */ {"dist", BMO_OP_SLOT_FLT}, /* minimum distance */ + {"use_shapekey", BMO_OP_SLOT_BOOL}, /* Transform shape keys too. */ {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index c0184a8c4c2..e9820327fe8 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -55,7 +55,15 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) /* feed old data to transform bmo */ scale[axis] = -1.0f; - BMO_op_callf(bm, op->flag, "scale verts=%fv vec=%v space=%s", ELE_NEW, scale, op, "matrix"); + BMO_op_callf(bm, + op->flag, + "scale verts=%fv vec=%v space=%s use_shapekey=%s", + ELE_NEW, + scale, + op, + "matrix", + op, + "use_shapekey"); BMO_op_init(bm, &weldop, op->flag, "weld_verts"); diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c index e0df1c57d98..f5bfd22bd51 100644 --- a/source/blender/bmesh/operators/bmo_symmetrize.c +++ b/source/blender/bmesh/operators/bmo_symmetrize.c @@ -76,7 +76,14 @@ void bmo_symmetrize_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, op_bisect.slots_out, "geom.out", BM_ALL_NOLOOP, ELE_OUT); BMO_slot_buffer_flag_enable(bm, op_dupe.slots_out, "geom.out", BM_ALL_NOLOOP, ELE_OUT); - BMO_op_callf(bm, op->flag, "scale verts=%S vec=%v", &op_dupe, "geom.out", scale); + BMO_op_callf(bm, + op->flag, + "scale verts=%S vec=%v use_shapekey=%s", + &op_dupe, + "geom.out", + scale, + op, + "use_shapekey"); /* important 'flip_multires' is disabled, * otherwise multi-res data will be reversed, see: T47788 */ diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index ffb4af1fe3c..c056302ca0f 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -46,12 +46,17 @@ void bmo_create_vert_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "vert.out", BM_VERT, ELE_NEW); } -void bmo_transform_exec(BMesh *UNUSED(bm), BMOperator *op) +void bmo_transform_exec(BMesh *bm, BMOperator *op) { BMOIter iter; BMVert *v; float mat[4][4], mat_space[4][4], imat_space[4][4]; + const uint shape_keys_len = BMO_slot_bool_get(op->slots_in, "use_shapekey") ? + CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY) : + 0; + const uint cd_shape_key_offset = CustomData_get_offset(&bm->vdata, CD_SHAPEKEY); + BMO_slot_mat4_get(op->slots_in, "matrix", mat); BMO_slot_mat4_get(op->slots_in, "space", mat_space); @@ -62,6 +67,13 @@ void bmo_transform_exec(BMesh *UNUSED(bm), BMOperator *op) BMO_ITER (v, &iter, op->slots_in, "verts", BM_VERT) { mul_m4_v3(mat, v->co); + + if (shape_keys_len != 0) { + float(*co_dst)[3] = BM_ELEM_CD_GET_VOID_P(v, cd_shape_key_offset); + for (int i = 0; i < shape_keys_len; i++, co_dst++) { + mul_m4_v3(mat, *co_dst); + } + } } } @@ -74,8 +86,16 @@ void bmo_translate_exec(BMesh *bm, BMOperator *op) unit_m4(mat); copy_v3_v3(mat[3], vec); - BMO_op_callf( - bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts"); + BMO_op_callf(bm, + op->flag, + "transform matrix=%m4 space=%s verts=%s use_shapekey=%s", + mat, + op, + "space", + op, + "verts", + op, + "use_shapekey"); } void bmo_scale_exec(BMesh *bm, BMOperator *op) @@ -89,8 +109,16 @@ void bmo_scale_exec(BMesh *bm, BMOperator *op) mat[1][1] = vec[1]; mat[2][2] = vec[2]; - BMO_op_callf( - bm, op->flag, "transform matrix=%m3 space=%s verts=%s", mat, op, "space", op, "verts"); + BMO_op_callf(bm, + op->flag, + "transform matrix=%m3 space=%s verts=%s use_shapekey=%s", + mat, + op, + "space", + op, + "verts", + op, + "use_shapekey"); } void bmo_rotate_exec(BMesh *bm, BMOperator *op) @@ -102,8 +130,16 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op) BMO_slot_mat4_get(op->slots_in, "matrix", mat); transform_pivot_set_m4(mat, center); - BMO_op_callf( - bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts"); + BMO_op_callf(bm, + op->flag, + "transform matrix=%m4 space=%s verts=%s use_shapekey=%s", + mat, + op, + "space", + op, + "verts", + op, + "use_shapekey"); } void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op) |