diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index bd2b04683..32bf95ba7 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "JoinVerticesProcess.h" #include "ProcessHelper.h" #include "Vertex.h" +#include "TinyFormatter.h" using namespace Assimp; // ------------------------------------------------------------------------------------------------ @@ -251,13 +252,17 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } if (!DefaultLogger::isNullLogger() && DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { - char szBuff[128]; // should be sufficiently large in every case - ::sprintf(szBuff,"Mesh %i | Verts in: %i out: %i | ~%.1f%%", - meshIndex, - pMesh->mNumVertices, - (int)uniqueVertices.size(), - ((pMesh->mNumVertices - uniqueVertices.size()) / (float)pMesh->mNumVertices) * 100.f); - DefaultLogger::get()->debug(szBuff); + DefaultLogger::get()->debug((Formatter::format(), + "Mesh ",meshIndex, + " (", + (pMesh->mName.length ? pMesh->mName.data : "unnamed"), + ") | Verts in: ",pMesh->mNumVertices, + " out: ", + uniqueVertices.size(), + " | ~", + ((pMesh->mNumVertices - uniqueVertices.size()) / (float)pMesh->mNumVertices) * 100.f, + "%" + )); } // replace vertex data with the unique data sets diff --git a/code/SortByPTypeProcess.cpp b/code/SortByPTypeProcess.cpp index 30c1b6117..66fb1eb86 100644 --- a/code/SortByPTypeProcess.cpp +++ b/code/SortByPTypeProcess.cpp @@ -221,6 +221,9 @@ void SortByPTypeProcess::Execute( aiScene* pScene) outMeshes.push_back(new aiMesh()); aiMesh* out = outMeshes.back(); + // the name carries the adjacency information between the meshes + out->mName = mesh->mName; + // copy data members out->mPrimitiveTypes = 1u << real; out->mMaterialIndex = mesh->mMaterialIndex; diff --git a/code/SplitLargeMeshes.cpp b/code/SplitLargeMeshes.cpp index b00527128..530434b78 100644 --- a/code/SplitLargeMeshes.cpp +++ b/code/SplitLargeMeshes.cpp @@ -168,6 +168,9 @@ void SplitLargeMeshesProcess_Triangle::SplitMesh( pcMesh->mNumFaces = iOutFaceNum; pcMesh->mMaterialIndex = pMesh->mMaterialIndex; + // the name carries the adjacency information between the meshes + pcMesh->mName = pMesh->mName; + if (i == iSubMeshes-1) { pcMesh->mNumFaces = iOutFaceNum + ( @@ -442,6 +445,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh( pcMesh->mNumVertices = 0; pcMesh->mMaterialIndex = pMesh->mMaterialIndex; + // the name carries the adjacency information between the meshes + pcMesh->mName = pMesh->mName; + typedef std::vector BoneWeightList; if (pMesh->HasBones()) { diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 93d122b5d..c4ad27d8e 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -318,6 +318,8 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh) pMesh->mMaterialIndex,mScene->mNumMaterials-1); } + Validate(&pMesh->mName); + for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) { aiFace& face = pMesh->mFaces[i]; diff --git a/doc/AssimpDoc_Html/AssimpDoc.chm b/doc/AssimpDoc_Html/AssimpDoc.chm index 00fe252b8..ca3932310 100644 Binary files a/doc/AssimpDoc_Html/AssimpDoc.chm and b/doc/AssimpDoc_Html/AssimpDoc.chm differ diff --git a/include/aiMesh.h b/include/aiMesh.h index 4393ab521..14cce69fa 100644 --- a/include/aiMesh.h +++ b/include/aiMesh.h @@ -440,6 +440,19 @@ struct aiMesh */ unsigned int mMaterialIndex; + /** Name of the mesh. Meshes can be named, but this is not a + * requirement and leaving this field empty is totally fine. + * There are mainly three uses for mesh names: + * - some formats name nodes and meshes independently. + * - importers tend to split meshes up to meet the + * one-material-per-mesh requirement. Assigning + * the same (dummy) name to each of the result meshes + * aids the caller at recovering the original mesh + * partitioning. + * - Vertex animations refer to meshes by their names. + **/ + aiString mName; + #ifdef __cplusplus //! Default constructor. Initializes all members to 0