Fix [#28322] COLLADA imports messed up UVs

Reported by Chad Gleason

Imported index order could put mface->v4==0. We already know amount of verts, so use that instead.
This commit is contained in:
Nathan Letwory 2011-09-04 01:13:44 +00:00
parent 1764f2135d
commit cbc812b757

@ -220,8 +220,8 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
if (quad) uvs.getUV(indices[index + 3], mtface->uv[3]); if (quad) uvs.getUV(indices[index + 3], mtface->uv[3]);
#ifdef COLLADA_DEBUG #if 1 // #ifdef COLLADA_DEBUG
/*if (quad) { if (quad) {
fprintf(stderr, "face uv:\n" fprintf(stderr, "face uv:\n"
"((%d, %d, %d, %d))\n" "((%d, %d, %d, %d))\n"
"((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n", "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
@ -248,7 +248,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
mtface->uv[0][0], mtface->uv[0][1], mtface->uv[0][0], mtface->uv[0][1],
mtface->uv[1][0], mtface->uv[1][1], mtface->uv[1][0], mtface->uv[1][1],
mtface->uv[2][0], mtface->uv[2][1]); mtface->uv[2][0], mtface->uv[2][1]);
}*/ }
#endif #endif
} }
@ -587,7 +587,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (k = 0; k < index_list_array.getCount(); k++) { for (k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index // get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k); MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, mface->v4 != 0); set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4);
} }
#endif #endif