diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2010-10-01 23:46:42 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2010-10-01 23:46:42 +0400 |
commit | 99ebe229f6c08aceaafbbad8fc1142422ee4c6f3 (patch) | |
tree | 4af70a077f588697186757048161df7b01c4a454 | |
parent | ee84a5b0829b504ac1dbbf1b2405efead3de0be8 (diff) |
Fix [#21084] Collada messing up geometry on import and renaming uvlayers
Reported by Michael Williamson
Add support to write the uvlayer name as found in <bind_vertex_input> semantic attribute (Blender
exports in this one too, so reimport goes ok now).
I have created a patch for OpenCOLLADA to be applied against r769, which is needed
for this fix to work: http://code.google.com/p/opencollada/issues/detail?id=117
The Windows OpenCOLLADA updated builds (r769+patches) will be committed after this.
Note: This means that linux and osx users will have to patch OpenCOLLADA themselves, until
it's committed (or in case of OSX the libs updated in lib/darwinXXX).
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 0e895741fae..0b50326ad6c 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -1620,13 +1620,6 @@ private: // allocate UV layers unsigned int totuvset = mesh->getUVCoords().getInputInfosArray().getCount(); - - // for (i = 0; i < totuvset; i++) { - // if (mesh->getUVCoords().getLength(i) == 0) { - // totuvset = 0; - // break; - // } - // } for (i = 0; i < totuvset; i++) { if (mesh->getUVCoords().getLength(i) == 0) { @@ -1636,7 +1629,8 @@ private: } for (i = 0; i < totuvset; i++) { - CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); + COLLADAFW::MeshVertexData::InputInfos *info = mesh->getUVCoords().getInputInfosArray()[i]; + CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface, info->mName.c_str()); //this->set_layername_map[i] = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i); } @@ -1702,7 +1696,7 @@ private: #else for (k = 0; k < index_list_array.getCount(); k++) { int uvset_index = index_list_array[k]->getSetIndex(); - + // get mtface by face index and uv set index MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index); set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, false); @@ -1906,8 +1900,16 @@ public: Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, MTex *color_texture) { - COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId(); - char *uvname = CustomData_get_layer_name(&me->fdata, CD_MTFACE, ctexture.getSetIndex()); + const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId(); + const size_t setindex = ctexture.getSetIndex(); + std::string uvname = ctexture.getName(); + + const CustomData *data = &me->fdata; + int layer_index = CustomData_get_layer_index(data, CD_MTFACE); + CustomDataLayer *cdl = &data->layers[layer_index+setindex]; + + /* set uvname to bind_vertex_input semantic */ + BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name)); if (texindex_texarray_map.find(texture_index) == texindex_texarray_map.end()) { @@ -1924,7 +1926,7 @@ public: MTex *texture = *it; if (texture) { - strcpy(texture->uvname, uvname); + BLI_strncpy(texture->uvname, uvname.c_str(), sizeof(texture->uvname)); if (texture->mapto == MAP_COL) color_texture = texture; } } |