Explorar o código

OFFLoader: Don't use assignments as expressions

Turo Lamminen %!s(int64=10) %!d(string=hai) anos
pai
achega
fba7ede639
Modificáronse 1 ficheiros con 23 adicións e 10 borrados
  1. 23 10
      code/OFFLoader.cpp

+ 23 - 10
code/OFFLoader.cpp

@@ -138,9 +138,15 @@ void OFFImporter::InternReadFile( const std::string& pFile,
         throw DeadlyImportError("OFF: There are no valid faces");
         throw DeadlyImportError("OFF: There are no valid faces");
     }
     }
 
 
-    pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes = 1 ];
-    aiMesh* mesh = pScene->mMeshes[0] = new aiMesh();
-    aiFace* faces = mesh->mFaces = new aiFace [mesh->mNumFaces = numFaces];
+    pScene->mNumMeshes = 1;
+    pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
+
+    aiMesh* mesh = new aiMesh();
+    pScene->mMeshes[0] = mesh;
+
+    mesh->mNumFaces = numFaces;
+    aiFace* faces = new aiFace [mesh->mNumFaces];
+    mesh->mFaces = faces;
 
 
     std::vector<aiVector3D> tempPositions(numVertices);
     std::vector<aiVector3D> tempPositions(numVertices);
 
 
@@ -171,7 +177,8 @@ void OFFImporter::InternReadFile( const std::string& pFile,
             break;
             break;
         }
         }
         sz = line;SkipSpaces(&sz);
         sz = line;SkipSpaces(&sz);
-        if(!(faces->mNumIndices = strtoul10(sz,&sz)) || faces->mNumIndices > 9)
+        faces->mNumIndices = strtoul10(sz,&sz);
+        if(!(faces->mNumIndices) || faces->mNumIndices > 9)
         {
         {
             DefaultLogger::get()->error("OFF: Faces with zero indices aren't allowed");
             DefaultLogger::get()->error("OFF: Faces with zero indices aren't allowed");
             --mesh->mNumFaces;
             --mesh->mNumFaces;
@@ -185,24 +192,28 @@ void OFFImporter::InternReadFile( const std::string& pFile,
         throw DeadlyImportError("OFF: There are no valid faces");
         throw DeadlyImportError("OFF: There are no valid faces");
 
 
     // allocate storage for the output vertices
     // allocate storage for the output vertices
-    aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
+    aiVector3D* verts = new aiVector3D[mesh->mNumVertices];
+    mesh->mVertices = verts;
 
 
     // second: now parse all face indices
     // second: now parse all face indices
-    buffer = old;faces = mesh->mFaces;
+    buffer = old;
+    faces = mesh->mFaces;
     for (unsigned int i = 0, p = 0; i< mesh->mNumFaces;)
     for (unsigned int i = 0, p = 0; i< mesh->mNumFaces;)
     {
     {
         if(!GetNextLine(buffer,line))break;
         if(!GetNextLine(buffer,line))break;
 
 
         unsigned int idx;
         unsigned int idx;
         sz = line;SkipSpaces(&sz);
         sz = line;SkipSpaces(&sz);
-        if(!(idx = strtoul10(sz,&sz)) || idx > 9)
+        idx = strtoul10(sz,&sz);
+        if(!(idx) || idx > 9)
             continue;
             continue;
 
 
         faces->mIndices = new unsigned int [faces->mNumIndices];
         faces->mIndices = new unsigned int [faces->mNumIndices];
         for (unsigned int m = 0; m < faces->mNumIndices;++m)
         for (unsigned int m = 0; m < faces->mNumIndices;++m)
         {
         {
             SkipSpaces(&sz);
             SkipSpaces(&sz);
-            if ((idx = strtoul10(sz,&sz)) >= numVertices)
+            idx = strtoul10(sz,&sz);
+            if ((idx) >= numVertices)
             {
             {
                 DefaultLogger::get()->error("OFF: Vertex index is out of range");
                 DefaultLogger::get()->error("OFF: Vertex index is out of range");
                 idx = numVertices-1;
                 idx = numVertices-1;
@@ -217,11 +228,13 @@ void OFFImporter::InternReadFile( const std::string& pFile,
     // generate the output node graph
     // generate the output node graph
     pScene->mRootNode = new aiNode();
     pScene->mRootNode = new aiNode();
     pScene->mRootNode->mName.Set("<OFFRoot>");
     pScene->mRootNode->mName.Set("<OFFRoot>");
-    pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes = 1];
+    pScene->mRootNode->mNumMeshes = 1;
+    pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes];
     pScene->mRootNode->mMeshes[0] = 0;
     pScene->mRootNode->mMeshes[0] = 0;
 
 
     // generate a default material
     // generate a default material
-    pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 1];
+    pScene->mNumMaterials = 1;
+    pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
     aiMaterial* pcMat = new aiMaterial();
     aiMaterial* pcMat = new aiMaterial();
 
 
     aiColor4D clr(0.6f,0.6f,0.6f,1.0f);
     aiColor4D clr(0.6f,0.6f,0.6f,1.0f);