fix error where BKE_mesh_cd_validate layer renaming would use invalid index values. from r60260

also correct some comments.
This commit is contained in:
Campbell Barton 2013-09-25 11:11:41 +00:00
parent 8917e63134
commit 3c05662f5e
3 changed files with 8 additions and 5 deletions

@ -1002,6 +1002,7 @@ void BKE_mesh_cd_validate(Mesh *me)
CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, from_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); CustomData_set_layer_unique_name(&me->pdata, totlayer_mtex);
} while (totlayer_uv != ++totlayer_mtex); } while (totlayer_uv != ++totlayer_mtex);
mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
} }
else if (totlayer_uv < totlayer_mtex) { else if (totlayer_uv < totlayer_mtex) {
do { do {
@ -1009,15 +1010,17 @@ void BKE_mesh_cd_validate(Mesh *me)
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, from_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); CustomData_set_layer_unique_name(&me->ldata, totlayer_uv);
} while (totlayer_mtex != ++totlayer_uv); } while (totlayer_mtex != ++totlayer_uv);
uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
} }
BLI_assert(totlayer_mtex == totlayer_uv); BLI_assert(totlayer_mtex == totlayer_uv);
/* Check uv/tex names match as well!!! */ /* Check uv/tex names match as well!!! */
for (i = 0; i < totlayer_mtex; i++, mtex_index++, uv_index++) { for (i = 0; i < totlayer_mtex; i++, mtex_index++, uv_index++) {
const char *name = me->pdata.layers[mtex_index].name; const char *name_src = me->pdata.layers[mtex_index].name;
if (strcmp(name, me->ldata.layers[uv_index].name) != 0) { const char *name_dst = me->ldata.layers[uv_index].name;
BKE_mesh_uv_cdlayer_rename_index(me, mtex_index, uv_index, -1, name, false); if (!STREQ(name_src, name_dst)) {
BKE_mesh_uv_cdlayer_rename_index(me, mtex_index, uv_index, -1, name_src, false);
} }
} }
} }

@ -1114,7 +1114,7 @@ bool isect_point_planes_v3(float (*planes)[4], int totplane, const float p[3])
} }
/** /**
* Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument. * Intersect line/plane.
* *
* \param out The intersection point. * \param out The intersection point.
* \param l1 The first point of the line. * \param l1 The first point of the line.

@ -142,7 +142,7 @@ typedef struct Object {
/* materials */ /* materials */
struct Material **mat; /* material slots */ struct Material **mat; /* material slots */
char *matbits; /* a boolean field, with each byte 1 if corresponding material is linked to object */ char *matbits; /* a boolean field, with each byte 1 if corresponding material is linked to object */
int totcol; /* copy of mesh or curve or meta */ int totcol; /* copy of mesh, curve & meta struct member of same name (keep in sync) */
int actcol; /* currently selected material in the UI */ int actcol; /* currently selected material in the UI */
/* rot en drot have to be together! (transform('r' en 's')) */ /* rot en drot have to be together! (transform('r' en 's')) */