diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-28 03:23:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-28 03:23:27 +0300 |
commit | 037876659f473b7a7e14bdd300b7285a22ef095b (patch) | |
tree | 1490da5b73dc772f11a92256e47df2f85159b658 /source/blender/blenkernel/intern/mesh.c | |
parent | 87a95558a0c055dfc5b610641b2c188995fc352c (diff) |
Fix own error removing texface
Setting the name crashed with NULL poly layer.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 215e9ec677b..8c9690b01df 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -581,43 +581,44 @@ bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int ldata = &me->ldata; fdata = &me->fdata; } - cdlp = (poly_index != -1) ? &pdata->layers[poly_index] : NULL; - cdlu = &ldata->layers[loop_index]; - cdlf = fdata && do_tessface ? &fdata->layers[face_index] : NULL; - if (cdlp == NULL && cdlf == NULL) { - return false; - } + cdlu = &ldata->layers[loop_index]; + cdlp = (poly_index != -1) ? &pdata->layers[poly_index] : NULL; + cdlf = (face_index != -1) && fdata && do_tessface ? &fdata->layers[face_index] : NULL; if (cdlu->name != new_name) { /* Mesh validate passes a name from the CD layer as the new name, * Avoid memcpy from self to self in this case. */ BLI_strncpy(cdlu->name, new_name, sizeof(cdlu->name)); - CustomData_set_layer_unique_name(ldata, cdlu - ldata->layers); + CustomData_set_layer_unique_name(ldata, loop_index); + } + + if (cdlp == NULL && cdlf == NULL) { + return false; } /* Loop until we do have exactly the same name for all layers! */ for (i = 1; - (cdlp && !STREQ(cdlp->name, cdlu->name)) || - (cdlf && !STREQ(cdlp->name, cdlf->name)); + (cdlp && !STREQ(cdlu->name, cdlp->name)) || + (cdlf && !STREQ(cdlu->name, cdlf->name)); i++) { switch (i % step) { case 0: if (cdlp) { BLI_strncpy(cdlp->name, cdlu->name, sizeof(cdlp->name)); - CustomData_set_layer_unique_name(pdata, cdlp - pdata->layers); + CustomData_set_layer_unique_name(pdata, poly_index); } break; case 1: BLI_strncpy(cdlu->name, cdlp->name, sizeof(cdlu->name)); - CustomData_set_layer_unique_name(ldata, cdlu - ldata->layers); + CustomData_set_layer_unique_name(ldata, loop_index); break; case 2: if (cdlf) { BLI_strncpy(cdlf->name, cdlu->name, sizeof(cdlf->name)); - CustomData_set_layer_unique_name(fdata, cdlf - fdata->layers); + CustomData_set_layer_unique_name(fdata, face_index); } break; } |