diff --git a/code/OgreStructs.cpp b/code/OgreStructs.cpp index 62c109ad3..566c51e0f 100644 --- a/code/OgreStructs.cpp +++ b/code/OgreStructs.cpp @@ -407,10 +407,13 @@ size_t IndexData::FaceSize() const // Mesh -Mesh::Mesh() : - hasSkeletalAnimations(false), - skeleton(NULL), - sharedVertexData(NULL) +Mesh::Mesh() + : hasSkeletalAnimations(false) + , skeleton(NULL) + , sharedVertexData(NULL) + , subMeshes() + , animations() + , poses() { } @@ -443,16 +446,22 @@ size_t Mesh::NumSubMeshes() const return subMeshes.size(); } -SubMesh *Mesh::GetSubMesh(uint16_t index) const +SubMesh *Mesh::GetSubMesh( size_t index ) const { - for(size_t i=0; iindex == index) - return subMeshes[i]; + for ( size_t i = 0; i < subMeshes.size(); ++i ) { + if ( subMeshes[ i ]->index == index ) { + return subMeshes[ i ]; + } + } return 0; } void Mesh::ConvertToAssimpScene(aiScene* dest) { + if ( nullptr == dest ) { + return; + } + // Setup dest->mNumMeshes = NumSubMeshes(); dest->mMeshes = new aiMesh*[dest->mNumMeshes]; @@ -463,8 +472,7 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) dest->mRootNode->mMeshes = new unsigned int[dest->mRootNode->mNumMeshes]; // Export meshes - for(size_t i=0; imNumMeshes; ++i) - { + for(size_t i=0; imNumMeshes; ++i) { dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this); dest->mRootNode->mMeshes[i] = i; } diff --git a/code/OgreStructs.h b/code/OgreStructs.h index dff6226aa..430ba672d 100644 --- a/code/OgreStructs.h +++ b/code/OgreStructs.h @@ -568,7 +568,10 @@ typedef std::vector SubMeshList; class Mesh { public: + /// Constructor. Mesh(); + + /// Destructor. ~Mesh(); /// Releases all memory that this data structure owns. @@ -578,7 +581,7 @@ public: size_t NumSubMeshes() const; /// Returns submesh for @c index. - SubMesh *GetSubMesh(uint16_t index) const; + SubMesh *GetSubMesh( size_t index) const; /// Convert mesh to Assimp scene. void ConvertToAssimpScene(aiScene* dest);