Browse Source

VS2015-code analysis: fix finding ( index var type too small ).

Kim Kulling 9 years ago
parent
commit
7468ca5c35
2 changed files with 22 additions and 11 deletions
  1. 18 10
      code/OgreStructs.cpp
  2. 4 1
      code/OgreStructs.h

+ 18 - 10
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; i<subMeshes.size(); ++i)
-        if (subMeshes[i]->index == 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; i<dest->mNumMeshes; ++i)
-    {
+    for(size_t i=0; i<dest->mNumMeshes; ++i) {
         dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this);
         dest->mRootNode->mMeshes[i] = i;
     }

+ 4 - 1
code/OgreStructs.h

@@ -568,7 +568,10 @@ typedef std::vector<SubMesh*> 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);