From 3346fb517f0c0de22afa3f01385c6c9757ebbeaa Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 16 Jul 2017 01:02:33 +0200 Subject: [PATCH 1/3] fix compiler warnings. --- code/AssbinExporter.cpp | 47 +++++++++++++------------ code/AssbinLoader.cpp | 76 ++++++++++++++++++++--------------------- 2 files changed, 64 insertions(+), 59 deletions(-) diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp index 4a19147ac..e97f27a8a 100644 --- a/code/AssbinExporter.cpp +++ b/code/AssbinExporter.cpp @@ -350,27 +350,32 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) Write(&chunk, type); switch (type) { - case AI_BOOL: - Write(&chunk, *((bool*) value)); - break; - case AI_INT32: - Write(&chunk, *((int32_t*) value)); - break; - case AI_UINT64: - Write(&chunk, *((uint64_t*) value)); - break; - case AI_FLOAT: - Write(&chunk, *((float*) value)); - break; - case AI_DOUBLE: - Write(&chunk, *((double*) value)); - break; - case AI_AISTRING: - Write(&chunk, *((aiString*) value)); - break; - case AI_AIVECTOR3D: - Write(&chunk, *((aiVector3D*) value)); - break; + case AI_BOOL: + Write(&chunk, *((bool*) value)); + break; + case AI_INT32: + Write(&chunk, *((int32_t*) value)); + break; + case AI_UINT64: + Write(&chunk, *((uint64_t*) value)); + break; + case AI_FLOAT: + Write(&chunk, *((float*) value)); + break; + case AI_DOUBLE: + Write(&chunk, *((double*) value)); + break; + case AI_AISTRING: + Write(&chunk, *((aiString*) value)); + break; + case AI_AIVECTOR3D: + Write(&chunk, *((aiVector3D*) value)); + break; +#ifdef SWIG + case FORCE_32BIT: +#endif // SWIG + default: + break; } } } diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp index 218d8f53a..f418638e1 100644 --- a/code/AssbinLoader.cpp +++ b/code/AssbinLoader.cpp @@ -198,8 +198,7 @@ template void ReadBounds( IOStream * stream, T* /*p*/, unsigned int stream->Seek( sizeof(T) * n, aiOrigin_CUR ); } -void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) -{ +void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) { uint32_t chunkID = Read(stream); ai_assert(chunkID == ASSBIN_CHUNK_AINODE); /*uint32_t size =*/ Read(stream); @@ -212,58 +211,59 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* p (*node)->mNumMeshes = Read(stream); unsigned int nb_metadata = Read(stream); - if(parent) - { + if(parent) { (*node)->mParent = parent; } - if ((*node)->mNumMeshes) - { + if ((*node)->mNumMeshes) { (*node)->mMeshes = new unsigned int[(*node)->mNumMeshes]; for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) { (*node)->mMeshes[i] = Read(stream); } } - if ((*node)->mNumChildren) - { + if ((*node)->mNumChildren) { (*node)->mChildren = new aiNode*[(*node)->mNumChildren]; for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) { ReadBinaryNode( stream, &(*node)->mChildren[i], *node ); } } - if (nb_metadata) - { - (*node)->mMetaData = aiMetadata::Alloc(nb_metadata); - for (unsigned int i = 0; i < nb_metadata; ++i) { - (*node)->mMetaData->mKeys[i] = Read(stream); - (*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read(stream); - void* data = NULL; + if ( nb_metadata > 0 ) { + (*node)->mMetaData = aiMetadata::Alloc(nb_metadata); + for (unsigned int i = 0; i < nb_metadata; ++i) { + (*node)->mMetaData->mKeys[i] = Read(stream); + (*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read(stream); + void* data( nullptr ); - switch ((*node)->mMetaData->mValues[i].mType) { - case AI_BOOL: - data = new bool(Read(stream)); - break; - case AI_INT32: - data = new int32_t(Read(stream)); - break; - case AI_UINT64: - data = new uint64_t(Read(stream)); - break; - case AI_FLOAT: - data = new float(Read(stream)); - break; - case AI_DOUBLE: - data = new double(Read(stream)); - break; - case AI_AISTRING: - data = new aiString(Read(stream)); - break; - case AI_AIVECTOR3D: - data = new aiVector3D(Read(stream)); - break; - } + switch ((*node)->mMetaData->mValues[i].mType) { + case AI_BOOL: + data = new bool(Read(stream)); + break; + case AI_INT32: + data = new int32_t(Read(stream)); + break; + case AI_UINT64: + data = new uint64_t(Read(stream)); + break; + case AI_FLOAT: + data = new float(Read(stream)); + break; + case AI_DOUBLE: + data = new double(Read(stream)); + break; + case AI_AISTRING: + data = new aiString(Read(stream)); + break; + case AI_AIVECTOR3D: + data = new aiVector3D(Read(stream)); + break; +#ifndef SWIG + case FORCE_32BIT: +#endif // SWIG + default: + break; + } (*node)->mMetaData->mValues[i].mData = data; } From 80acc1f24129b17bd1099a9caef278781beeefed Mon Sep 17 00:00:00 2001 From: Madrich Date: Mon, 17 Jul 2017 09:42:26 +0200 Subject: [PATCH 2/3] Fix Collada export image tag Fix compiler double issues --- code/ColladaExporter.cpp | 2 +- code/IFCLoader.cpp | 2 +- code/X3DImporter_Geometry3D.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index d701f905a..745975e5d 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -552,7 +552,7 @@ void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::strin std::stringstream imageUrlEncoded; for( std::string::const_iterator it = pSurface.texture.begin(); it != pSurface.texture.end(); ++it ) { - if( isalnum_C( (unsigned char) *it) || *it == ':' || *it == '_' || *it == '.' || *it == '/' || *it == '\\' ) + if( isalnum_C( (unsigned char) *it) || *it == ':' || *it == '_' || *it == '-' || *it == '.' || *it == '/' || *it == '\\' ) imageUrlEncoded << *it; else imageUrlEncoded << '%' << std::hex << size_t( (unsigned char) *it) << std::dec; diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index 463803ab3..e8632fa9d 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -155,7 +155,7 @@ void IFCImporter::SetupProperties(const Importer* pImp) { settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); - settings.conicSamplingAngle = std::min(std::max(pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE, AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE), 5.0f), 120.0f); + settings.conicSamplingAngle = std::min(std::max((float) pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE, AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE), 5.0f), 120.0f); settings.cylindricalTessellation = std::min(std::max(pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION, AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION), 3), 180); settings.skipAnnotations = true; } diff --git a/code/X3DImporter_Geometry3D.cpp b/code/X3DImporter_Geometry3D.cpp index 721221f5c..b2e9a28f8 100644 --- a/code/X3DImporter_Geometry3D.cpp +++ b/code/X3DImporter_Geometry3D.cpp @@ -949,7 +949,7 @@ void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet() void X3DImporter::ParseNode_Geometry3D_Sphere() { std::string use, def; - float radius = 1; + ai_real radius = 1; bool solid = true; CX3DImporter_NodeElement* ne( nullptr ); From 4361262029b9891e487aa58645f9f06c9b5125a6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 18 Jul 2017 17:02:21 +0200 Subject: [PATCH 3/3] PlyLoader: fix out of bound access. --- code/PlyLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp index 46def8c69..0e99df7a9 100644 --- a/code/PlyLoader.cpp +++ b/code/PlyLoader.cpp @@ -761,7 +761,7 @@ void PLYImporter::LoadFace(const PLY::Element* pcElement, const PLY::ElementInst mGeneratedMesh->mFaces[pos].mIndices = new unsigned int[3]; mGeneratedMesh->mFaces[pos].mIndices[0] = aiTable[0]; mGeneratedMesh->mFaces[pos].mIndices[1] = aiTable[1]; - mGeneratedMesh->mFaces[pos].mIndices[2] = aiTable[2]; + mGeneratedMesh->mFaces[pos].mIndices[2] = p; if ((flip = !flip)) { std::swap(mGeneratedMesh->mFaces[pos].mIndices[0], mGeneratedMesh->mFaces[pos].mIndices[1]);