[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32235] trunk/blender/source/blender/ collada/DocumentImporter.cpp: Fix [#21084] Collada messing up geometry on import and renaming uvlayers
Nathan Letwory
nathan at letworyinteractive.com
Fri Oct 1 21:46:42 CEST 2010
Revision: 32235
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32235
Author: jesterking
Date: 2010-10-01 21:46:42 +0200 (Fri, 01 Oct 2010)
Log Message:
-----------
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).
Modified Paths:
--------------
trunk/blender/source/blender/collada/DocumentImporter.cpp
Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp 2010-10-01 17:55:35 UTC (rev 32234)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp 2010-10-01 19:46:42 UTC (rev 32235)
@@ -1620,13 +1620,6 @@
// 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 @@
}
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 @@
#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 @@
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 @@
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;
}
}
More information about the Bf-blender-cvs
mailing list