From ae2cce0899db7c97b684a35e0f78e60168e23658 Mon Sep 17 00:00:00 2001 From: rmitton Date: Sat, 23 Jan 2016 15:22:48 -0800 Subject: [PATCH 1/4] Validation fix for empty scenes. The validator requires empty scenes to have NULL pointers. --- code/SIBImporter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index bfb093512..880391fb5 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -860,9 +860,9 @@ void SIBImporter::InternReadFile(const std::string& pFile, pScene->mNumMaterials = sib.mtls.size(); pScene->mNumMeshes = sib.meshes.size(); pScene->mNumLights = sib.lights.size(); - pScene->mMaterials = new aiMaterial* [pScene->mNumMaterials]; - pScene->mMeshes = new aiMesh* [pScene->mNumMeshes]; - pScene->mLights = new aiLight* [pScene->mNumLights]; + pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : 0; + pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : 0; + pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : 0; if (pScene->mNumMaterials) memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials); if (pScene->mNumMeshes) @@ -875,7 +875,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, aiNode *root = new aiNode(); root->mName.Set(""); root->mNumChildren = sib.objs.size() + sib.lights.size(); - root->mChildren = new aiNode* [root->mNumChildren]; + root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : 0; pScene->mRootNode = root; // Add nodes for each object. @@ -889,7 +889,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, node->mTransformation = obj.axis; node->mNumMeshes = obj.meshCount; - node->mMeshes = new unsigned[node->mNumMeshes]; + node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : 0; for (unsigned i=0;imNumMeshes;i++) node->mMeshes[i] = obj.meshIdx + i; From 94a35dfdd26dfd29a164ebc2e707a998cf50fef2 Mon Sep 17 00:00:00 2001 From: rmitton Date: Mon, 25 Jan 2016 13:42:30 -0800 Subject: [PATCH 2/4] Fixed NULL pointers to match coding standards. --- code/SIBImporter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index 880391fb5..a25b96698 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -860,9 +860,9 @@ void SIBImporter::InternReadFile(const std::string& pFile, pScene->mNumMaterials = sib.mtls.size(); pScene->mNumMeshes = sib.meshes.size(); pScene->mNumLights = sib.lights.size(); - pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : 0; - pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : 0; - pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : 0; + pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL; + pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL; + pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL; if (pScene->mNumMaterials) memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials); if (pScene->mNumMeshes) @@ -875,7 +875,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, aiNode *root = new aiNode(); root->mName.Set(""); root->mNumChildren = sib.objs.size() + sib.lights.size(); - root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : 0; + root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL; pScene->mRootNode = root; // Add nodes for each object. @@ -889,7 +889,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, node->mTransformation = obj.axis; node->mNumMeshes = obj.meshCount; - node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : 0; + node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL; for (unsigned i=0;imNumMeshes;i++) node->mMeshes[i] = obj.meshIdx + i; From f23285a1cecee28c73bcaf685040fec7f6138451 Mon Sep 17 00:00:00 2001 From: rmitton Date: Mon, 25 Jan 2016 13:45:08 -0800 Subject: [PATCH 3/4] Fixed whitespace to match coding standard. --- code/SIBImporter.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index a25b96698..8fce2234e 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -512,7 +512,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) aiString name; while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); @@ -720,7 +720,7 @@ static void ReadLight(SIB* sib, StreamReaderLE* stream) aiLight* light = new aiLight(); while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); @@ -768,18 +768,18 @@ static void ReadInstance(SIB* sib, StreamReaderLE* stream) uint32_t shapeIndex = 0; while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); switch (chunk.Tag) { - case TAG('D','I','N','F'): break; // display info, not needed - case TAG('P','I','N','F'): break; // ? + case TAG('D','I','N','F'): break; // display info, not needed + case TAG('P','I','N','F'): break; // ? case TAG('A','X','I','S'): ReadAxis(inst.axis, stream); break; - case TAG('I','N','S','I'): shapeIndex = stream->GetU4(); break; - case TAG('S','M','T','X'): ReadScale(inst.axis, stream); break; - case TAG('S','N','A','M'): inst.name = ReadString(stream, chunk.Size/2); break; + case TAG('I','N','S','I'): shapeIndex = stream->GetU4(); break; + case TAG('S','M','T','X'): ReadScale(inst.axis, stream); break; + case TAG('S','N','A','M'): inst.name = ReadString(stream, chunk.Size/2); break; default: UnknownChunk(stream, chunk); break; } @@ -808,7 +808,7 @@ static void ReadScene(SIB* sib, StreamReaderLE* stream) { // Parse each chunk in turn. while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); @@ -860,9 +860,9 @@ void SIBImporter::InternReadFile(const std::string& pFile, pScene->mNumMaterials = sib.mtls.size(); pScene->mNumMeshes = sib.meshes.size(); pScene->mNumLights = sib.lights.size(); - pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL; - pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL; - pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL; + pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL; + pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL; + pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL; if (pScene->mNumMaterials) memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials); if (pScene->mNumMeshes) @@ -875,7 +875,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, aiNode *root = new aiNode(); root->mName.Set(""); root->mNumChildren = sib.objs.size() + sib.lights.size(); - root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL; + root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL; pScene->mRootNode = root; // Add nodes for each object. @@ -889,7 +889,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, node->mTransformation = obj.axis; node->mNumMeshes = obj.meshCount; - node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL; + node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL; for (unsigned i=0;imNumMeshes;i++) node->mMeshes[i] = obj.meshIdx + i; From 72b5ed50e933c521a02fee1cf46cfff3e02e3cb3 Mon Sep 17 00:00:00 2001 From: rmitton Date: Sun, 7 Feb 2016 13:21:58 -0800 Subject: [PATCH 4/4] Bump just to get AppVeyor to re-test it. --- code/SIBImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index 8fce2234e..1b3602124 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file SIBImporter.cpp - * @brief Implementation of the SIB importer class + * @brief Implementation of the SIB importer class. * * The Nevercenter Silo SIB format is undocumented. * All details here have been reverse engineered from