Преглед на файлове

- ColladaExporter filters empty meshes which fooled certain loaders - specifically Assimp's Collada Loader :-)
- Bugfix: ColladaExporter now writes proper URLs when referencing materials in meshes

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1170 67173fc5-114c-0410-ac8e-9d2fd5bffc1f

ulfjorensen преди 13 години
родител
ревизия
f41e106efc
променени са 1 файла, в които са добавени 9 реда и са изтрити 2 реда
  1. 9 2
      code/ColladaExporter.cpp

+ 9 - 2
code/ColladaExporter.cpp

@@ -298,6 +298,9 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
 	const aiMesh* mesh = mScene->mMeshes[pIndex];
 	std::string idstr = GetMeshId( pIndex);
 
+  if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
+    return;
+
 	// opening tag
 	mOutput << startstr << "<geometry id=\"" << idstr << "\" name=\"" << idstr << "_name\" >" << endstr;
 	PushTag();
@@ -503,14 +506,18 @@ void ColladaExporter::WriteNode( const aiNode* pNode)
 	// instance every geometry
 	for( size_t a = 0; a < pNode->mNumMeshes; ++a )
 	{
-		// const aiMesh* mesh = mScene->mMeshes[pNode->mMeshes[a]];
+		const aiMesh* mesh = mScene->mMeshes[pNode->mMeshes[a]];
+    // do not instanciate mesh if empty. I wonder how this could happen
+    if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
+      continue;
+
 		mOutput << startstr << "<instance_geometry url=\"#" << GetMeshId( pNode->mMeshes[a]) << "\">" << endstr;
 		PushTag();
     mOutput << startstr << "<bind_material>" << endstr;
     PushTag();
     mOutput << startstr << "<technique_common>" << endstr;
     PushTag();
-    mOutput << startstr << "<instance_material symbol=\"theresonlyone\" target=\"" << materials[mScene->mMeshes[pNode->mMeshes[a]]->mMaterialIndex].name << "\" />" << endstr;
+    mOutput << startstr << "<instance_material symbol=\"theresonlyone\" target=\"#" << materials[mesh->mMaterialIndex].name << "\" />" << endstr;
 		PopTag();
     mOutput << startstr << "</technique_common>" << endstr;
     PopTag();