diff --git a/code/AssxmlExporter.cpp b/code/AssxmlExporter.cpp index 9e8037649..bcf805501 100644 --- a/code/AssxmlExporter.cpp +++ b/code/AssxmlExporter.cpp @@ -67,6 +67,7 @@ namespace AssxmlExport { // ----------------------------------------------------------------------------------- static int ioprintf( IOStream * io, const char *format, ... ) { + using namespace std; if ( nullptr == io ) { return -1; } @@ -77,7 +78,7 @@ static int ioprintf( IOStream * io, const char *format, ... ) { ::memset( sz, '\0', Size ); va_list va; va_start( va, format ); - int nSize = std::vsnprintf( sz, Size-1, format, va ); + int nSize = vsnprintf( sz, Size-1, format, va ); ai_assert( nSize < Size ); va_end( va ); diff --git a/code/STEPFile.h b/code/STEPFile.h index f97845dd8..252e75dbb 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -596,11 +596,6 @@ namespace STEP { LazyObject(DB& db, uint64_t id, uint64_t line, const char* type,const char* args); ~LazyObject(); - LazyObject( LazyObject const& ) = delete; - LazyObject operator=( LazyObject const& ) = delete; - LazyObject( LazyObject && ) = delete; - LazyObject operator=( LazyObject && ) = delete; - public: Object& operator * () { diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index b56e2e601..5a138f809 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -1211,6 +1211,11 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src) // and reallocate all arrays GetArrayCopy( dest->mMeshes, dest->mNumMeshes ); CopyPtrArray( dest->mChildren, src->mChildren,dest->mNumChildren); + + // need to set the mParent fields to the created aiNode. + for( unsigned int i = 0; i < dest->mNumChildren; i ++ ) { + dest->mChildren[i]->mParent = dest; + } } // ------------------------------------------------------------------------------------------------ diff --git a/code/SplitByBoneCountProcess.cpp b/code/SplitByBoneCountProcess.cpp index 0e913932c..cbc60beec 100644 --- a/code/SplitByBoneCountProcess.cpp +++ b/code/SplitByBoneCountProcess.cpp @@ -90,7 +90,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) // early out bool isNecessary = false; - for( size_t a = 0; a < pScene->mNumMeshes; ++a) + for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount ) isNecessary = true; @@ -107,7 +107,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) // build a new array of meshes for the scene std::vector meshes; - for( size_t a = 0; a < pScene->mNumMeshes; ++a) + for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) { aiMesh* srcMesh = pScene->mMeshes[a]; @@ -118,9 +118,9 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) if( !newMeshes.empty() ) { // store new meshes and indices of the new meshes - for( size_t b = 0; b < newMeshes.size(); ++b) + for( unsigned int b = 0; b < newMeshes.size(); ++b) { - mSubMeshIndices[a].push_back( meshes.size()); + mSubMeshIndices[a].push_back( static_cast(meshes.size())); meshes.push_back( newMeshes[b]); } @@ -130,13 +130,13 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) else { // Mesh is kept unchanged - store it's new place in the mesh array - mSubMeshIndices[a].push_back( meshes.size()); + mSubMeshIndices[a].push_back( static_cast(meshes.size())); meshes.push_back( srcMesh); } } // rebuild the scene's mesh array - pScene->mNumMeshes = meshes.size(); + pScene->mNumMeshes = static_cast(meshes.size()); delete [] pScene->mMeshes; pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; std::copy( meshes.begin(), meshes.end(), pScene->mMeshes); @@ -157,33 +157,33 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector BoneWeight; + typedef std::pair BoneWeight; std::vector< std::vector > vertexBones( pMesh->mNumVertices); - for( size_t a = 0; a < pMesh->mNumBones; ++a) + for( unsigned int a = 0; a < pMesh->mNumBones; ++a) { const aiBone* bone = pMesh->mBones[a]; - for( size_t b = 0; b < bone->mNumWeights; ++b) + for( unsigned int b = 0; b < bone->mNumWeights; ++b) vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); } - size_t numFacesHandled = 0; + unsigned int numFacesHandled = 0; std::vector isFaceHandled( pMesh->mNumFaces, false); while( numFacesHandled < pMesh->mNumFaces ) { // which bones are used in the current submesh - size_t numBones = 0; + unsigned int numBones = 0; std::vector isBoneUsed( pMesh->mNumBones, false); // indices of the faces which are going to go into this submesh - std::vector subMeshFaces; + std::vector subMeshFaces; subMeshFaces.reserve( pMesh->mNumFaces); // accumulated vertex count of all the faces in this submesh - size_t numSubMeshVertices = 0; + unsigned int numSubMeshVertices = 0; // a small local array of new bones for the current face. State of all used bones for that face // can only be updated AFTER the face is completely analysed. Thanks to imre for the fix. - std::vector newBonesAtCurrentFace; + std::vector newBonesAtCurrentFace; // add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit - for( size_t a = 0; a < pMesh->mNumFaces; ++a) + for( unsigned int a = 0; a < pMesh->mNumFaces; ++a) { // skip if the face is already stored in a submesh if( isFaceHandled[a] ) @@ -191,12 +191,12 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormFaces[a]; // check every vertex if its bones would still fit into the current submesh - for( size_t b = 0; b < face.mNumIndices; ++b ) + for( unsigned int b = 0; b < face.mNumIndices; ++b ) { const std::vector& vb = vertexBones[face.mIndices[b]]; - for( size_t c = 0; c < vb.size(); ++c) + for( unsigned int c = 0; c < vb.size(); ++c) { - size_t boneIndex = vb[c].first; + unsigned int boneIndex = vb[c].first; // if the bone is already used in this submesh, it's ok if( isBoneUsed[boneIndex] ) continue; @@ -214,7 +214,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumVertices = numSubMeshVertices; - newMesh->mNumFaces = subMeshFaces.size(); + newMesh->mNumFaces = static_cast(subMeshFaces.size()); newMesh->mVertices = new aiVector3D[newMesh->mNumVertices]; if( pMesh->HasNormals() ) newMesh->mNormals = new aiVector3D[newMesh->mNumVertices]; @@ -251,13 +251,13 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormTangents = new aiVector3D[newMesh->mNumVertices]; newMesh->mBitangents = new aiVector3D[newMesh->mNumVertices]; } - for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) + for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) { if( pMesh->HasTextureCoords( a) ) newMesh->mTextureCoords[a] = new aiVector3D[newMesh->mNumVertices]; newMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a]; } - for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) + for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) { if( pMesh->HasVertexColors( a) ) newMesh->mColors[a] = new aiColor4D[newMesh->mNumVertices]; @@ -265,9 +265,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormFaces = new aiFace[subMeshFaces.size()]; - size_t nvi = 0; // next vertex index - std::vector previousVertexIndices( numSubMeshVertices, std::numeric_limits::max()); // per new vertex: its index in the source mesh - for( size_t a = 0; a < subMeshFaces.size(); ++a ) + unsigned int nvi = 0; // next vertex index + std::vector previousVertexIndices( numSubMeshVertices, std::numeric_limits::max()); // per new vertex: its index in the source mesh + for( unsigned int a = 0; a < subMeshFaces.size(); ++a ) { const aiFace& srcFace = pMesh->mFaces[subMeshFaces[a]]; aiFace& dstFace = newMesh->mFaces[a]; @@ -275,9 +275,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormTangents[nvi] = pMesh->mTangents[srcIndex]; newMesh->mBitangents[nvi] = pMesh->mBitangents[srcIndex]; } - for( size_t c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) + for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) { if( pMesh->HasTextureCoords( c) ) newMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; } - for( size_t c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) + for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) { if( pMesh->HasVertexColors( c) ) newMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex]; @@ -310,8 +310,8 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumBones = 0; newMesh->mBones = new aiBone*[numBones]; - std::vector mappedBoneIndex( pMesh->mNumBones, std::numeric_limits::max()); - for( size_t a = 0; a < pMesh->mNumBones; ++a ) + std::vector mappedBoneIndex( pMesh->mNumBones, std::numeric_limits::max()); + for( unsigned int a = 0; a < pMesh->mNumBones; ++a ) { if( !isBoneUsed[a] ) continue; @@ -329,21 +329,21 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumBones == numBones ); // iterate over all new vertices and count which bones affected its old vertex in the source mesh - for( size_t a = 0; a < numSubMeshVertices; ++a ) + for( unsigned int a = 0; a < numSubMeshVertices; ++a ) { - size_t oldIndex = previousVertexIndices[a]; + unsigned int oldIndex = previousVertexIndices[a]; const std::vector& bonesOnThisVertex = vertexBones[oldIndex]; - for( size_t b = 0; b < bonesOnThisVertex.size(); ++b ) + for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b ) { - size_t newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; - if( newBoneIndex != std::numeric_limits::max() ) + unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; + if( newBoneIndex != std::numeric_limits::max() ) newMesh->mBones[newBoneIndex]->mNumWeights++; } } // allocate all bone weight arrays accordingly - for( size_t a = 0; a < newMesh->mNumBones; ++a ) + for( unsigned int a = 0; a < newMesh->mNumBones; ++a ) { aiBone* bone = newMesh->mBones[a]; ai_assert( bone->mNumWeights > 0 ); @@ -352,18 +352,18 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector& bonesOnThisVertex = vertexBones[previousIndex]; // all of the bones affecting it should be present in the new submesh, or else // the face it comprises shouldn't be present - for( size_t b = 0; b < bonesOnThisVertex.size(); ++b) + for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b) { - size_t newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; - ai_assert( newBoneIndex != std::numeric_limits::max() ); + unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; + ai_assert( newBoneIndex != std::numeric_limits::max() ); aiVertexWeight* dstWeight = newMesh->mBones[newBoneIndex]->mWeights + newMesh->mBones[newBoneIndex]->mNumWeights; newMesh->mBones[newBoneIndex]->mNumWeights++; @@ -383,22 +383,22 @@ void SplitByBoneCountProcess::UpdateNode( aiNode* pNode) const // rebuild the node's mesh index list if( pNode->mNumMeshes > 0 ) { - std::vector newMeshList; - for( size_t a = 0; a < pNode->mNumMeshes; ++a) + std::vector newMeshList; + for( unsigned int a = 0; a < pNode->mNumMeshes; ++a) { - size_t srcIndex = pNode->mMeshes[a]; - const std::vector& replaceMeshes = mSubMeshIndices[srcIndex]; + unsigned int srcIndex = pNode->mMeshes[a]; + const std::vector& replaceMeshes = mSubMeshIndices[srcIndex]; newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end()); } delete pNode->mMeshes; - pNode->mNumMeshes = newMeshList.size(); + pNode->mNumMeshes = static_cast(newMeshList.size()); pNode->mMeshes = new unsigned int[pNode->mNumMeshes]; std::copy( newMeshList.begin(), newMeshList.end(), pNode->mMeshes); } // do that also recursively for all children - for( size_t a = 0; a < pNode->mNumChildren; ++a ) + for( unsigned int a = 0; a < pNode->mNumChildren; ++a ) { UpdateNode( pNode->mChildren[a]); } diff --git a/code/SplitByBoneCountProcess.h b/code/SplitByBoneCountProcess.h index f4816952d..39f47d043 100644 --- a/code/SplitByBoneCountProcess.h +++ b/code/SplitByBoneCountProcess.h @@ -101,7 +101,7 @@ public: size_t mMaxBoneCount; /// Per mesh index: Array of indices of the new submeshes. - std::vector< std::vector > mSubMeshIndices; + std::vector< std::vector > mSubMeshIndices; }; } // end of namespace Assimp diff --git a/code/glTFAsset.h b/code/glTFAsset.h index be3c3e756..c7045a609 100644 --- a/code/glTFAsset.h +++ b/code/glTFAsset.h @@ -759,6 +759,7 @@ namespace glTF virtual void WriteObjects(AssetWriter& writer) = 0; }; + template class LazyDict; @@ -766,6 +767,7 @@ namespace glTF template void WriteLazyDict(LazyDict& d, AssetWriter& w); + //! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID //! It is the owner the loaded objects, so when it is destroyed it also deletes them template diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index 0e51ebd94..0fa8556c0 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -305,7 +305,7 @@ namespace glTF { } - AssetWriter::AssetWriter(Asset& a) + inline AssetWriter::AssetWriter(Asset& a) : mDoc() , mAsset(a) , mAl(mDoc.GetAllocator()) @@ -326,7 +326,7 @@ namespace glTF { } } - void AssetWriter::WriteFile(const char* path) + inline void AssetWriter::WriteFile(const char* path) { bool isBinary = mAsset.extensionsUsed.KHR_binary_glTF; @@ -363,7 +363,7 @@ namespace glTF { } } - void AssetWriter::WriteBinaryData(IOStream* outfile, size_t sceneLength) + inline void AssetWriter::WriteBinaryData(IOStream* outfile, size_t sceneLength) { // // write the body data @@ -413,7 +413,7 @@ namespace glTF { } - void AssetWriter::WriteMetadata() + inline void AssetWriter::WriteMetadata() { Value asset; asset.SetObject(); @@ -425,7 +425,7 @@ namespace glTF { mDoc.AddMember("asset", asset, mAl); } - void AssetWriter::WriteExtensionsUsed() + inline void AssetWriter::WriteExtensionsUsed() { Value exts; exts.SetArray(); diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 222947add..ca606ecdc 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER #include "glTFExporter.h" + #include "Exceptional.h" #include "StringComparison.h" #include "ByteSwapper.h" @@ -54,7 +55,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include #include #include "glTFAssetWriter.h" diff --git a/code/glTFImporter.cpp b/code/glTFImporter.cpp index fa730ddd1..a17076d63 100644 --- a/code/glTFImporter.cpp +++ b/code/glTFImporter.cpp @@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "MakeVerboseFormat.h" #include "glTFAsset.h" +// This is included here so WriteLazyDict's definition is found. +#include "glTFAssetWriter.h" using namespace Assimp; using namespace glTF; diff --git a/test/regression/db.zip b/test/regression/db.zip index 62a76956f..fba468a7b 100644 Binary files a/test/regression/db.zip and b/test/regression/db.zip differ