Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-04-29 15:33:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-04-29 16:39:50 +0300
commit6d0cae56e84306ed64a51005c4fb1811a40822b7 (patch)
treede25f4c347865a2aefe7d33b8ab5920d35718254 /source/blender/bmesh/intern/bmesh_mesh_conv.c
parentb5ce2bbef7a91f81c3556f2ddf6dd5f21161bc91 (diff)
Fix T48290: Hook fails after deleting geometry
Now CD_SHAPEKEY_INDEX customdata is stored in edit-mode when hooks and vertex parents are used. This also fixes a bug where undo would loose key-index data. Move to structs for BM_mesh_bm_to/from_me to avoid passing many argument, which mostly aren't used.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_mesh_conv.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index fc26d04690d..7b102c9283b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -224,7 +224,7 @@ static BMFace *bm_face_create_from_mpoly(
*/
void BM_mesh_bm_from_me(
BMesh *bm, Mesh *me,
- const bool calc_face_normal, const bool set_key, int act_key_nr)
+ const struct BMeshFromMeshParams *params)
{
MVert *mvert;
MEdge *medge;
@@ -273,8 +273,8 @@ void BM_mesh_bm_from_me(
CustomData_set_layer_name(&bm->ldata, CD_MLOOPUV, i, bm->pdata.layers[li].name);
}
- if ((act_key_nr != 0) && (me->key != NULL)) {
- actkey = BLI_findlink(&me->key->block, act_key_nr - 1);
+ if ((params->active_shapekey != 0) && (me->key != NULL)) {
+ actkey = BLI_findlink(&me->key->block, params->active_shapekey - 1);
}
else {
actkey = NULL;
@@ -283,9 +283,11 @@ void BM_mesh_bm_from_me(
const int tot_shape_keys = me->key ? BLI_listbase_count(&me->key->block) : 0;
const float (**shape_key_table)[3] = tot_shape_keys ? BLI_array_alloca(shape_key_table, tot_shape_keys) : NULL;
- if (tot_shape_keys) {
+ if (tot_shape_keys || params->add_key_index) {
CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0);
+ }
+ if (tot_shape_keys) {
/* check if we need to generate unique ids for the shapekeys.
* this also exists in the file reading code, but is here for
* a sanity check */
@@ -303,7 +305,7 @@ void BM_mesh_bm_from_me(
if (actkey && actkey->totelem == me->totvert) {
keyco = actkey->data;
- bm->shapenr = act_key_nr;
+ bm->shapenr = params->active_shapekey;
}
for (i = 0, block = me->key->block.first; block; block = block->next, i++) {
@@ -328,10 +330,13 @@ void BM_mesh_bm_from_me(
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
const int cd_shape_key_offset = me->key ? CustomData_get_offset(&bm->vdata, CD_SHAPEKEY) : -1;
- const int cd_shape_keyindex_offset = me->key ? CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX) : -1;
+ const int cd_shape_keyindex_offset = (tot_shape_keys || params->add_key_index) ?
+ CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX) : -1;
for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
- v = vtable[i] = BM_vert_create(bm, keyco && set_key ? keyco[i] : mvert->co, NULL, BM_CREATE_SKIP_CD);
+ v = vtable[i] = BM_vert_create(
+ bm, keyco && params->use_shapekey ? keyco[i] : mvert->co, NULL,
+ BM_CREATE_SKIP_CD);
BM_elem_index_set(v, i); /* set_ok */
/* transfer flag */
@@ -349,11 +354,11 @@ void BM_mesh_bm_from_me(
if (cd_vert_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f);
+ /* set shape key original index */
+ if (cd_shape_keyindex_offset != -1) BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i);
+
/* set shapekey data */
if (tot_shape_keys) {
- /* set shape key original index */
- if (cd_shape_keyindex_offset != -1) BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i);
-
float (*co_dst)[3] = BM_ELEM_CD_GET_VOID_P(v, cd_shape_key_offset);
for (j = 0; j < tot_shape_keys; j++, co_dst++) {
copy_v3_v3(*co_dst, shape_key_table[j][i]);
@@ -436,7 +441,7 @@ void BM_mesh_bm_from_me(
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->pdata, &bm->pdata, i, &f->head.data, true);
- if (calc_face_normal) {
+ if (params->calc_face_normal) {
BM_face_normal_update(f);
}
}
@@ -571,7 +576,9 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
}
}
-void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
+void BM_mesh_bm_to_me(
+ BMesh *bm, Mesh *me,
+ const struct BMeshToMeshParams *params)
{
MLoop *mloop;
MPoly *mpoly;
@@ -632,10 +639,13 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
me->totface = 0;
me->act_face = -1;
- CustomData_copy(&bm->vdata, &me->vdata, CD_MASK_MESH, CD_CALLOC, me->totvert);
- CustomData_copy(&bm->edata, &me->edata, CD_MASK_MESH, CD_CALLOC, me->totedge);
- CustomData_copy(&bm->ldata, &me->ldata, CD_MASK_MESH, CD_CALLOC, me->totloop);
- CustomData_copy(&bm->pdata, &me->pdata, CD_MASK_MESH, CD_CALLOC, me->totpoly);
+ {
+ const CustomDataMask mask = CD_MASK_MESH | params->cd_mask_extra;
+ CustomData_copy(&bm->vdata, &me->vdata, mask, CD_CALLOC, me->totvert);
+ CustomData_copy(&bm->edata, &me->edata, mask, CD_CALLOC, me->totedge);
+ CustomData_copy(&bm->ldata, &me->ldata, mask, CD_CALLOC, me->totloop);
+ CustomData_copy(&bm->pdata, &me->pdata, mask, CD_CALLOC, me->totpoly);
+ }
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, mvert, me->totvert);
CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, me->totedge);
@@ -784,11 +794,11 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
if (vertMap) MEM_freeN(vertMap);
}
- if (do_tessface) {
+ if (params->calc_tessface) {
BKE_mesh_tessface_calc(me);
}
- BKE_mesh_update_customdata_pointers(me, do_tessface);
+ BKE_mesh_update_customdata_pointers(me, params->calc_tessface);
{
BMEditSelection *selected;