From ad133a05ec3640fcd23ce6bbdde1aac1b101e823 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 3 Aug 2016 10:20:03 +0200 Subject: [PATCH 01/13] CMake: remove dead code. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a9b45fdf..1ba477f38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,6 @@ ENDIF(ASSIMP_DOUBLE_PRECISION) configure_file( ${CMAKE_CURRENT_LIST_DIR}/revision.h.in -# ${CMAKE_CURRENT_SOURCE_DIR}/revision.h.in ${CMAKE_CURRENT_BINARY_DIR}/revision.h ) From a98e524fe2a73cbcd4b09437120fdde5fd663daa Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Fri, 5 Aug 2016 19:54:58 +0100 Subject: [PATCH 02/13] dox_cmd.h: fix typo 'dumb' --> 'dump' --- doc/dox_cmd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/dox_cmd.h b/doc/dox_cmd.h index bc2320e1e..66c156edc 100644 --- a/doc/dox_cmd.h +++ b/doc/dox_cmd.h @@ -211,14 +211,14 @@ the dump is written to <model>-dump.txt

-b

-Optional. If this switch is specified, the dumb is written in binary format. +Optional. If this switch is specified, the dump is written in binary format. The long form of this parameter is --binary.

-s<n>

-Optional. If this switch is specified, the dumb is shortened to include only +Optional. If this switch is specified, the dump is shortened to include only min/max values for all vertex components and animation channels. The resulting file is much smaller, but the original model can't be reconstructed from it. This is used by Assimp's regression test suite, comparing those minidumps provides From a9ebac6b543c148d87cdae42b4a69718c817d2c5 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Mon, 8 Aug 2016 11:46:41 +0100 Subject: [PATCH 03/13] fix long option name for --om to match the actual code in tools/assimp_cmd/Main.cpp --- doc/dox_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dox_cmd.h b/doc/dox_cmd.h index 66c156edc..5bc1b7a9d 100644 --- a/doc/dox_cmd.h +++ b/doc/dox_cmd.h @@ -489,7 +489,7 @@ more information can be found in the aiPostProcess.h header. -om - --optimize-mesh + --optimize-meshes Optimize mesh usage. Meshes are merged, if possible. Very effective in combination with --optimize-graph From e7ed352078d5415a1472b39c93378472003f2597 Mon Sep 17 00:00:00 2001 From: nyorain Date: Tue, 9 Aug 2016 00:50:48 +0200 Subject: [PATCH 04/13] Added documentation for embedded textures --- include/assimp/material.h | 56 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/include/assimp/material.h b/include/assimp/material.h index 4fb20edd5..9eb76a80f 100644 --- a/include/assimp/material.h +++ b/include/assimp/material.h @@ -714,30 +714,33 @@ public: // ------------------------------------------------------------------- /** Helper function to get all parameters pertaining to a * particular texture slot from a material. - * - * This function is provided just for convenience, you could also - * read the single material properties manually. - * @param type Specifies the type of the texture to be retrieved ( - * e.g. diffuse, specular, height map ...) - * @param index Index of the texture to be retrieved. The function fails - * if there is no texture of that type with this index. - * #GetTextureCount() can be used to determine the number of textures - * per texture type. - * @param path Receives the path to the texture. - * NULL is a valid value. - * @param mapping The texture mapping. - * NULL is allowed as value. - * @param uvindex Receives the UV index of the texture. - * NULL is a valid value. - * @param blend Receives the blend factor for the texture - * NULL is a valid value. - * @param op Receives the texture operation to be performed between - * this texture and the previous texture. NULL is allowed as value. - * @param mapmode Receives the mapping modes to be used for the texture. - * The parameter may be NULL but if it is a valid pointer it MUST - * point to an array of 3 aiTextureMapMode's (one for each - * axis: UVW order (=XYZ)). - */ + * + * This function is provided just for convenience, you could also + * read the single material properties manually. + * @param type Specifies the type of the texture to be retrieved ( + * e.g. diffuse, specular, height map ...) + * @param index Index of the texture to be retrieved. The function fails + * if there is no texture of that type with this index. + * #GetTextureCount() can be used to determine the number of textures + * per texture type. + * @param path Receives the path to the texture. + * If the texture is embedded, receives a '*' followed by the id of + * the texture (for the textures stored in the corresponding scene) which + * can be converted to an int using a function like atoi. + * NULL is a valid value. + * @param mapping The texture mapping. + * NULL is allowed as value. + * @param uvindex Receives the UV index of the texture. + * NULL is a valid value. + * @param blend Receives the blend factor for the texture + * NULL is a valid value. + * @param op Receives the texture operation to be performed between + * this texture and the previous texture. NULL is allowed as value. + * @param mapmode Receives the mapping modes to be used for the texture. + * The parameter may be NULL but if it is a valid pointer it MUST + * point to an array of 3 aiTextureMapMode's (one for each + * axis: UVW order (=XYZ)). + */ // ------------------------------------------------------------------- aiReturn GetTexture(aiTextureType type, unsigned int index, @@ -1506,7 +1509,10 @@ ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMa * #aiGetMaterialTextureCount() can be used to determine the number of * textures in a particular texture stack. * @param[out] path Receives the output path - * This parameter must be non-null. + * If the texture is embedded, receives a '*' followed by the id of + * the texture (for the textures stored in the corresponding scene) which + * can be converted to an int using a function like atoi. + * This parameter must be non-null. * @param mapping The texture mapping mode to be used. * Pass NULL if you're not interested in this information. * @param[out] uvindex For UV-mapped textures: receives the index of the UV From 8ba10cf26aaec98aea9c1dd74cfbcfd9f430cb9e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 9 Aug 2016 13:42:33 +0200 Subject: [PATCH 05/13] Closes https://github.com/assimp/assimp/issues/966: add missing doc for assimp_cmd. --- doc/dox_cmd.h | 41 +++++++++++++++++++++++++++------ tools/assimp_cmd/Main.cpp | 1 - tools/assimp_view/assimp_view.h | 8 ------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/doc/dox_cmd.h b/doc/dox_cmd.h index 5bc1b7a9d..e740886a1 100644 --- a/doc/dox_cmd.h +++ b/doc/dox_cmd.h @@ -368,7 +368,6 @@ of all supported steps along with short descriptions of what they're doing.
more information can be found in the aiPostProcess.h header. - @@ -432,13 +431,13 @@ more information can be found in the aiPostProcess.h header. - + - + @@ -479,19 +478,47 @@ more information can be found in the aiPostProcess.h header. - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter Long parameterImprove the cache locality of the vertex buffer by reordering the index buffer to achieve a lower ACMR (average post-transform vertex cache miss ratio)
-sbpt --sort-by-ptype Splits meshes which consist of more than one kind of primitives (e.g. lines and triangles mixed up) in 'clean' submeshes.
-lh --convert-to-lh Converts the imported data to left-handed coordinate spaceSearch the data structure for instanced meshes and replace them by references. This can reduce vertex/face counts but the postprocessing-step takes some time.
-og --optimize-graph Simplify and optimize the scenegraph. Use it with care, all hierarchy information could be lost. Animations remain untouched.
-om --optimize-meshes Optimize mesh usage. Meshes are merged, if possible. Very effective in combination with --optimize-graph
-tuv--transform-uv-coordsWill transform uv-coordinates if possible.
-guv--gen-uvcoordsWill generate uv-coordinates for textures if possible.
-fid--find-invalid-dataWill look for invalid data in the imported model structure.
-fixn--fix normalsImported normal vector will be fixed.
-db--deboneRemoves nearly losslessly or according to a configured threshold bones from the model.
-sbc--split-by-bone-countSplit meshes with too many bones. Necessary for our (limited) hardware skinning shader.
For convenience some default postprocessing configurations are provided. diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index cb6f32834..9c5368bf5 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -378,7 +378,6 @@ int ProcessStandardArguments( // -fixn --fix normals // -tri --triangulate // -fi --find-instances - // -fi --find-instances // -og --optimize-graph // -om --optimize-meshes // -db --debone diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h index 7676b57f9..6300c1a87 100644 --- a/tools/assimp_view/assimp_view.h +++ b/tools/assimp_view/assimp_view.h @@ -71,14 +71,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../code/MaterialSystem.h" // aiMaterial class #include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp -// in order for std::min and std::max to behave properly -/*#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif // max -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif // min -*/ #include // default movement speed From bdcff35d5d9d52f9b4b3d228e3087e6c01effdae Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 12 Aug 2016 17:13:18 +0200 Subject: [PATCH 06/13] closes https://github.com/assimp/assimp/issues/901 --- code/DefaultIOStream.cpp | 7 +++++-- code/DefaultIOStream.h | 8 ++++---- test/unit/utDefaultIOStream.cpp | 18 +++++++++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index f1809d894..73bfb35c4 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -55,6 +55,7 @@ DefaultIOStream::~DefaultIOStream() { if (mFile) { ::fclose(mFile); + mFile = nullptr; } } @@ -111,7 +112,7 @@ size_t DefaultIOStream::FileSize() const if (SIZE_MAX == cachedSize) { - // Although fseek/ftell would allow us to reuse the exising file handle here, + // Although fseek/ftell would allow us to reuse the existing file handle here, // it is generally unsafe because: // - For binary streams, it is not technically well-defined // - For text files the results are meaningless @@ -125,12 +126,14 @@ size_t DefaultIOStream::FileSize() const if (0 != err) return 0; cachedSize = (size_t) (fileStat.st_size); -#else +#elif defined __gnu_linux__ struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat ); if (0 != err) return 0; cachedSize = (size_t) (fileStat.st_size); +#else +# error "Unknown platform" #endif } return cachedSize; diff --git a/code/DefaultIOStream.h b/code/DefaultIOStream.h index 7d7450c6e..779858839 100644 --- a/code/DefaultIOStream.h +++ b/code/DefaultIOStream.h @@ -59,11 +59,11 @@ class ASSIMP_API DefaultIOStream : public IOStream { friend class DefaultIOSystem; #if __ANDROID__ -#if __ANDROID_API__ > 9 -#if defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) +# if __ANDROID_API__ > 9 +# if defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) friend class AndroidJNIIOSystem; -#endif // defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) -#endif // __ANDROID_API__ > 9 +# endif // defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) +# endif // __ANDROID_API__ > 9 #endif // __ANDROID__ protected: diff --git a/test/unit/utDefaultIOStream.cpp b/test/unit/utDefaultIOStream.cpp index a4461ea5f..7d3c07f20 100644 --- a/test/unit/utDefaultIOStream.cpp +++ b/test/unit/utDefaultIOStream.cpp @@ -48,7 +48,12 @@ class utDefaultIOStream : public ::testing::Test { class TestDefaultIOStream : public DefaultIOStream { public: TestDefaultIOStream() - : DefaultIOStream() { + : DefaultIOStream() { + // empty + } + + TestDefaultIOStream( FILE* pFile, const std::string &strFilename ) + : DefaultIOStream( pFile, strFilename ) { // empty } @@ -58,7 +63,14 @@ public: }; TEST_F( utDefaultIOStream, FileSizeTest ) { - TestDefaultIOStream myStream; + char buffer[ L_tmpnam ]; + tmpnam( buffer ); + std::FILE *fs( std::fopen( buffer, "w+" ) ); + size_t written( std::fwrite( buffer, 1, sizeof( char ) * L_tmpnam, fs ) ); + std::fflush( fs ); + + TestDefaultIOStream myStream( fs, buffer ); size_t size = myStream.FileSize(); - EXPECT_EQ( size, 0 ); + EXPECT_EQ( size, sizeof( char ) * L_tmpnam ); + remove( buffer ); } From 83b02ff41f07a656a526063d1caebc2eee913f5d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 12 Aug 2016 18:14:26 +0200 Subject: [PATCH 07/13] DefaultIOStream: add missing detection for apple-based OS. --- code/DefaultIOStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index 73bfb35c4..d10c303d8 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -126,7 +126,7 @@ size_t DefaultIOStream::FileSize() const if (0 != err) return 0; cachedSize = (size_t) (fileStat.st_size); -#elif defined __gnu_linux__ +#elif defined __gnu_linux__ || defined __APPLE__ || defined __MACH__ struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat ); if (0 != err) From 0379675fcad819ad1ca027f485de420a37d40e7a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 12 Aug 2016 18:47:37 +0200 Subject: [PATCH 08/13] Add type to deal with 64-bit filesizes on x86_64-apple-darwin15.5.0x86_64-apple-darwin15.5.0 --- code/DefaultIOStream.cpp | 9 +++++---- code/DefaultIOStream.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index d10c303d8..e9da3ff70 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -110,7 +110,7 @@ size_t DefaultIOStream::FileSize() const return 0; } - if (SIZE_MAX == cachedSize) { + if (SIZE_MAX == mCachedSize ) { // Although fseek/ftell would allow us to reuse the existing file handle here, // it is generally unsafe because: @@ -125,18 +125,19 @@ size_t DefaultIOStream::FileSize() const int err = _stat64( mFilename.c_str(), &fileStat ); if (0 != err) return 0; - cachedSize = (size_t) (fileStat.st_size); + mCachedSize = (size_t) (fileStat.st_size); #elif defined __gnu_linux__ || defined __APPLE__ || defined __MACH__ struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat ); if (0 != err) return 0; - cachedSize = (size_t) (fileStat.st_size); + const unsigned long long cachedSize = fileStat.st_size; + mCachedSize = static_cast< size_t >( cachedSize ); #else # error "Unknown platform" #endif } - return cachedSize; + return mCachedSize; } // ---------------------------------------------------------------------------------- diff --git a/code/DefaultIOStream.h b/code/DefaultIOStream.h index 779858839..83bd3a9d4 100644 --- a/code/DefaultIOStream.h +++ b/code/DefaultIOStream.h @@ -111,7 +111,7 @@ private: std::string mFilename; // Cached file size - mutable size_t cachedSize; + mutable size_t mCachedSize; }; @@ -119,7 +119,7 @@ private: inline DefaultIOStream::DefaultIOStream () : mFile (NULL), mFilename (""), - cachedSize (SIZE_MAX) + mCachedSize(SIZE_MAX) { // empty } @@ -130,7 +130,7 @@ inline DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) : mFile(pFile), mFilename(strFilename), - cachedSize (SIZE_MAX) + mCachedSize(SIZE_MAX) { // empty } From d586aab53bde5314a7003b38110b301d9f19231f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 12 Aug 2016 19:44:07 +0200 Subject: [PATCH 09/13] Update Readme.md fix link to chat channel. IRC is obsolete now. --- Readme.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index e75e9eca1..d91f290fa 100644 --- a/Readme.md +++ b/Readme.md @@ -14,7 +14,6 @@ Coverity Coverity Scan Build Status -Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
__[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.__ @@ -117,8 +116,7 @@ For development discussions, there is also a (very low-volume) mailing list, _as Open Asset Import Library is a library to load various 3d file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export. -And we also have an IRC-channel at freenode: #assetimporterlib . You can easily join us via: [KiwiIRC/freenote](https://kiwiirc.com/client/irc.freenode.net), choose your nickname and type -> /join #assetimporterlib +And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
### Contributing ### Contributions to assimp are highly appreciated. The easiest way to get involved is to submit From eb82a800cb75cd7df90a4a1f1ecaa2aa3a0d70cd Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 13 Aug 2016 09:13:22 +0200 Subject: [PATCH 10/13] CMakeLists: cleanup, move all options to one place for mantenace. --- CMakeLists.txt | 85 ++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ba477f38..f5f4a0297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,50 @@ SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required cmake_minimum_required( VERSION 2.8 ) PROJECT( Assimp ) -OPTION(BUILD_SHARED_LIBS "Build package with shared libraries." ON) +# All supported options ############################################### +OPTION( BUILD_SHARED_LIBS + "Build package with shared libraries." + ON +) +OPTION( ASSIMP_DOUBLE_PRECISION + "Set to ON to enable double precision processing" + OFF +) +OPTION( ASSIMP_OPT_BUILD_PACKAGES + "Set to ON to generate CPack configuration files and packaging targets" + OFF +) +OPTION( ASSIMP_ANDROID_JNIIOSYSTEM + "Android JNI IOSystem support is active" + OFF +) +OPTION( ASSIMP_NO_EXPORT + "Disable Assimp's export functionality." + OFF +) +OPTION( ASSIMP_BUILD_ZLIB + "Build your own zlib" + OFF +) +option( ASSIMP_BUILD_ASSIMP_TOOLS + "If the supplementary tools for Assimp are built in addition to the library." + ON +) +option ( ASSIMP_BUILD_SAMPLES + "If the official samples are built as well (needs Glut)." + OFF +) +OPTION ( ASSIMP_BUILD_TESTS + "If the test suite for Assimp is built in addition to the library." + ON +) +IF(MSVC) + OPTION( ASSIMP_INSTALL_PDB + "Install MSVC debug files." + ON + ) +ENDIF(MSVC) + IF(NOT BUILD_SHARED_LIBS) SET(LINK_SEARCH_START_STATIC TRUE) ENDIF(NOT BUILD_SHARED_LIBS) @@ -80,11 +123,6 @@ IF(NOT GIT_COMMIT_HASH) SET(GIT_COMMIT_HASH 0) ENDIF(NOT GIT_COMMIT_HASH) -OPTION(ASSIMP_DOUBLE_PRECISION - "Set to ON to enable double precision processing" - OFF -) - IF(ASSIMP_DOUBLE_PRECISION) ADD_DEFINITIONS(-DAI_DOUBLE_PRECISION) ENDIF(ASSIMP_DOUBLE_PRECISION) @@ -105,15 +143,12 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) -OPTION(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF) SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" ) SET(LIBASSIMP_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}" ) SET(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}-dev" ) SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev) SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names") -OPTION(ASSIMP_ANDROID_JNIIOSYSTEM "Android JNI IOSystem support is active" OFF) - # Workaround to be able to deal with compiler bug "Too many sections" with mingw. IF( CMAKE_COMPILER_IS_MINGW ) ADD_DEFINITIONS(-DASSIMP_BUILD_NO_IFC_IMPORTER ) @@ -170,8 +205,6 @@ IF (NOT TARGET uninstall) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") ENDIF() - - # cmake configuration files configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE) @@ -179,22 +212,12 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${C FIND_PACKAGE( DirectX ) -OPTION ( ASSIMP_NO_EXPORT - "Disable Assimp's export functionality." - OFF -) - IF( CMAKE_COMPILER_IS_GNUCXX ) SET(LIBSTDC++_LIBRARIES -lstdc++) ENDIF( CMAKE_COMPILER_IS_GNUCXX ) # Search for external dependencies, and build them from source if not found # Search for zlib -OPTION(ASSIMP_BUILD_ZLIB - "Build your own zlib" - OFF -) - IF ( NOT ASSIMP_BUILD_ZLIB ) find_package(ZLIB) ENDIF( NOT ASSIMP_BUILD_ZLIB ) @@ -292,10 +315,6 @@ ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) ADD_SUBDIRECTORY( code/ ) -option ( ASSIMP_BUILD_ASSIMP_TOOLS - "If the supplementary tools for Assimp are built in addition to the library." - ON -) IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( WIN32 ) option ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} ) @@ -333,10 +352,6 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) ENDIF ( Qt4_FOUND AND IL_FOUND AND OPENGL_FOUND) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS ) -option ( ASSIMP_BUILD_SAMPLES - "If the official samples are built as well (needs Glut)." - OFF -) IF ( ASSIMP_BUILD_SAMPLES) IF ( WIN32 ) @@ -345,22 +360,10 @@ IF ( ASSIMP_BUILD_SAMPLES) ADD_SUBDIRECTORY( samples/SimpleOpenGL/ ) ENDIF ( ASSIMP_BUILD_SAMPLES ) -OPTION ( ASSIMP_BUILD_TESTS - "If the test suite for Assimp is built in addition to the library." - ON -) - IF ( ASSIMP_BUILD_TESTS ) ADD_SUBDIRECTORY( test/ ) ENDIF ( ASSIMP_BUILD_TESTS ) -IF(MSVC) - OPTION ( ASSIMP_INSTALL_PDB - "Install MSVC debug files." - ON - ) -ENDIF(MSVC) - # Generate a pkg-config .pc for the Assimp library. CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY ) INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT}) From b91685765957c54a561ff4159a44e310aa208f33 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 14 Aug 2016 11:44:21 +0200 Subject: [PATCH 11/13] closes https://github.com/assimp/assimp/issues/967: add unzip include path when no other version was found. --- code/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 35ecf5020..9baa4db2e 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -722,6 +722,7 @@ if (UNZIP_FOUND) SET (unzip_compile_SRCS "") else (UNZIP_FOUND) SET (unzip_compile_SRCS ${unzip_SRCS}) + INCLUDE_DIRECTORIES( "../contrib/unzip/" ) endif (UNZIP_FOUND) MESSAGE(STATUS "Enabled formats:${ASSIMP_IMPORTERS_ENABLED}") From c403565d0626d3789888830357c6722b37408b10 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 14 Aug 2016 11:58:12 +0200 Subject: [PATCH 12/13] Update rapidjson to v1.0.2 --- .../rapidjson/include/rapidjson/allocators.h | 6 +- .../rapidjson/include/rapidjson/document.h | 134 +----------------- .../include/rapidjson/encodedstream.h | 10 +- .../include/rapidjson/filewritestream.h | 6 +- .../include/rapidjson/internal/biginteger.h | 14 +- .../include/rapidjson/internal/diyfp.h | 5 +- .../include/rapidjson/internal/dtoa.h | 10 +- .../include/rapidjson/internal/ieee754.h | 2 +- .../include/rapidjson/internal/stack.h | 19 +-- .../include/rapidjson/internal/strtod.h | 22 +-- .../rapidjson/include/rapidjson/rapidjson.h | 8 +- contrib/rapidjson/include/rapidjson/reader.h | 108 ++++---------- contrib/rapidjson/include/rapidjson/writer.h | 10 +- contrib/rapidjson/license.txt | 2 +- contrib/rapidjson/readme.md | 14 +- 15 files changed, 79 insertions(+), 291 deletions(-) diff --git a/contrib/rapidjson/include/rapidjson/allocators.h b/contrib/rapidjson/include/rapidjson/allocators.h index 24e6044b3..d74a67155 100644 --- a/contrib/rapidjson/include/rapidjson/allocators.h +++ b/contrib/rapidjson/include/rapidjson/allocators.h @@ -181,7 +181,7 @@ public: if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity) AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size); - void *buffer = reinterpret_cast(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size; + void *buffer = reinterpret_cast(chunkHead_ + 1) + chunkHead_->size; chunkHead_->size += size; return buffer; } @@ -199,7 +199,7 @@ public: return originalPtr; // Simply expand it if it is the last allocation and there is sufficient space - if (originalPtr == (char *)(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) { + if (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) { size_t increment = static_cast(newSize - originalSize); increment = RAPIDJSON_ALIGN(increment); if (chunkHead_->size + increment <= chunkHead_->capacity) { @@ -231,7 +231,7 @@ private: void AddChunk(size_t capacity) { if (!baseAllocator_) ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator()); - ChunkHeader* chunk = reinterpret_cast(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity)); + ChunkHeader* chunk = reinterpret_cast(baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity)); chunk->capacity = capacity; chunk->size = 0; chunk->next = chunkHead_; diff --git a/contrib/rapidjson/include/rapidjson/document.h b/contrib/rapidjson/include/rapidjson/document.h index 98053cbd5..c6acbd907 100644 --- a/contrib/rapidjson/include/rapidjson/document.h +++ b/contrib/rapidjson/include/rapidjson/document.h @@ -69,9 +69,6 @@ RAPIDJSON_NAMESPACE_BEGIN template class GenericValue; -template -class GenericDocument; - //! Name-value pair in a JSON object value. /*! This class was internal to GenericValue. It used to be a inner struct. @@ -449,16 +446,6 @@ private: //! Copy constructor is not permitted. GenericValue(const GenericValue& rhs); -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Moving from a GenericDocument is not permitted. - template - GenericValue(GenericDocument&& rhs); - - //! Move assignment from a GenericDocument is not permitted. - template - GenericValue& operator=(GenericDocument&& rhs); -#endif - public: //! Constructor with JSON value type. @@ -545,28 +532,6 @@ public: flags_ |= kIntFlag; } -#if defined(__APPLE__) - //! Constructor for unsigned long value. - explicit GenericValue(unsigned long u64) RAPIDJSON_NOEXCEPT : data_(), flags_(kNumberUint64Flag) { - data_.n.u64 = u64; - if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000))) - flags_ |= kInt64Flag; - if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000))) - flags_ |= kUintFlag; - if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000))) - flags_ |= kIntFlag; - } - -#if !defined(__x86_64__) && !defined(__arm64__) - //! Constructor for size_t value. - explicit GenericValue( size_t u ) RAPIDJSON_NOEXCEPT : data_(), flags_( kNumberUintFlag ) { - data_.n.u64 = u; - if ( !( u&0x80000000 ) ) - flags_ |= kIntFlag|kInt64Flag; - } -#endif -#endif - //! Constructor for double value. explicit GenericValue(double d) RAPIDJSON_NOEXCEPT : data_(), flags_(kNumberDoubleFlag) { data_.n.d = d; } @@ -695,20 +660,6 @@ public: return *this; } - //! free-standing swap function helper - /*! - Helper function to enable support for common swap implementation pattern based on \c std::swap: - \code - void swap(MyClass& a, MyClass& b) { - using std::swap; - swap(a.value, b.value); - // ... - } - \endcode - \see Swap() - */ - friend inline void swap(GenericValue& a, GenericValue& b) RAPIDJSON_NOEXCEPT { a.Swap(b); } - //! Prepare Value for move semantics /*! \return *this */ GenericValue& Move() RAPIDJSON_NOEXCEPT { return *this; } @@ -1262,31 +1213,6 @@ public: return pos; } - //! Erase a member in object by its name. - /*! \param name Name of member to be removed. - \return Whether the member existed. - \note Linear time complexity. - */ - bool EraseMember(const Ch* name) { - GenericValue n(StringRef(name)); - return EraseMember(n); - } - -#if RAPIDJSON_HAS_STDSTRING - bool EraseMember(const std::basic_string& name) { return EraseMember(GenericValue(StringRef(name))); } -#endif - - template - bool EraseMember(const GenericValue& name) { - MemberIterator m = FindMember(name); - if (m != MemberEnd()) { - EraseMember(m); - return true; - } - else - return false; - } - //@} //!@name Array @@ -1798,22 +1724,7 @@ public: typedef Allocator AllocatorType; //!< Allocator type from template parameter. //! Constructor - /*! Creates an empty document of specified type. - \param type Mandatory type of object to create. - \param allocator Optional allocator for allocating memory. - \param stackCapacity Optional initial capacity of stack in bytes. - \param stackAllocator Optional allocator for allocating memory for stack. - */ - explicit GenericDocument(Type type, Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) : - GenericValue(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_() - { - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - } - - //! Constructor - /*! Creates an empty document which type is Null. - \param allocator Optional allocator for allocating memory. + /*! \param allocator Optional allocator for allocating memory. \param stackCapacity Optional initial capacity of stack in bytes. \param stackAllocator Optional allocator for allocating memory for stack. */ @@ -1827,7 +1738,7 @@ public: #if RAPIDJSON_HAS_CXX11_RVALUE_REFS //! Move constructor in C++11 GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT - : ValueType(std::forward(rhs)), // explicit cast to avoid prohibited move from Document + : ValueType(std::move(rhs)), allocator_(rhs.allocator_), ownAllocator_(rhs.ownAllocator_), stack_(std::move(rhs.stack_)), @@ -1867,35 +1778,6 @@ public: } #endif - //! Exchange the contents of this document with those of another. - /*! - \param other Another document. - \note Constant complexity. - \see GenericValue::Swap - */ - GenericDocument& Swap(GenericDocument& rhs) RAPIDJSON_NOEXCEPT { - ValueType::Swap(rhs); - stack_.Swap(rhs.stack_); - internal::Swap(allocator_, rhs.allocator_); - internal::Swap(ownAllocator_, rhs.ownAllocator_); - internal::Swap(parseResult_, rhs.parseResult_); - return *this; - } - - //! free-standing swap function helper - /*! - Helper function to enable support for common swap implementation pattern based on \c std::swap: - \code - void swap(MyClass& a, MyClass& b) { - using std::swap; - swap(a.doc, b.doc); - // ... - } - \endcode - \see Swap() - */ - friend inline void swap(GenericDocument& a, GenericDocument& b) RAPIDJSON_NOEXCEPT { a.Swap(b); } - //!@name Parse from stream //!@{ @@ -1908,13 +1790,13 @@ public: */ template GenericDocument& ParseStream(InputStream& is) { - GenericReader reader( - stack_.HasAllocator() ? &stack_.GetAllocator() : 0); + ValueType::SetNull(); // Remove existing root if exist + GenericReader reader(&stack_.GetAllocator()); ClearStackOnExit scope(*this); parseResult_ = reader.template Parse(is, *this); if (parseResult_) { RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object - ValueType::operator=(*stack_.template Pop(1));// Move value from stack to document + this->RawAssign(*stack_.template Pop(1)); // Add this-> to prevent issue 13. } return *this; } @@ -2011,10 +1893,7 @@ public: //!@} //! Get the allocator of this document. - Allocator& GetAllocator() { - RAPIDJSON_ASSERT(allocator_); - return *allocator_; - } + Allocator& GetAllocator() { return *allocator_; } //! Get the capacity of stack in bytes. size_t GetStackCapacity() const { return stack_.GetCapacity(); } @@ -2123,7 +2002,6 @@ GenericValue::GenericValue(const GenericValue(&rhs.data_); - break; } } diff --git a/contrib/rapidjson/include/rapidjson/encodedstream.h b/contrib/rapidjson/include/rapidjson/encodedstream.h index fd3bfaf13..7c8863fee 100644 --- a/contrib/rapidjson/include/rapidjson/encodedstream.h +++ b/contrib/rapidjson/include/rapidjson/encodedstream.h @@ -77,8 +77,8 @@ public: void Flush() { os_.Flush(); } // Not implemented - Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;} - Ch Take() { RAPIDJSON_ASSERT(false); return 0;} + Ch Peek() const { RAPIDJSON_ASSERT(false); } + Ch Take() { RAPIDJSON_ASSERT(false); } size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } @@ -146,7 +146,7 @@ private: if (!c) return; - unsigned bom = static_cast(c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24)); + unsigned bom = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24); hasBOM_ = false; if (bom == 0xFFFE0000) { type_ = kUTF32BE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); } else if (bom == 0x0000FEFF) { type_ = kUTF32LE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); } @@ -227,8 +227,8 @@ public: void Flush() { os_->Flush(); } // Not implemented - Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;} - Ch Take() { RAPIDJSON_ASSERT(false); return 0;} + Ch Peek() const { RAPIDJSON_ASSERT(false); } + Ch Take() { RAPIDJSON_ASSERT(false); } size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } diff --git a/contrib/rapidjson/include/rapidjson/filewritestream.h b/contrib/rapidjson/include/rapidjson/filewritestream.h index afd7e19b8..dfb9cbd02 100644 --- a/contrib/rapidjson/include/rapidjson/filewritestream.h +++ b/contrib/rapidjson/include/rapidjson/filewritestream.h @@ -57,11 +57,7 @@ public: void Flush() { if (current_ != buffer_) { - size_t result = fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); - if (result < static_cast(current_ - buffer_)) { - // failure deliberately ignored at this time - // added to avoid warn_unused_result build errors - } + fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); current_ = buffer_; } } diff --git a/contrib/rapidjson/include/rapidjson/internal/biginteger.h b/contrib/rapidjson/include/rapidjson/internal/biginteger.h index 4477cf5d1..99a30acf6 100644 --- a/contrib/rapidjson/include/rapidjson/internal/biginteger.h +++ b/contrib/rapidjson/include/rapidjson/internal/biginteger.h @@ -19,7 +19,6 @@ #if defined(_MSC_VER) && defined(_M_AMD64) #include // for _umul128 -#pragma intrinsic(_umul128) #endif RAPIDJSON_NAMESPACE_BEGIN @@ -51,16 +50,7 @@ public: if (length > 0) AppendDecimal64(decimals + i, decimals + i + length); } - - BigInteger& operator=(const BigInteger &rhs) - { - if (this != &rhs) { - count_ = rhs.count_; - std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type)); - } - return *this; - } - + BigInteger& operator=(uint64_t u) { digits_[0] = u; count_ = 1; @@ -240,7 +230,7 @@ private: uint64_t r = 0; for (const char* p = begin; p != end; ++p) { RAPIDJSON_ASSERT(*p >= '0' && *p <= '9'); - r = r * 10u + (unsigned)(*p - '0'); + r = r * 10 + (*p - '0'); } return r; } diff --git a/contrib/rapidjson/include/rapidjson/internal/diyfp.h b/contrib/rapidjson/include/rapidjson/internal/diyfp.h index 7a55ee31c..3b6c4238c 100644 --- a/contrib/rapidjson/include/rapidjson/internal/diyfp.h +++ b/contrib/rapidjson/include/rapidjson/internal/diyfp.h @@ -24,7 +24,6 @@ #if defined(_MSC_VER) && defined(_M_AMD64) #include #pragma intrinsic(_BitScanReverse64) -#pragma intrinsic(_umul128) #endif RAPIDJSON_NAMESPACE_BEGIN @@ -233,8 +232,8 @@ inline DiyFp GetCachedPower(int e, int* K) { } inline DiyFp GetCachedPower10(int exp, int *outExp) { - unsigned index = (static_cast(exp) + 348u) / 8u; - *outExp = -348 + static_cast(index) * 8; + unsigned index = (exp + 348) / 8; + *outExp = -348 + index * 8; return GetCachedPowerByIndex(index); } diff --git a/contrib/rapidjson/include/rapidjson/internal/dtoa.h b/contrib/rapidjson/include/rapidjson/internal/dtoa.h index d04ae21cc..2d8d2e46a 100644 --- a/contrib/rapidjson/include/rapidjson/internal/dtoa.h +++ b/contrib/rapidjson/include/rapidjson/internal/dtoa.h @@ -62,7 +62,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff const DiyFp wp_w = Mp - W; uint32_t p1 = static_cast(Mp.f >> -one.e); uint64_t p2 = Mp.f & (one.f - 1); - unsigned kappa = CountDecimalDigit32(p1); // kappa in [0, 9] + int kappa = CountDecimalDigit32(p1); // kappa in [0, 9] *len = 0; while (kappa > 0) { @@ -101,7 +101,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff kappa--; if (p2 < delta) { *K += kappa; - GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-static_cast(kappa)]); + GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-kappa]); return; } } @@ -158,14 +158,14 @@ inline char* Prettify(char* buffer, int length, int k) { } else if (0 < kk && kk <= 21) { // 1234e-2 -> 12.34 - std::memmove(&buffer[kk + 1], &buffer[kk], static_cast(length - kk)); + std::memmove(&buffer[kk + 1], &buffer[kk], length - kk); buffer[kk] = '.'; return &buffer[length + 1]; } else if (-6 < kk && kk <= 0) { // 1234e-6 -> 0.001234 const int offset = 2 - kk; - std::memmove(&buffer[offset], &buffer[0], static_cast(length)); + std::memmove(&buffer[offset], &buffer[0], length); buffer[0] = '0'; buffer[1] = '.'; for (int i = 2; i < offset; i++) @@ -179,7 +179,7 @@ inline char* Prettify(char* buffer, int length, int k) { } else { // 1234e30 -> 1.234e33 - std::memmove(&buffer[2], &buffer[1], static_cast(length - 1)); + std::memmove(&buffer[2], &buffer[1], length - 1); buffer[1] = '.'; buffer[length + 1] = 'e'; return WriteExponent(kk - 1, &buffer[0 + length + 2]); diff --git a/contrib/rapidjson/include/rapidjson/internal/ieee754.h b/contrib/rapidjson/include/rapidjson/internal/ieee754.h index 2fdaf54b3..e3f03364c 100644 --- a/contrib/rapidjson/include/rapidjson/internal/ieee754.h +++ b/contrib/rapidjson/include/rapidjson/internal/ieee754.h @@ -53,7 +53,7 @@ public: else if (order <= -1074) return 0; else - return (unsigned)order + 1074; + return order + 1074; } private: diff --git a/contrib/rapidjson/include/rapidjson/internal/stack.h b/contrib/rapidjson/include/rapidjson/internal/stack.h index 344785dcd..722d56923 100644 --- a/contrib/rapidjson/include/rapidjson/internal/stack.h +++ b/contrib/rapidjson/include/rapidjson/internal/stack.h @@ -16,7 +16,6 @@ #define RAPIDJSON_INTERNAL_STACK_H_ #include "../rapidjson.h" -#include "swap.h" RAPIDJSON_NAMESPACE_BEGIN namespace internal { @@ -82,15 +81,6 @@ public: } #endif - void Swap(Stack& rhs) RAPIDJSON_NOEXCEPT { - internal::Swap(allocator_, rhs.allocator_); - internal::Swap(ownAllocator_, rhs.ownAllocator_); - internal::Swap(stack_, rhs.stack_); - internal::Swap(stackTop_, rhs.stackTop_); - internal::Swap(stackEnd_, rhs.stackEnd_); - internal::Swap(initialCapacity_, rhs.initialCapacity_); - } - void Clear() { stackTop_ = stack_; } void ShrinkToFit() { @@ -134,14 +124,7 @@ public: template T* Bottom() { return (T*)stack_; } - bool HasAllocator() const { - return allocator_ != 0; - } - - Allocator& GetAllocator() { - RAPIDJSON_ASSERT(allocator_); - return *allocator_; - } + Allocator& GetAllocator() { return *allocator_; } bool Empty() const { return stackTop_ == stack_; } size_t GetSize() const { return static_cast(stackTop_ - stack_); } size_t GetCapacity() const { return static_cast(stackEnd_ - stack_); } diff --git a/contrib/rapidjson/include/rapidjson/internal/strtod.h b/contrib/rapidjson/include/rapidjson/internal/strtod.h index a1b821197..ace65f677 100644 --- a/contrib/rapidjson/include/rapidjson/internal/strtod.h +++ b/contrib/rapidjson/include/rapidjson/internal/strtod.h @@ -95,13 +95,13 @@ inline int CheckWithinHalfULP(double b, const BigInteger& d, int dExp) { hS_Exp2 -= common_Exp2; BigInteger dS = d; - dS.MultiplyPow5(static_cast(dS_Exp5)) <<= static_cast(dS_Exp2); + dS.MultiplyPow5(dS_Exp5) <<= dS_Exp2; BigInteger bS(bInt); - bS.MultiplyPow5(static_cast(bS_Exp5)) <<= static_cast(bS_Exp2); + bS.MultiplyPow5(bS_Exp5) <<= bS_Exp2; BigInteger hS(1); - hS.MultiplyPow5(static_cast(hS_Exp5)) <<= static_cast(hS_Exp2); + hS.MultiplyPow5(hS_Exp5) <<= hS_Exp2; BigInteger delta(0); dS.Difference(bS, &delta); @@ -134,7 +134,7 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit if (significand > RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) || (significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > '5')) break; - significand = significand * 10u + static_cast(decimals[i] - '0'); + significand = significand * 10 + (decimals[i] - '0'); } if (i < length && decimals[i] >= '5') // Rounding @@ -163,10 +163,10 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit DiyFp(RAPIDJSON_UINT64_C2(0xf4240000, 00000000), -44), // 10^6 DiyFp(RAPIDJSON_UINT64_C2(0x98968000, 00000000), -40) // 10^7 }; - int adjustment = dExp - actualExp - 1; + int adjustment = dExp - actualExp - 1; RAPIDJSON_ASSERT(adjustment >= 0 && adjustment < 7); v = v * kPow10[adjustment]; - if (length + static_cast(adjustment)> 19u) // has more digits than decimal digits in 64-bit + if (length + adjustment > 19) // has more digits than decimal digits in 64-bit error += kUlp / 2; } @@ -184,14 +184,14 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit unsigned scaleExp = (precisionSize + kUlpShift) - 63; v.f >>= scaleExp; v.e += scaleExp; - error = (error >> scaleExp) + 1 + static_cast(kUlp); + error = (error >> scaleExp) + 1 + kUlp; precisionSize -= scaleExp; } - DiyFp rounded(v.f >> precisionSize, v.e + static_cast(precisionSize)); + DiyFp rounded(v.f >> precisionSize, v.e + precisionSize); const uint64_t precisionBits = (v.f & ((uint64_t(1) << precisionSize) - 1)) * kUlp; const uint64_t halfWay = (uint64_t(1) << (precisionSize - 1)) * kUlp; - if (precisionBits >= halfWay + static_cast(error)) { + if (precisionBits >= halfWay + error) { rounded.f++; if (rounded.f & (DiyFp::kDpHiddenBit << 1)) { // rounding overflows mantissa (issue #340) rounded.f >>= 1; @@ -201,7 +201,7 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit *result = rounded.ToDouble(); - return halfWay - static_cast(error) >= precisionBits || precisionBits >= halfWay + static_cast(error); + return halfWay - error >= precisionBits || precisionBits >= halfWay + error; } inline double StrtodBigInteger(double approx, const char* decimals, size_t length, size_t decimalPosition, int exp) { @@ -249,7 +249,7 @@ inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t if ((int)length > kMaxDecimalDigit) { int delta = (int(length) - kMaxDecimalDigit); exp += delta; - decimalPosition -= static_cast(delta); + decimalPosition -= delta; length = kMaxDecimalDigit; } diff --git a/contrib/rapidjson/include/rapidjson/rapidjson.h b/contrib/rapidjson/include/rapidjson/rapidjson.h index b83f8e22f..f22130d3c 100644 --- a/contrib/rapidjson/include/rapidjson/rapidjson.h +++ b/contrib/rapidjson/include/rapidjson/rapidjson.h @@ -223,7 +223,7 @@ //! Whether using 64-bit architecture #ifndef RAPIDJSON_64BIT -#if defined(__LP64__) || defined(_WIN64) || defined(__EMSCRIPTEN__) +#if defined(__LP64__) || defined(_WIN64) #define RAPIDJSON_64BIT 1 #else #define RAPIDJSON_64BIT 0 @@ -238,13 +238,13 @@ \param x pointer to align Some machines require strict data alignment. Currently the default uses 4 bytes - alignment. User can customize by defining the RAPIDJSON_ALIGN function macro. + alignment. User can customize by defining the RAPIDJSON_ALIGN function macro., */ #ifndef RAPIDJSON_ALIGN #if RAPIDJSON_64BIT == 1 -#define RAPIDJSON_ALIGN(x) (((x) + static_cast(7u)) & ~static_cast(7u)) +#define RAPIDJSON_ALIGN(x) ((x + 7u) & ~7u) #else -#define RAPIDJSON_ALIGN(x) (((x) + 3u) & ~3u) +#define RAPIDJSON_ALIGN(x) ((x + 3u) & ~3u) #endif #endif diff --git a/contrib/rapidjson/include/rapidjson/reader.h b/contrib/rapidjson/include/rapidjson/reader.h index 6fb29e908..c5ecf4be5 100644 --- a/contrib/rapidjson/include/rapidjson/reader.h +++ b/contrib/rapidjson/include/rapidjson/reader.h @@ -140,7 +140,6 @@ enum ParseFlag { kParseIterativeFlag = 4, //!< Iterative(constant complexity in terms of function call stack size) parsing. kParseStopWhenDoneFlag = 8, //!< After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate kParseErrorDocumentRootNotSingular error. kParseFullPrecisionFlag = 16, //!< Parse number in full precision (but slower). - kParseCommentsFlag = 32, //!< Allow one-line (//) and multi-line (/**/) comments. kParseDefaultFlags = RAPIDJSON_PARSE_DEFAULT_FLAGS //!< Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS }; @@ -272,7 +271,7 @@ inline const char *SkipWhitespace_SIMD(const char* p) { // The rest of string using SIMD static const char whitespace[16] = " \n\r\t"; - const __m128i w = _mm_loadu_si128((const __m128i *)&whitespace[0]); + const __m128i w = _mm_load_si128((const __m128i *)&whitespace[0]); for (;; p += 16) { const __m128i s = _mm_load_si128((const __m128i *)p); @@ -399,8 +398,7 @@ public: ClearStackOnExit scope(*this); - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); + SkipWhitespace(is); if (is.Peek() == '\0') { RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentEmpty, is.Tell()); @@ -411,8 +409,7 @@ public: RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); if (!(parseFlags & kParseStopWhenDoneFlag)) { - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); + SkipWhitespace(is); if (is.Peek() != '\0') { RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentRootNotSingular, is.Tell()); @@ -465,40 +462,6 @@ private: ClearStackOnExit& operator=(const ClearStackOnExit&); }; - template - void SkipWhitespaceAndComments(InputStream& is) { - SkipWhitespace(is); - - if (parseFlags & kParseCommentsFlag) { - while (is.Peek() == '/') { - is.Take(); - - if (is.Peek() == '*') { - is.Take(); - while (true) { - if (is.Peek() == '\0') - RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); - - if (is.Take() == '*') { - if (is.Peek() == '\0') - RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); - - if (is.Take() == '/') - break; - } - } - } else if (is.Peek() == '/') { - is.Take(); - while (is.Peek() != '\0' && is.Take() != '\n') { } - } else { - RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); - } - - SkipWhitespace(is); - } - } - } - // Parse object: { string : value, ... } template void ParseObject(InputStream& is, Handler& handler) { @@ -508,8 +471,7 @@ private: if (!handler.StartObject()) RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); if (is.Peek() == '}') { is.Take(); @@ -525,35 +487,27 @@ private: ParseString(is, handler, true); RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); if (is.Take() != ':') RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); ParseValue(is, handler); RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); ++memberCount; switch (is.Take()) { - case ',': - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - break; + case ',': SkipWhitespace(is); break; case '}': if (!handler.EndObject(memberCount)) RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); return; - default: - RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); - break; + default: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); } } } @@ -567,8 +521,7 @@ private: if (!handler.StartArray()) RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); if (is.Peek() == ']') { is.Take(); @@ -582,21 +535,15 @@ private: RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; ++elementCount; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; + SkipWhitespace(is); switch (is.Take()) { - case ',': - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - break; + case ',': SkipWhitespace(is); break; case ']': if (!handler.EndArray(elementCount)) RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); return; - default: - RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); - break; + default: RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); } } } @@ -1020,13 +967,13 @@ private: else { if (use64bit) { if (minus) - cont = handler.Int64(static_cast(~i64 + 1)); + cont = handler.Int64(-(int64_t)i64); else cont = handler.Uint64(i64); } else { if (minus) - cont = handler.Int(static_cast(~i + 1)); + cont = handler.Int(-(int)i); else cont = handler.Uint(i); } @@ -1045,10 +992,7 @@ private: case '"': ParseString(is, handler); break; case '{': ParseObject(is, handler); break; case '[': ParseArray (is, handler); break; - default : - ParseNumber(is, handler); - break; - + default : ParseNumber(is, handler); } } @@ -1443,14 +1387,14 @@ private: } switch (src) { - case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell()); return; - case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); return; + case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell()); + case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); case IterativeParsingObjectInitialState: - case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); return; - case IterativeParsingMemberKeyState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); return; - case IterativeParsingMemberValueState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); return; - case IterativeParsingElementState: RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); return; - default: RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); return; + case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); + case IterativeParsingMemberKeyState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); + case IterativeParsingMemberValueState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); + case IterativeParsingElementState: RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); + default: RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); } } @@ -1460,8 +1404,7 @@ private: ClearStackOnExit scope(*this); IterativeParsingState state = IterativeParsingStartState; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); + SkipWhitespace(is); while (is.Peek() != '\0') { Token t = Tokenize(is.Peek()); IterativeParsingState n = Predict(state, t); @@ -1478,8 +1421,7 @@ private: if ((parseFlags & kParseStopWhenDoneFlag) && state == IterativeParsingFinishState) break; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); + SkipWhitespace(is); } // Handle the end of file. diff --git a/contrib/rapidjson/include/rapidjson/writer.h b/contrib/rapidjson/include/rapidjson/writer.h index 874faa881..e1eea38b9 100644 --- a/contrib/rapidjson/include/rapidjson/writer.h +++ b/contrib/rapidjson/include/rapidjson/writer.h @@ -350,7 +350,7 @@ template<> inline bool Writer::WriteInt(int i) { char *buffer = os_->Push(11); const char* end = internal::i32toa(i, buffer); - os_->Pop(static_cast(11 - (end - buffer))); + os_->Pop(11 - (end - buffer)); return true; } @@ -358,7 +358,7 @@ template<> inline bool Writer::WriteUint(unsigned u) { char *buffer = os_->Push(10); const char* end = internal::u32toa(u, buffer); - os_->Pop(static_cast(10 - (end - buffer))); + os_->Pop(10 - (end - buffer)); return true; } @@ -366,7 +366,7 @@ template<> inline bool Writer::WriteInt64(int64_t i64) { char *buffer = os_->Push(21); const char* end = internal::i64toa(i64, buffer); - os_->Pop(static_cast(21 - (end - buffer))); + os_->Pop(21 - (end - buffer)); return true; } @@ -374,7 +374,7 @@ template<> inline bool Writer::WriteUint64(uint64_t u) { char *buffer = os_->Push(20); const char* end = internal::u64toa(u, buffer); - os_->Pop(static_cast(20 - (end - buffer))); + os_->Pop(20 - (end - buffer)); return true; } @@ -382,7 +382,7 @@ template<> inline bool Writer::WriteDouble(double d) { char *buffer = os_->Push(25); char* end = internal::dtoa(d, buffer); - os_->Pop(static_cast(25 - (end - buffer))); + os_->Pop(25 - (end - buffer)); return true; } diff --git a/contrib/rapidjson/license.txt b/contrib/rapidjson/license.txt index 7ccc161c8..879293afa 100644 --- a/contrib/rapidjson/license.txt +++ b/contrib/rapidjson/license.txt @@ -3,7 +3,7 @@ Tencent is pleased to support the open source community by making RapidJSON avai Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License. -If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license. +If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. A copy of the MIT License is included in this file. Other dependencies and licenses: diff --git a/contrib/rapidjson/readme.md b/contrib/rapidjson/readme.md index fb270fb96..19da38667 100644 --- a/contrib/rapidjson/readme.md +++ b/contrib/rapidjson/readme.md @@ -10,8 +10,8 @@ Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights * [RapidJSON GitHub](https://github.com/miloyip/rapidjson/) * RapidJSON Documentation - * [English](http://rapidjson.org/) - * [简体中文](http://rapidjson.org/zh-cn/) + * [English](http://miloyip.github.io/rapidjson/) + * [简体中文](http://miloyip.github.io/rapidjson/zh-cn/) * [GitBook](https://www.gitbook.com/book/miloyip/rapidjson/) with downloadable PDF/EPUB/MOBI, without API reference. ## Build status @@ -31,15 +31,15 @@ Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights RapidJSON is a JSON parser and generator for C++. It was inspired by [RapidXml](http://rapidxml.sourceforge.net/). -* RapidJSON is **small** but **complete**. It supports both SAX and DOM style API. The SAX parser is only a half thousand lines of code. +* RapidJSON is small but complete. It supports both SAX and DOM style API. The SAX parser is only a half thousand lines of code. -* RapidJSON is **fast**. Its performance can be comparable to `strlen()`. It also optionally supports SSE2/SSE4.2 for acceleration. +* RapidJSON is fast. Its performance can be comparable to `strlen()`. It also optionally supports SSE2/SSE4.2 for acceleration. -* RapidJSON is **self-contained** and **header-only**. It does not depend on external libraries such as BOOST. It even does not depend on STL. +* RapidJSON is self-contained. It does not depend on external libraries such as BOOST. It even does not depend on STL. -* RapidJSON is **memory-friendly**. Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string). By default it uses a fast memory allocator, and the parser allocates memory compactly during parsing. +* RapidJSON is memory friendly. Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string). By default it uses a fast memory allocator, and the parser allocates memory compactly during parsing. -* RapidJSON is **Unicode-friendly**. It supports UTF-8, UTF-16, UTF-32 (LE & BE), and their detection, validation and transcoding internally. For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. It also supports surrogates and "\u0000" (null character). +* RapidJSON is Unicode friendly. It supports UTF-8, UTF-16, UTF-32 (LE & BE), and their detection, validation and transcoding internally. For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. It also supports surrogates and "\u0000" (null character). More features can be read [here](doc/features.md). From ec67a1f2eae7d343e1c56a8a47bf80fdce93474c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 14 Aug 2016 12:23:16 +0200 Subject: [PATCH 13/13] closes https://github.com/assimp/assimp/issues/97: define for 32-bit linux --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5f4a0297..af472a0b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,13 @@ IF( CMAKE_COMPILER_IS_MINGW ) ADD_DEFINITIONS(-DASSIMP_BUILD_NO_IFC_IMPORTER ) ENDIF() +# Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux +IF( UNIX ) + IF (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux + ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 ) + ENDIF() +ENDIF() + IF((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW) IF (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 8) # -fPIC is only required for shared libs on 64 bit SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")