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:
authorBastien Montagne <montagne29@wanadoo.fr>2013-09-20 15:14:08 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-09-20 15:14:08 +0400
commit2cca73eeb17abc59d08926b84a81dcf4e085f618 (patch)
treec912cd1b4dfab7df99bd47649ab4d46b9baabff6 /source/blender/blenkernel/intern/mesh_validate.c
parent6ca12765e331a3403f8bf3f6a0c94db99937c790 (diff)
Fix [#36759] UV Project - Specified UV Map doesnt work properly
In fact, the issue was that names of mloopuv/mtespoly layers could very easily get out of sync (a simple rename was enough), while most tools (such as the UVProject modifier) expect matching layers to have the same name! Now matching names are check on load, and renaming of a layer through RNA is guaranted to be synchronized with its counterparts. Thanks to Brecht & Campbell for reviews.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_validate.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 557d201e7fd..891d3080797 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -989,28 +989,37 @@ void BKE_mesh_cd_validate(Mesh *me)
{
int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
+ int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
+ int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
+ int i;
if (LIKELY(totlayer_mtex == totlayer_uv)) {
/* pass */
}
else if (totlayer_mtex < totlayer_uv) {
- const int uv_index_first = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
do {
- const char *from_name = me->ldata.layers[uv_index_first + totlayer_mtex].name;
+ const char *from_name = me->ldata.layers[uv_index + totlayer_mtex].name;
CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, from_name);
CustomData_set_layer_unique_name(&me->pdata, totlayer_mtex);
} while (totlayer_uv != ++totlayer_mtex);
}
else if (totlayer_uv < totlayer_mtex) {
- const int mtex_index_first = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
do {
- const char *from_name = me->pdata.layers[mtex_index_first + totlayer_uv].name;
+ const char *from_name = me->pdata.layers[mtex_index + totlayer_uv].name;
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, from_name);
CustomData_set_layer_unique_name(&me->ldata, totlayer_uv);
} while (totlayer_mtex != ++totlayer_uv);
}
BLI_assert(totlayer_mtex == totlayer_uv);
+
+ /* Check uv/tex names match as well!!! */
+ for (i = 0; i < totlayer_mtex; i++, mtex_index++, uv_index++) {
+ const char *name = me->pdata.layers[mtex_index].name;
+ if (strcmp(name, me->ldata.layers[uv_index].name) != 0) {
+ BKE_mesh_uv_cdlayer_rename_index(me, mtex_index, uv_index, -1, name, false);
+ }
+ }
}
/** \} */