From 397fa374a35000c1babb2307b1c491455365d8ee Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Fri, 18 Mar 2016 17:02:39 -0700 Subject: [PATCH 1/3] Removed usage of Boost static assert. --- code/AssbinExporter.cpp | 11 +++++------ code/AssbinLoader.cpp | 3 +-- code/DefaultIOStream.cpp | 6 +++--- code/JoinVerticesProcess.cpp | 7 +++---- code/LWOMaterial.cpp | 3 +-- code/STEPFile.h | 3 +-- code/SpatialSort.cpp | 5 ++--- tools/assimp_cmd/WriteDumb.cpp | 9 ++++----- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp index 9a70d7166..7df58cd2d 100644 --- a/code/AssbinExporter.cpp +++ b/code/AssbinExporter.cpp @@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/assimp/Exporter.hpp" #include "ProcessHelper.h" #include "Exceptional.h" -#include #ifdef ASSIMP_BUILD_NO_OWN_ZLIB # include @@ -103,7 +102,7 @@ inline size_t Write(IOStream * stream, const unsigned int& w) template <> inline size_t Write(IOStream * stream, const uint16_t& w) { - BOOST_STATIC_ASSERT(sizeof(uint16_t)==2); + static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2"); stream->Write(&w,2,1); return 2; } @@ -113,7 +112,7 @@ inline size_t Write(IOStream * stream, const uint16_t& w) template <> inline size_t Write(IOStream * stream, const float& f) { - BOOST_STATIC_ASSERT(sizeof(float)==4); + static_assert(sizeof(float)==4, "sizeof(float)==4"); stream->Write(&f,4,1); return 4; } @@ -123,7 +122,7 @@ inline size_t Write(IOStream * stream, const float& f) template <> inline size_t Write(IOStream * stream, const double& f) { - BOOST_STATIC_ASSERT(sizeof(double)==8); + static_assert(sizeof(double)==8, "sizeof(double)==8"); stream->Write(&f,8,1); return 8; } @@ -472,7 +471,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) uint32_t tmp = f.mNumIndices; hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); for (unsigned int i = 0; i < f.mNumIndices; ++i) { - BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff); + static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff"); tmp = static_cast( f.mIndices[i] ); hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); } @@ -486,7 +485,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) for (unsigned int i = 0; i < mesh->mNumFaces;++i) { const aiFace& f = mesh->mFaces[i]; - BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); + static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); Write(&chunk,f.mNumIndices); for (unsigned int a = 0; a < f.mNumIndices;++a) { diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp index 509741277..2e8e06f8a 100644 --- a/code/AssbinLoader.cpp +++ b/code/AssbinLoader.cpp @@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/assimp/mesh.h" #include "../include/assimp/anim.h" #include "../include/assimp/scene.h" -#include #ifdef ASSIMP_BUILD_NO_OWN_ZLIB # include @@ -351,7 +350,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) for (unsigned int i = 0; i < mesh->mNumFaces;++i) { aiFace& f = mesh->mFaces[i]; - BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); + static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); f.mNumIndices = Read(stream); f.mIndices = new unsigned int[f.mNumIndices]; diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index a6ca86484..31116e697 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/assimp/ai_assert.h" #include "DefaultIOStream.h" -#include #include #include @@ -86,8 +85,9 @@ aiReturn DefaultIOStream::Seek(size_t pOffset, } // Just to check whether our enum maps one to one with the CRT constants - BOOST_STATIC_ASSERT(aiOrigin_CUR == SEEK_CUR && - aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET); + static_assert(aiOrigin_CUR == SEEK_CUR && + aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET, "aiOrigin_CUR == SEEK_CUR && \ + aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET"); // do the seek return (0 == ::fseek(mFile, (long)pOffset,(int)pOrigin) ? AI_SUCCESS : AI_FAILURE); diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index 7874d97e7..b822b527c 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Vertex.h" #include "TinyFormatter.h" #include -#include using namespace Assimp; // ------------------------------------------------------------------------------------------------ @@ -117,8 +116,8 @@ void JoinVerticesProcess::Execute( aiScene* pScene) // Unites identical vertices in the given mesh int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { - BOOST_STATIC_ASSERT( AI_MAX_NUMBER_OF_COLOR_SETS == 8); - BOOST_STATIC_ASSERT( AI_MAX_NUMBER_OF_TEXTURECOORDS == 8); + static_assert( AI_MAX_NUMBER_OF_COLOR_SETS == 8, "AI_MAX_NUMBER_OF_COLOR_SETS == 8"); + static_assert( AI_MAX_NUMBER_OF_TEXTURECOORDS == 8, "AI_MAX_NUMBER_OF_TEXTURECOORDS == 8"); // Return early if we don't have any positions if (!pMesh->HasPositions() || !pMesh->HasFaces()) { @@ -134,7 +133,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // whether a new vertex was created for the index (true) or if it was replaced by an existing // unique vertex (false). This saves an additional std::vector and greatly enhances // branching performance. - BOOST_STATIC_ASSERT(AI_MAX_VERTICES == 0x7fffffff); + static_assert(AI_MAX_VERTICES == 0x7fffffff, "AI_MAX_VERTICES == 0x7fffffff"); std::vector replaceIndex( pMesh->mNumVertices, 0xffffffff); // A little helper to find locally close vertices faster. diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 7513032ee..b80dae1e8 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "LWOLoader.h" #include "ByteSwapper.h" -#include using namespace Assimp; @@ -160,7 +159,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex trafo.mScaling.x = (*it).wrapAmountW; trafo.mScaling.y = (*it).wrapAmountH; - BOOST_STATIC_ASSERT(sizeof(aiUVTransform)/sizeof(float) == 5); + static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5"); pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur)); } DefaultLogger::get()->debug("LWO2: Setting up non-UV mapping"); diff --git a/code/STEPFile.h b/code/STEPFile.h index d688fc9fd..a0f936889 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_STEPFILE_H #include -#include #include #include #include @@ -722,7 +721,7 @@ namespace STEP { ListOf() { - BOOST_STATIC_ASSERT(min_cnt <= max_cnt || !max_cnt); + static_assert(min_cnt <= max_cnt || !max_cnt, "min_cnt <= max_cnt || !max_cnt"); } }; diff --git a/code/SpatialSort.cpp b/code/SpatialSort.cpp index 3420983f0..2cf179a92 100644 --- a/code/SpatialSort.cpp +++ b/code/SpatialSort.cpp @@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the helper class to quickly find vertices close to a given position */ #include "SpatialSort.h" -#include #include "../include/assimp/ai_assert.h" using namespace Assimp; @@ -192,14 +191,14 @@ namespace { // If this assertion fails, signed int is not big enough to store a float on your platform. // Please correct the declaration of BinFloat a few lines above - but do it in a portable, // #ifdef'd manner! - BOOST_STATIC_ASSERT( sizeof(BinFloat) >= sizeof(float)); + static_assert( sizeof(BinFloat) >= sizeof(float), "sizeof(BinFloat) >= sizeof(float)"); #if defined( _MSC_VER) // If this assertion fails, Visual C++ has finally moved to ILP64. This means that this // code has just become legacy code! Find out the current value of _MSC_VER and modify // the #if above so it evaluates false on the current and all upcoming VC versions (or // on the current platform, if LP64 or LLP64 are still used on other platforms). - BOOST_STATIC_ASSERT( sizeof(BinFloat) == sizeof(float)); + static_assert( sizeof(BinFloat) == sizeof(float), "sizeof(BinFloat) == sizeof(float)"); // This works best on Visual C++, but other compilers have their problems with it. const BinFloat binValue = reinterpret_cast(pValue); diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index 6a8ea3007..12f5bd25a 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -58,7 +58,6 @@ const char* AICMD_MSG_DUMP_HELP = ; #include "../../code/assbin_chunks.h" -#include FILE* out = NULL; bool shortened = false; @@ -151,7 +150,7 @@ inline uint32_t Write(const uint16_t& w) template <> inline uint32_t Write(const float& f) { - BOOST_STATIC_ASSERT(sizeof(float)==4); + static_assert(sizeof(float)==4, "sizeof(float)==4"); fwrite(&f,4,1,out); return 4; } @@ -161,7 +160,7 @@ inline uint32_t Write(const float& f) template <> inline uint32_t Write(const double& f) { - BOOST_STATIC_ASSERT(sizeof(double)==8); + static_assert(sizeof(double)==8, "sizeof(double)==8"); fwrite(&f,8,1,out); return 8; } @@ -424,7 +423,7 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh) uint32_t tmp = f.mNumIndices; hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); for (unsigned int i = 0; i < f.mNumIndices; ++i) { - BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff); + static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff"); tmp = static_cast( f.mIndices[i] ); hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); } @@ -438,7 +437,7 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh) for (unsigned int i = 0; i < mesh->mNumFaces;++i) { const aiFace& f = mesh->mFaces[i]; - BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); + static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); len += Write(f.mNumIndices); for (unsigned int a = 0; a < f.mNumIndices;++a) { From c53903ff0b41955ef253c2ab6ae8503acec54432 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 31 Mar 2016 11:11:55 +0200 Subject: [PATCH 2/3] Update CMakeLists.txt Enable c++11 support for this branch. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 538d2665b..160a1340a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used f # Needed for openddl_parser config, no use of c++11 at this moment add_definitions( -DOPENDDL_NO_USE_CPP11 ) +set_property( GLOBAL PROPERTY CXX_STANDARD 11 ) # Get the current working branch execute_process( From b573676a1b69f8cc16bd644b269134cc754edede Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 31 Mar 2016 11:26:38 +0200 Subject: [PATCH 3/3] Update CMakeLists.txt Enable c++11 support manually by using the compiler flags. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 160a1340a..1b2f12612 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,12 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() # hide all not-exported symbols - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -std=c++0x" ) elseif(MSVC) # enable multi-core compilation with MSVC add_compile_options(/MP) +elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" ) endif() INCLUDE (FindPkgConfig)