From 45c12cd5fb10803f359852c4866cac5031848429 Mon Sep 17 00:00:00 2001 From: RichardTea <31507749+RichardTea@users.noreply.github.com> Date: Mon, 20 May 2019 13:49:56 +0100 Subject: [PATCH 1/6] Update irrXMLWrapper.h Use std::find to find and remove null characters from XML --- include/assimp/irrXMLWrapper.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/assimp/irrXMLWrapper.h b/include/assimp/irrXMLWrapper.h index ec8ee7c76..290cf67ea 100644 --- a/include/assimp/irrXMLWrapper.h +++ b/include/assimp/irrXMLWrapper.h @@ -91,14 +91,15 @@ public: stream->Read(&data[0],data.size(),1); // Remove null characters from the input sequence otherwise the parsing will utterly fail - unsigned int size = 0; - unsigned int size_max = static_cast(data.size()); - for(unsigned int i = 0; i < size_max; i++) { - if(data[i] != '\0') { - data[size++] = data[i]; - } + // std::find is usually much faster than manually iterating + // It is very unlikely that there will be any null characters + auto null_char_iter = std::find(data.begin(), data.end(), '\0'); + + while (null_char_iter != data.end()) + { + null_char_iter = data.erase(null_char_iter); + null_char_iter = std::find(null_char_iter, data.end(), '\0'); } - data.resize(size); BaseImporter::ConvertToUTF8(data); } From daef984ac603e10ffff19f99eccccb6815151913 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Wed, 22 May 2019 20:00:33 +0200 Subject: [PATCH 2/6] Optim FindInstancesProcess ComputePositionEpsilon() is a costly function which was called in the inner loop although it only uses data from upper loop. --- code/FindInstancesProcess.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/FindInstancesProcess.cpp b/code/FindInstancesProcess.cpp index be1138116..64907458a 100644 --- a/code/FindInstancesProcess.cpp +++ b/code/FindInstancesProcess.cpp @@ -137,6 +137,11 @@ void FindInstancesProcess::Execute( aiScene* pScene) aiMesh* inst = pScene->mMeshes[i]; hashes[i] = GetMeshHash(inst); + // Find an appropriate epsilon + // to compare position differences against + float epsilon = ComputePositionEpsilon(inst); + epsilon *= epsilon; + for (int a = i-1; a >= 0; --a) { if (hashes[i] == hashes[a]) { @@ -154,12 +159,7 @@ void FindInstancesProcess::Execute( aiScene* pScene) orig->mPrimitiveTypes != inst->mPrimitiveTypes) continue; - // up to now the meshes are equal. find an appropriate - // epsilon to compare position differences against - float epsilon = ComputePositionEpsilon(inst); - epsilon *= epsilon; - - // now compare vertex positions, normals, + // up to now the meshes are equal. Now compare vertex positions, normals, // tangents and bitangents using this epsilon. if (orig->HasPositions()) { if(!CompareArrays(orig->mVertices,inst->mVertices,orig->mNumVertices,epsilon)) From d048bccad1ea3f72906da2d970b30f187db91f33 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 22 May 2019 13:54:15 -1000 Subject: [PATCH 3/6] Export static libaries as CMake package When built with BUILD_SHARED_LIBS disabled, the exported CMake targets are modified to reference the static library location. This also fixes version detection for VS2017 and beyond within the target import script. --- CMakeLists.txt | 16 ++++-- assimpTargets-debug.cmake.in | 100 ++++++++++++++++++++++----------- assimpTargets-release.cmake.in | 98 +++++++++++++++++++++----------- assimpTargets.cmake.in | 6 +- 4 files changed, 148 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cda2d4e84..520dd68d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,16 +328,24 @@ 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}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE) -CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE) -CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE) +IF (is_multi_config) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE) + SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake") +ELSEIF (CMAKE_BUILD_TYPE STREQUAL Debug) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE) + SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake") +ELSE() + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE) + SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake") +ENDIF() CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE) #we should generated these scripts after CMake VERSION 3.0.2 using export(EXPORT ...) and write_basic_package_version_file(...) INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" + ${PACKAGE_TARGETS_FILE} DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT}) FIND_PACKAGE( DirectX ) diff --git a/assimpTargets-debug.cmake.in b/assimpTargets-debug.cmake.in index a83e6c22d..6ee6b2886 100644 --- a/assimpTargets-debug.cmake.in +++ b/assimpTargets-debug.cmake.in @@ -5,48 +5,75 @@ # Commands may need to know the format version. set(CMAKE_IMPORT_FILE_VERSION 1) +set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) + if(MSVC) - if( MSVC70 OR MSVC71 ) - set(MSVC_PREFIX "vc70") - elseif( MSVC80 ) - set(MSVC_PREFIX "vc80") - elseif( MSVC90 ) - set(MSVC_PREFIX "vc90") - elseif( MSVC10 ) - set(MSVC_PREFIX "vc100") - elseif( MSVC11 ) - set(MSVC_PREFIX "vc110") - elseif( MSVC12 ) - set(MSVC_PREFIX "vc120") - elseif( MSVC14 ) - set(MSVC_PREFIX "vc140") + if(MSVC_TOOLSET_VERSION) + set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}") else() - set(MSVC_PREFIX "vc150") + if( MSVC70 OR MSVC71 ) + set(MSVC_PREFIX "vc70") + elseif( MSVC80 ) + set(MSVC_PREFIX "vc80") + elseif( MSVC90 ) + set(MSVC_PREFIX "vc90") + elseif( MSVC10 ) + set(MSVC_PREFIX "vc100") + elseif( MSVC11 ) + set(MSVC_PREFIX "vc110") + elseif( MSVC12 ) + set(MSVC_PREFIX "vc120") + elseif( MSVC14 ) + set(MSVC_PREFIX "vc140") + else() + set(MSVC_PREFIX "vc150") + endif() endif() set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" ) - set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") - set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@") + if(ASSIMP_BUILD_SHARED_LIBS) + set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") + set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@") - # Import target "assimp::assimp" for configuration "Debug" - set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(assimp::assimp PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}" - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" - ) - list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) + # Import target "assimp::assimp" for configuration "Debug" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" + ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) + else() + set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") + + # Import target "assimp::assimp" for configuration "Debug" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" + ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") + endif() else() - set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" ) - set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") - set_target_properties(assimp::assimp PROPERTIES - IMPORTED_SONAME_DEBUG "${sharedLibraryName}" - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" + set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the assimp libraries" ) + if(ASSIMP_BUILD_SHARED_LIBS) + set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_SONAME_DEBUG "${sharedLibraryName}" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) - list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) + else() + set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" + ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) + endif() endif() @@ -60,7 +87,11 @@ set( ASSIMP_CXX_FLAGS ) # dynamically linked library set( ASSIMP_LINK_FLAGS "" ) set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") -set( ASSIMP_LIBRARIES ${sharedLibraryName}) +if(ASSIMP_BUILD_SHARED_LIBS) + set( ASSIMP_LIBRARIES ${sharedLibraryName}) +else() + set( ASSIMP_LIBRARIES ${staticLibraryName}) +endif() # for compatibility with pkg-config set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}") @@ -75,4 +106,5 @@ MARK_AS_ADVANCED( ASSIMP_CFLAGS_OTHER ASSIMP_LDFLAGS_OTHER ASSIMP_LIBRARY_SUFFIX + ASSIMP_BUILD_SHARED_LIBS ) diff --git a/assimpTargets-release.cmake.in b/assimpTargets-release.cmake.in index 2efae448a..56bfc3602 100644 --- a/assimpTargets-release.cmake.in +++ b/assimpTargets-release.cmake.in @@ -5,48 +5,75 @@ # Commands may need to know the format version. set(CMAKE_IMPORT_FILE_VERSION 1) +set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) + if(MSVC) - if( MSVC70 OR MSVC71 ) - set(MSVC_PREFIX "vc70") - elseif( MSVC80 ) - set(MSVC_PREFIX "vc80") - elseif( MSVC90 ) - set(MSVC_PREFIX "vc90") - elseif( MSVC10 ) - set(MSVC_PREFIX "vc100") - elseif( MSVC11 ) - set(MSVC_PREFIX "vc110") - elseif( MSVC12 ) - set(MSVC_PREFIX "vc120") - elseif( MSVC14 ) - set(MSVC_PREFIX "vc140") + if(MSVC_TOOLSET_VERSION) + set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}") else() - set(MSVC_PREFIX "vc150") + if( MSVC70 OR MSVC71 ) + set(MSVC_PREFIX "vc70") + elseif( MSVC80 ) + set(MSVC_PREFIX "vc80") + elseif( MSVC90 ) + set(MSVC_PREFIX "vc90") + elseif( MSVC10 ) + set(MSVC_PREFIX "vc100") + elseif( MSVC11 ) + set(MSVC_PREFIX "vc110") + elseif( MSVC12 ) + set(MSVC_PREFIX "vc120") + elseif( MSVC14 ) + set(MSVC_PREFIX "vc140") + else() + set(MSVC_PREFIX "vc150") + endif() endif() set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" ) - set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@") - set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_IMPORT_LIBRARY_SUFFIX@") + if(ASSIMP_BUILD_SHARED_LIBS) + set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@") + set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_IMPORT_LIBRARY_SUFFIX@") - # Import target "assimp::assimp" for configuration "Release" - set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(assimp::assimp PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}" - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" + # Import target "assimp::assimp" for configuration "Release" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) - list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) + else() + set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") + + # Import target "assimp::assimp" for configuration "Release" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" + ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") + endif() else() - set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" ) - set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") - set_target_properties(assimp::assimp PROPERTIES - IMPORTED_SONAME_RELEASE "${sharedLibraryName}" - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" + set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the assimp libraries" ) + if(ASSIMP_BUILD_SHARED_LIBS) + set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_SONAME_RELEASE "${sharedLibraryName}" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) - list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) + else() + set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" + ) + list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) + endif() endif() # Commands beyond this point should not need to know the version. @@ -58,7 +85,11 @@ set( ASSIMP_CXX_FLAGS ) # dynamically linked library set( ASSIMP_LINK_FLAGS "" ) set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") -set( ASSIMP_LIBRARIES ${sharedLibraryName}) +if(ASSIMP_BUILD_SHARED_LIBS) + set( ASSIMP_LIBRARIES ${sharedLibraryName}) +else() + set( ASSIMP_LIBRARIES ${staticLibraryName}) +endif() # for compatibility with pkg-config set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}") @@ -73,4 +104,5 @@ MARK_AS_ADVANCED( ASSIMP_CFLAGS_OTHER ASSIMP_LDFLAGS_OTHER ASSIMP_LIBRARY_SUFFIX + ASSIMP_BUILD_SHARED_LIBS ) diff --git a/assimpTargets.cmake.in b/assimpTargets.cmake.in index 68e2c0dec..ab1a8d2c7 100644 --- a/assimpTargets.cmake.in +++ b/assimpTargets.cmake.in @@ -51,7 +51,11 @@ if(_IMPORT_PREFIX STREQUAL "/") endif() # Create imported target assimp::assimp -add_library(assimp::assimp SHARED IMPORTED) +if(@BUILD_SHARED_LIBS@) + add_library(assimp::assimp SHARED IMPORTED) +else() + add_library(assimp::assimp STATIC IMPORTED) +endif() set_target_properties(assimp::assimp PROPERTIES COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION" From 3924a5c32a135a2f7b2827fe0f7183693b2d6d13 Mon Sep 17 00:00:00 2001 From: Eric Olson Date: Mon, 27 May 2019 12:59:00 -0500 Subject: [PATCH 4/6] Ensure obj is not null before using hasattr Fixes error shown below: File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 320, in load scene = _init(model.contents) File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 206, in _init raise e File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 187, in _init call_init(e, target) File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 80, in call_init _init(obj.contents, obj, caller) File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 214, in _init if _is_init_type(obj): File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\core.py", line 86, in _is_init_type if helper.hasattr_silent(obj,'contents'): #pointer File "C:\Users\micro\build2\boxwin_external_libs\pyassimp\helper.py", line 277, in hasattr_silent return hasattr(object, name) ValueError: NULL pointer access --- port/PyAssimp/pyassimp/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 44163a434..c346e2652 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -82,7 +82,8 @@ def call_init(obj, caller = None): _init(obj,parent=caller) def _is_init_type(obj): - if helper.hasattr_silent(obj,'contents'): #pointer + + if obj and helper.hasattr_silent(obj,'contents'): #pointer return _is_init_type(obj[0]) # null-pointer case that arises when we reach a mesh attribute # like mBitangents which use mNumVertices rather than mNumBitangents From dff92d77331debe5eacaf07c2745fd755c549a01 Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Mon, 27 May 2019 21:14:50 +0300 Subject: [PATCH 5/6] quality-of-life improvements for Visual Studio --- .gitignore | 7 +++++++ include/assimp/defs.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 49cd60ca8..9dcb6623d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,12 @@ build *.sln *.ncb *.vcproj +*.vcxproj.user +*.VC.db +*.VC.db-shm +*.VC.db-wal +*.VC.opendb +*.ipch # Output bin/ @@ -32,6 +38,7 @@ cmake_uninstall.cmake *.dir/ assimp-config.cmake assimp-config-version.cmake +assimpTargets*.cmake # MakeFile Makefile diff --git a/include/assimp/defs.h b/include/assimp/defs.h index 4a177e3c3..2631263f5 100644 --- a/include/assimp/defs.h +++ b/include/assimp/defs.h @@ -293,7 +293,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MSC_VER # define AI_NO_EXCEPT noexcept #else -# if (_MSC_VER == 1915 ) +# if (_MSC_VER >= 1915 ) # define AI_NO_EXCEPT noexcept # else # define AI_NO_EXCEPT From 48ed2d2d3c6cc1fa73d3ced821b5189de569bc53 Mon Sep 17 00:00:00 2001 From: Mike Samsonov Date: Thu, 30 May 2019 10:54:44 +0100 Subject: [PATCH 6/6] Double precision fix --- code/FBXParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/FBXParser.cpp b/code/FBXParser.cpp index fe63866a0..5d5c2c6c1 100644 --- a/code/FBXParser.cpp +++ b/code/FBXParser.cpp @@ -643,9 +643,9 @@ void ParseVectorDataArray(std::vector& out, const Element& el) if (type == 'd') { const double* d = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count3; ++i, d += 3) { - out.push_back(aiVector3D(static_cast(d[0]), - static_cast(d[1]), - static_cast(d[2]))); + out.push_back(aiVector3D(static_cast(d[0]), + static_cast(d[1]), + static_cast(d[2]))); } // for debugging /*for ( size_t i = 0; i < out.size(); i++ ) {