diff --git a/code/BVHLoader.h b/code/BVHLoader.h index 0836488ff..a18ad81d9 100644 --- a/code/BVHLoader.h +++ b/code/BVHLoader.h @@ -84,7 +84,10 @@ class BVHLoader : public BaseImporter std::vector mChannels; std::vector mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames - Node() { } + Node() + : mNode(nullptr) + { } + explicit Node( const aiNode* pNode) : mNode( pNode) { } }; diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp index f653d8d81..0892efd9f 100644 --- a/code/BaseImporter.cpp +++ b/code/BaseImporter.cpp @@ -157,9 +157,6 @@ void BaseImporter::GetExtensionList(std::set& extensions) // read 200 characters from the file std::unique_ptr _buffer (new char[searchBytes+1 /* for the '\0' */]); char* buffer = _buffer.get(); - if( NULL == buffer ) { - return false; - } const size_t read = pStream->Read(buffer,1,searchBytes); if( !read ) { diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp index 7b0064164..7160740c1 100644 --- a/code/CSMLoader.cpp +++ b/code/CSMLoader.cpp @@ -136,7 +136,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, TextFileToBuffer(file.get(),mBuffer2); const char* buffer = &mBuffer2[0]; - aiAnimation* anim = new aiAnimation(); + std::unique_ptr anim(new aiAnimation()); int first = 0, last = 0x00ffffff; // now process the file and look out for '$' sections @@ -294,8 +294,8 @@ void CSMImporter::InternReadFile( const std::string& pFile, // Store the one and only animation in the scene pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations=1]; - pScene->mAnimations[0] = anim; anim->mName.Set("$CSM_MasterAnim"); + pScene->mAnimations[0] = anim.release(); // mark the scene as incomplete and run SkeletonMeshBuilder on it pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; diff --git a/code/LimitBoneWeightsProcess.h b/code/LimitBoneWeightsProcess.h index 2fc6e02b1..090181982 100644 --- a/code/LimitBoneWeightsProcess.h +++ b/code/LimitBoneWeightsProcess.h @@ -120,7 +120,11 @@ public: { unsigned int mBone; ///< Index of the bone float mWeight; ///< Weight of that bone on this vertex - Weight() { } + Weight() + : mBone(0) + , mWeight(0.0f) + { } + Weight( unsigned int pBone, float pWeight) { mBone = pBone; diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 6c569c185..cc5c669e4 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -651,7 +651,8 @@ void PretransformVertices::Execute( aiScene* pScene) // generate mesh nodes for (unsigned int i = 0; i < pScene->mNumMeshes;++i,++nodes) { - aiNode* pcNode = *nodes = new aiNode(); + aiNode* pcNode = new aiNode(); + *nodes = pcNode; pcNode->mParent = pScene->mRootNode; pcNode->mName = pScene->mMeshes[i]->mName; @@ -663,7 +664,8 @@ void PretransformVertices::Execute( aiScene* pScene) // generate light nodes for (unsigned int i = 0; i < pScene->mNumLights;++i,++nodes) { - aiNode* pcNode = *nodes = new aiNode(); + aiNode* pcNode = new aiNode(); + *nodes = pcNode; pcNode->mParent = pScene->mRootNode; pcNode->mName.length = ai_snprintf(pcNode->mName.data, MAXLEN, "light_%u",i); pScene->mLights[i]->mName = pcNode->mName; @@ -671,7 +673,8 @@ void PretransformVertices::Execute( aiScene* pScene) // generate camera nodes for (unsigned int i = 0; i < pScene->mNumCameras;++i,++nodes) { - aiNode* pcNode = *nodes = new aiNode(); + aiNode* pcNode = new aiNode(); + *nodes = pcNode; pcNode->mParent = pScene->mRootNode; pcNode->mName.length = ::ai_snprintf(pcNode->mName.data,MAXLEN,"cam_%u",i); pScene->mCameras[i]->mName = pcNode->mName; diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 1263868bc..9ae8fccc6 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -139,6 +139,11 @@ public: */ Importer(const Importer& other); + // ------------------------------------------------------------------- + /** Assignment operator has been deleted + */ + Importer &operator=(const Importer &) = delete; + // ------------------------------------------------------------------- /** Destructor. The object kept ownership of the imported data, * which now will be destroyed along with the object. diff --git a/include/assimp/anim.h b/include/assimp/anim.h index 9156aac06..1a2c11044 100644 --- a/include/assimp/anim.h +++ b/include/assimp/anim.h @@ -162,7 +162,10 @@ struct aiMeshKey #ifdef __cplusplus - aiMeshKey() { + aiMeshKey() + : mTime(0.0) + , mValue(0) + { } /** Construction from a given time and key value */ diff --git a/include/assimp/matrix3x3.inl b/include/assimp/matrix3x3.inl index aaf62eb0f..ab2cc410b 100644 --- a/include/assimp/matrix3x3.inl +++ b/include/assimp/matrix3x3.inl @@ -313,16 +313,16 @@ inline aiMatrix3x3t& aiMatrix3x3t::FromToMatrix(const aiVector3t(2.0) / (u * u); - const TReal c2 = static_cast(2.0) / (v * v); - const TReal c3 = c1 * c2 * (u * v); + const TReal c1_ = static_cast(2.0) / (u * u); + const TReal c2_ = static_cast(2.0) / (v * v); + const TReal c3_ = c1_ * c2_ * (u * v); for (unsigned int i = 0; i < 3; i++) { for (unsigned int j = 0; j < 3; j++) { - mtx[i][j] = - c1 * u[i] * u[j] - c2 * v[i] * v[j] - + c3 * v[i] * u[j]; + mtx[i][j] = - c1_ * u[i] * u[j] - c2_ * v[i] * v[j] + + c3_ * v[i] * u[j]; } mtx[i][i] += static_cast(1.0); } diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index a532e2b46..5896284f6 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -212,7 +212,10 @@ struct aiVertexWeight #ifdef __cplusplus //! Default constructor - aiVertexWeight() { } + aiVertexWeight() + : mVertexId(0) + , mWeight(0.0f) + { } //! Initialisation from a given index and vertex weight factor //! \param pID ID @@ -270,6 +273,32 @@ struct aiBone } } + + //! Assignment operator + aiBone &operator=(const aiBone& other) + { + if (this == &other) { + return *this; + } + + mName = other.mName; + mNumWeights = other.mNumWeights; + mOffsetMatrix = other.mOffsetMatrix; + + if (other.mWeights && other.mNumWeights) + { + if (mWeights) { + delete[] mWeights; + } + + mWeights = new aiVertexWeight[mNumWeights]; + ::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight)); + } + + return *this; + } + + //! Destructor - deletes the array of vertex weights ~aiBone() { diff --git a/include/assimp/types.h b/include/assimp/types.h index f0d9b2428..9868f657c 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -304,6 +304,20 @@ struct aiString data[len] = 0; } + + /** Assigment operator */ + aiString& operator = (const aiString &rOther) { + if (this == &rOther) { + return *this; + } + + length = rOther.length;; + memcpy( data, rOther.data, length); + data[length] = '\0'; + return *this; + } + + /** Assign a const char* to the string */ aiString& operator = (const char* sz) { Set(sz);