Merge pull request #764 from rmitton/sib_import

Validation fix for empty SIB scenes.
pull/800/head
Alexander Gessler 2016-02-18 11:58:26 +01:00
commit 38d462f0b3
1 changed files with 15 additions and 15 deletions

View File

@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** @file SIBImporter.cpp /** @file SIBImporter.cpp
* @brief Implementation of the SIB importer class * @brief Implementation of the SIB importer class.
* *
* The Nevercenter Silo SIB format is undocumented. * The Nevercenter Silo SIB format is undocumented.
* All details here have been reverse engineered from * All details here have been reverse engineered from
@ -865,9 +865,9 @@ void SIBImporter::InternReadFile(const std::string& pFile,
pScene->mNumMaterials = sib.mtls.size(); pScene->mNumMaterials = sib.mtls.size();
pScene->mNumMeshes = sib.meshes.size(); pScene->mNumMeshes = sib.meshes.size();
pScene->mNumLights = sib.lights.size(); pScene->mNumLights = sib.lights.size();
pScene->mMaterials = new aiMaterial* [pScene->mNumMaterials]; pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL;
pScene->mMeshes = new aiMesh* [pScene->mNumMeshes]; pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL;
pScene->mLights = new aiLight* [pScene->mNumLights]; pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL;
if (pScene->mNumMaterials) if (pScene->mNumMaterials)
memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials); memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials);
if (pScene->mNumMeshes) if (pScene->mNumMeshes)
@ -880,7 +880,7 @@ void SIBImporter::InternReadFile(const std::string& pFile,
aiNode *root = new aiNode(); aiNode *root = new aiNode();
root->mName.Set("<SIBRoot>"); root->mName.Set("<SIBRoot>");
root->mNumChildren = sib.objs.size() + sib.lights.size(); root->mNumChildren = sib.objs.size() + sib.lights.size();
root->mChildren = new aiNode* [root->mNumChildren]; root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL;
pScene->mRootNode = root; pScene->mRootNode = root;
// Add nodes for each object. // Add nodes for each object.
@ -894,7 +894,7 @@ void SIBImporter::InternReadFile(const std::string& pFile,
node->mTransformation = obj.axis; node->mTransformation = obj.axis;
node->mNumMeshes = obj.meshCount; node->mNumMeshes = obj.meshCount;
node->mMeshes = new unsigned[node->mNumMeshes]; node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL;
for (unsigned i=0;i<node->mNumMeshes;i++) for (unsigned i=0;i<node->mNumMeshes;i++)
node->mMeshes[i] = obj.meshIdx + i; node->mMeshes[i] = obj.meshIdx + i;