From 3ca6b1081080355724cf02ceb31fcace1838fbb0 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 19 Mar 2018 13:17:18 +0200 Subject: [PATCH 001/124] Norod: Set IOS_SDK_VERSION to the latest based on xcodebuild sdk version Norod:Set XCODE_ROOT_DIR based on xcode-select's --print-path --- port/iOS/build.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 44683f0c7..1a4778850 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -6,17 +6,24 @@ BUILD_DIR="./lib/iOS" -IOS_SDK_VERSION= -IOS_SDK_TARGET=6.0 -#(iPhoneOS iPhoneSimulator) -- determined from arch -IOS_SDK_DEVICE= +################################### +# SDK Version +################################### +IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]') +################################### -XCODE_ROOT_DIR=/Applications/Xcode.app/Contents -TOOLCHAIN=$XCODE_ROOT_DIR//Developer/Toolchains/XcodeDefault.xctoolchain +################################################ +# Minimum iOS deployment target version +################################################ +MIN_IOS_VERSION="8.0" -BUILD_ARCHS_DEVICE="armv7 armv7s arm64" -BUILD_ARCHS_SIMULATOR="i386 x86_64" -BUILD_ARCHS_ALL=(armv7 armv7s arm64 i386 x86_64) +IOS_SDK_TARGET=$MIN_IOS_VERSION +XCODE_ROOT_DIR=$(xcode-select --print-path) +TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain + +BUILD_ARCHS_DEVICE="armv7s arm64" +BUILD_ARCHS_SIMULATOR="x86_64" +BUILD_ARCHS_ALL=(armv7s arm64 x86_64) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= @@ -43,7 +50,7 @@ build_arch() unset DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS - export DEVROOT=$XCODE_ROOT_DIR/Developer/Platforms/$IOS_SDK_DEVICE.platform/Developer + export DEVROOT=$XCODE_ROOT_DIR/Platforms/$IOS_SDK_DEVICE.platform/Developer export SDKROOT=$DEVROOT/SDKs/$IOS_SDK_DEVICE$IOS_SDK_VERSION.sdk export CFLAGS="-arch $1 -pipe -no-cpp-precomp -stdlib=$CPP_STD_LIB -isysroot $SDKROOT -$CPP_DEV_TARGET=$IOS_SDK_TARGET -I$SDKROOT/usr/include/" export LDFLAGS="-L$SDKROOT/usr/lib/" @@ -56,8 +63,8 @@ build_arch() echo "[!] Building $1 library" - $XCODE_ROOT_DIR/Developer/usr/bin/make clean - $XCODE_ROOT_DIR/Developer/usr/bin/make assimp -j 8 -l + $XCODE_ROOT_DIR/usr/bin/make clean + $XCODE_ROOT_DIR/usr/bin/make assimp -j 8 -l echo "[!] Moving built library into: $BUILD_DIR/$1/" From 14a1b9980ea444c82530a98780ccbe936b988a41 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 19 Mar 2018 15:49:16 +0200 Subject: [PATCH 002/124] Norod: Do not attempt to look for Qt5Widgets when building for iOS Norod: Toolchain files get their SDKVER, DEVROOT and SDKROOT values from build.sh Norod: Removed deprecated CMAKE_FORCE_ Norod: Build shared libs is now set-able from a flag, so to be more extendable later Norod: .gitignore updated --- .gitignore | 6 ++++++ CMakeLists.txt | 6 ++++-- port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake | 12 ++---------- port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake | 12 ++---------- port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake | 12 ++---------- port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake | 12 ++---------- port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake | 13 ++----------- port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake | 13 ++----------- port/iOS/build.sh | 6 ++++-- 9 files changed, 26 insertions(+), 66 deletions(-) diff --git a/.gitignore b/.gitignore index 2a3b68a50..89d21df6d 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,9 @@ lib64/assimp-vc120-mt.exp xcuserdata cmake-build-debug +install_manifest.txt +tools/assimp_qt_viewer/moc_glview.cpp +tools/assimp_qt_viewer/moc_glview.cpp_parameters +tools/assimp_qt_viewer/moc_mainwindow.cpp +tools/assimp_qt_viewer/moc_mainwindow.cpp_parameters +tools/assimp_qt_viewer/ui_mainwindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 15374a3fb..93558a76f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,9 +425,11 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) # Why here? Maybe user do not want Qt viewer and have no Qt. # Why assimp_qt_viewer/CMakeLists.txt still contain similar check? # Because viewer can be build independently of Assimp. - FIND_PACKAGE(Qt5Widgets QUIET) - FIND_PACKAGE(DevIL QUIET) FIND_PACKAGE(OpenGL QUIET) + IF (NOT IOS) + FIND_PACKAGE(Qt5Widgets QUIET) + ENDIF (NOT IOS) + FIND_PACKAGE(DevIL QUIET) IF ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND) ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ ) ELSE() diff --git a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake index 3aea8342e..15c1cc172 100644 --- a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake @@ -3,17 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "arm64") +SET (IOS TRUE) -SET (SDKVER "7.1") -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake index 5ec416322..692fa2b55 100644 --- a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake @@ -3,17 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv6") +SET (IOS TRUE) -SET (SDKVER "7.1") -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake index f11519aa4..0a708d963 100644 --- a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake @@ -3,17 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7s") +SET (IOS TRUE) -SET (SDKVER "7.1") -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake index b7f196c0f..22fdde115 100644 --- a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake @@ -3,17 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7") +SET (IOS TRUE) -SET (SDKVER "7.1") -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake index 22178bb87..217b4ed51 100644 --- a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake @@ -3,18 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "i386") +SET (IOS TRUE) -SET (SDKVER "7.1") - -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake index 3c69ecdb3..e4b27fba4 100644 --- a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake @@ -3,18 +3,9 @@ INCLUDE(CMakeForceCompiler) SET (CMAKE_CROSSCOMPILING TRUE) SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "x86_64") +SET (IOS TRUE) -SET (SDKVER "7.1") - -SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain") -SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk") -SET (CC "${DEVROOT}/usr/bin/clang") -SET (CXX "${DEVROOT}/usr/bin/clang++") - -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - -SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") +SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 1a4778850..8b423e473 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -12,6 +12,8 @@ BUILD_DIR="./lib/iOS" IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]') ################################### +BUILD_SHARED_LIBS="OFF" + ################################################ # Minimum iOS deployment target version ################################################ @@ -59,7 +61,7 @@ build_arch() rm CMakeCache.txt - cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=OFF + cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS echo "[!] Building $1 library" @@ -95,7 +97,7 @@ for i in "$@"; do -n|--no-fat) DEPLOY_FAT=0 echo "[!] Fat binary will not be created." - ;; + ;; -h|--help) echo " - don't build fat library (--no-fat)." echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')" From e2e09ba2fa83d25fb5a1767e07e6c12b111212e7 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 19 Mar 2018 22:51:52 +0200 Subject: [PATCH 003/124] Norod: Support building assimp as dylib for iOS (set as default) --- CMakeLists.txt | 4 +++- port/iOS/build.sh | 55 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93558a76f..e48507e43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,7 +337,9 @@ ENDIF(NOT ZLIB_FOUND) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) # Search for unzip -use_pkgconfig(UNZIP minizip) +IF (NOT IOS) + use_pkgconfig(UNZIP minizip) +ENDIF (NOT IOS) IF ( ASSIMP_NO_EXPORT ) ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 8b423e473..199418e17 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -12,7 +12,8 @@ BUILD_DIR="./lib/iOS" IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]') ################################### -BUILD_SHARED_LIBS="OFF" +BUILD_SHARED_LIBS=ON +BUILD_TYPE=MinSizeRel ################################################ # Minimum iOS deployment target version @@ -23,9 +24,9 @@ IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="armv7s arm64" -BUILD_ARCHS_SIMULATOR="x86_64" -BUILD_ARCHS_ALL=(armv7s arm64 x86_64) +BUILD_ARCHS_DEVICE="armv7 arm64" +BUILD_ARCHS_SIMULATOR="x86_64 i386" +BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= @@ -61,16 +62,23 @@ build_arch() rm CMakeCache.txt - cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS echo "[!] Building $1 library" $XCODE_ROOT_DIR/usr/bin/make clean $XCODE_ROOT_DIR/usr/bin/make assimp -j 8 -l - echo "[!] Moving built library into: $BUILD_DIR/$1/" + echo "[!] Moving built libraries into: $BUILD_DIR/$1/" - mv ./lib/libassimp.a $BUILD_DIR/$1/ + if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then + mv ./lib/libassimp*.dylib $BUILD_DIR/$1/ + else + mv ./lib/libassimp.a $BUILD_DIR/$1/ + fi + + mv ./lib/libIrrXML.a $BUILD_DIR/$1/ + mv ./lib/libzlibstatic.a $BUILD_DIR/$1/ } echo "[!] $0 - assimp iOS build script" @@ -120,13 +128,40 @@ for ARCH_TARGET in $DEPLOY_ARCHS; do done if [[ "$DEPLOY_FAT" -eq 1 ]]; then - echo '[+] Creating fat binary ...' + echo '[+] Creating fat libassimp binary ...' for ARCH_TARGET in $DEPLOY_ARCHS; do - LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.a " + if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.dylib " + else + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.a " + fi done - LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.a" + if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then + LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.dylib" + else + LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.a" + fi lipo $LIPO_ARGS echo "[!] Done! The fat binary can be found at $BUILD_DIR" + LIPO_ARGS="" + + echo '[+] Creating fat libIrrXML binary ...' + for ARCH_TARGET in $DEPLOY_ARCHS; do + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libIrrXML.a " + done + LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libIrrXML-fat.a" + lipo $LIPO_ARGS + echo "[!] Done! The fat binary can be found at $BUILD_DIR" + LIPO_ARGS="" + + echo '[+] Creating fat libzlibstatic binary ...' + for ARCH_TARGET in $DEPLOY_ARCHS; do + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libzlibstatic.a " + done + LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libzlibstatic-fat.a" + lipo $LIPO_ARGS + echo "[!] Done! The fat binary can be found at $BUILD_DIR" + LIPO_ARGS="" fi From c2f22be99abac1a10715ca92980dd352f4a2b237 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Tue, 20 Mar 2018 13:46:03 +0200 Subject: [PATCH 004/124] Norod: Default build type is set as Release, no shared libraries --- CMakeLists.txt | 8 +++++++- port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake | 8 ++++++++ port/iOS/build.sh | 6 +++--- 8 files changed, 58 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e48507e43..57f9e892f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,10 +39,16 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) PROJECT( Assimp ) # All supported options ############################################### + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + OPTION( BUILD_SHARED_LIBS "Build package with shared libraries." - ON + OFF ) + OPTION( BUILD_FRAMEWORK "Build package as Mac OS X Framework bundle." OFF diff --git a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake index 15c1cc172..4abcac764 100644 --- a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "arm64") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake index 692fa2b55..5aa7f90f1 100644 --- a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv6") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake index 0a708d963..d35bfce03 100644 --- a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7s") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake index 22fdde115..d563bb078 100644 --- a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake index 217b4ed51..6d077567e 100644 --- a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "i386") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake index e4b27fba4..354487ce0 100644 --- a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake @@ -5,6 +5,14 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "x86_64") SET (IOS TRUE) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "${DEVROOT}") SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 199418e17..7e454fae2 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -12,8 +12,8 @@ BUILD_DIR="./lib/iOS" IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]') ################################### -BUILD_SHARED_LIBS=ON -BUILD_TYPE=MinSizeRel +BUILD_SHARED_LIBS=OFF +BUILD_TYPE=Release ################################################ # Minimum iOS deployment target version @@ -62,7 +62,7 @@ build_arch() rm CMakeCache.txt - cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS echo "[!] Building $1 library" From c1f6683b2017905d2c86ab4934f730ab5ffa0187 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Tue, 20 Mar 2018 14:45:54 +0200 Subject: [PATCH 005/124] Partial revert, build only 64bit targets --- CMakeLists.txt | 4 ++-- port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake | 6 ++++++ port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake | 6 ++++++ port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake | 6 ++++++ port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake | 6 ++++++ port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake | 6 ++++++ port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake | 6 ++++++ port/iOS/build.sh | 7 ++++--- 8 files changed, 42 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57f9e892f..0579aefed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ endif() OPTION( BUILD_SHARED_LIBS "Build package with shared libraries." - OFF + ON ) OPTION( BUILD_FRAMEWORK @@ -433,11 +433,11 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) # Why here? Maybe user do not want Qt viewer and have no Qt. # Why assimp_qt_viewer/CMakeLists.txt still contain similar check? # Because viewer can be build independently of Assimp. - FIND_PACKAGE(OpenGL QUIET) IF (NOT IOS) FIND_PACKAGE(Qt5Widgets QUIET) ENDIF (NOT IOS) FIND_PACKAGE(DevIL QUIET) + FIND_PACKAGE(OpenGL QUIET) IF ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND) ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ ) ELSE() diff --git a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake index 4abcac764..89da24f09 100644 --- a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake index 5aa7f90f1..686b2faab 100644 --- a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake index d35bfce03..f34aad1fe 100644 --- a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake index d563bb078..46a0afbea 100644 --- a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake index 6d077567e..919817851 100644 --- a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake index 354487ce0..a9514ddaa 100644 --- a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake @@ -9,6 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +SET (CC "${DEVROOT}/usr/bin/clang") +SET (CXX "${DEVROOT}/usr/bin/clang++") + +CMAKE_FORCE_C_COMPILER (${CC} LLVM) +CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 7e454fae2..9d4338889 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -24,9 +24,10 @@ IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="armv7 arm64" -BUILD_ARCHS_SIMULATOR="x86_64 i386" -BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) +BUILD_ARCHS_DEVICE="arm64" +BUILD_ARCHS_SIMULATOR="x86_64" +BUILD_ARCHS_ALL=(arm64 x86_64) +#BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= From 643cf9bea2005343f90f19fb7acf3d3c402649b4 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Tue, 20 Mar 2018 17:09:50 +0200 Subject: [PATCH 006/124] Norod: Brought back 32bit archs --- port/iOS/build.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 9d4338889..b56b36c43 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -24,10 +24,9 @@ IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="arm64" -BUILD_ARCHS_SIMULATOR="x86_64" -BUILD_ARCHS_ALL=(arm64 x86_64) -#BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) +BUILD_ARCHS_DEVICE="arm64 armv7" +BUILD_ARCHS_SIMULATOR="x86_64 i386" +BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= From 78d04c137d4a7ddb04f0a4cd9e7640fb475883fd Mon Sep 17 00:00:00 2001 From: Sebastian Matusik Date: Thu, 26 Apr 2018 17:34:27 +0100 Subject: [PATCH 007/124] Fix for blendshapes import when using the JoinIdenticalVertices optimization flag --- code/JoinVerticesProcess.cpp | 276 +++++++++++++++++++---------------- include/assimp/Vertex.h | 24 +++ 2 files changed, 178 insertions(+), 122 deletions(-) diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index cffe74fb2..881481f9c 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -114,6 +114,125 @@ void JoinVerticesProcess::Execute( aiScene* pScene) pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; } +namespace { + +bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) +{ + // A little helper to find locally close vertices faster. + // Try to reuse the lookup table from the last step. + const static float epsilon = 1e-5f; + // Squared because we check against squared length of the vector difference + static const float squareEpsilon = epsilon * epsilon; + + // Square compare is useful for animeshes vertexes compare + if ((lhs.position - rhs.position).SquareLength() > squareEpsilon) { + return false; + } + + // We just test the other attributes even if they're not present in the mesh. + // In this case they're initialized to 0 so the comparison succeeds. + // By this method the non-present attributes are effectively ignored in the comparison. + if ((lhs.normal - rhs.normal).SquareLength() > squareEpsilon) { + return false; + } + + if ((lhs.texcoords[0] - rhs.texcoords[0]).SquareLength() > squareEpsilon) { + return false; + } + + if ((lhs.tangent - rhs.tangent).SquareLength() > squareEpsilon) { + return false; + } + + if ((lhs.bitangent - rhs.bitangent).SquareLength() > squareEpsilon) { + return false; + } + + // Usually we won't have vertex colors or multiple UVs, so we can skip from here + // Actually this increases runtime performance slightly, at least if branch + // prediction is on our side. + if (complex) { + for (int i = 0; i < 8; i++) { + if (i > 0 && (lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) { + return false; + } + if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) { + return false; + } + } + } + return true; +} + +template +void updateXMeshVertices(XMesh *pMesh, std::vector &uniqueVertices) { + // replace vertex data with the unique data sets + pMesh->mNumVertices = (unsigned int)uniqueVertices.size(); + + // ---------------------------------------------------------------------------- + // NOTE - we're *not* calling Vertex::SortBack() because it would check for + // presence of every single vertex component once PER VERTEX. And our CPU + // dislikes branches, even if they're easily predictable. + // ---------------------------------------------------------------------------- + + // Position, if present (check made for aiAnimMesh) + if (pMesh->mVertices) + { + delete [] pMesh->mVertices; + pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; + for (unsigned int a = 0; a < pMesh->mNumVertices; a++) { + pMesh->mVertices[a] = uniqueVertices[a].position; + } + } + + // Normals, if present + if (pMesh->mNormals) + { + delete [] pMesh->mNormals; + pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; + for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { + pMesh->mNormals[a] = uniqueVertices[a].normal; + } + } + // Tangents, if present + if (pMesh->mTangents) + { + delete [] pMesh->mTangents; + pMesh->mTangents = new aiVector3D[pMesh->mNumVertices]; + for (unsigned int a = 0; a < pMesh->mNumVertices; a++) { + pMesh->mTangents[a] = uniqueVertices[a].tangent; + } + } + // Bitangents as well + if (pMesh->mBitangents) + { + delete [] pMesh->mBitangents; + pMesh->mBitangents = new aiVector3D[pMesh->mNumVertices]; + for (unsigned int a = 0; a < pMesh->mNumVertices; a++) { + pMesh->mBitangents[a] = uniqueVertices[a].bitangent; + } + } + // Vertex colors + for (unsigned int a = 0; pMesh->HasVertexColors(a); a++) + { + delete [] pMesh->mColors[a]; + pMesh->mColors[a] = new aiColor4D[pMesh->mNumVertices]; + for( unsigned int b = 0; b < pMesh->mNumVertices; b++) { + pMesh->mColors[a][b] = uniqueVertices[b].colors[a]; + } + } + // Texture coords + for (unsigned int a = 0; pMesh->HasTextureCoords(a); a++) + { + delete [] pMesh->mTextureCoords[a]; + pMesh->mTextureCoords[a] = new aiVector3D[pMesh->mNumVertices]; + for (unsigned int b = 0; b < pMesh->mNumVertices; b++) { + pMesh->mTextureCoords[a][b] = uniqueVertices[b].texcoords[a]; + } + } +} +} // namespace + // ------------------------------------------------------------------------------------------------ // Unites identical vertices in the given mesh int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) @@ -138,9 +257,6 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) 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. - // Try to reuse the lookup table from the last step. - const static float epsilon = 1e-5f; // float posEpsilonSqr; SpatialSort* vertexFinder = NULL; SpatialSort _vertexFinder; @@ -162,9 +278,6 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // posEpsilonSqr = ComputePositionEpsilon(pMesh); } - // Squared because we check against squared length of the vector difference - static const float squareEpsilon = epsilon * epsilon; - // Again, better waste some bytes than a realloc ... std::vector verticesFound; verticesFound.reserve(10); @@ -172,6 +285,15 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // Run an optimized code path if we don't have multiple UVs or vertex colors. // This should yield false in more than 99% of all imports ... const bool complex = ( pMesh->GetNumColorChannels() > 0 || pMesh->GetNumUVChannels() > 1); + const bool hasAnimMeshes = pMesh->mNumAnimMeshes > 0; + + // We'll never have more vertices afterwards. + std::vector uniqueAnimatedVertices[pMesh->mNumAnimMeshes]; + if (hasAnimMeshes) { + for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) { + uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices); + } + } // Now check each vertex if it brings something new to the table for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { @@ -184,74 +306,32 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // check all unique vertices close to the position if this vertex is already present among them for( unsigned int b = 0; b < verticesFound.size(); b++) { - const unsigned int vidx = verticesFound[b]; const unsigned int uidx = replaceIndex[ vidx]; if( uidx & 0x80000000) continue; const Vertex& uv = uniqueVertices[ uidx]; - // Position mismatch is impossible - the vertex finder already discarded all non-matching positions - // We just test the other attributes even if they're not present in the mesh. - // In this case they're initialized to 0 so the comparison succeeds. - // By this method the non-present attributes are effectively ignored in the comparison. - if( (uv.normal - v.normal).SquareLength() > squareEpsilon) - continue; - if( (uv.texcoords[0] - v.texcoords[0]).SquareLength() > squareEpsilon) - continue; - if( (uv.tangent - v.tangent).SquareLength() > squareEpsilon) - continue; - if( (uv.bitangent - v.bitangent).SquareLength() > squareEpsilon) + if (!areVerticesEqual(v, uv, complex)) { continue; + } - // Usually we won't have vertex colors or multiple UVs, so we can skip from here - // Actually this increases runtime performance slightly, at least if branch - // prediction is on our side. - if (complex){ - // manually unrolled because continue wouldn't work as desired in an inner loop, - // also because some compilers seem to fail the task. Colors and UV coords - // are interleaved since the higher entries are most likely to be - // zero and thus useless. By interleaving the arrays, vertices are, - // on average, rejected earlier. - - if( (uv.texcoords[1] - v.texcoords[1]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[0], v.colors[0]) > squareEpsilon) - continue; - - if( (uv.texcoords[2] - v.texcoords[2]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[1], v.colors[1]) > squareEpsilon) - continue; - - if( (uv.texcoords[3] - v.texcoords[3]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[2], v.colors[2]) > squareEpsilon) - continue; - - if( (uv.texcoords[4] - v.texcoords[4]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[3], v.colors[3]) > squareEpsilon) - continue; - - if( (uv.texcoords[5] - v.texcoords[5]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[4], v.colors[4]) > squareEpsilon) - continue; - - if( (uv.texcoords[6] - v.texcoords[6]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[5], v.colors[5]) > squareEpsilon) - continue; - - if( (uv.texcoords[7] - v.texcoords[7]).SquareLength() > squareEpsilon) - continue; - if( GetColorDifference( uv.colors[6], v.colors[6]) > squareEpsilon) - continue; - - if( GetColorDifference( uv.colors[7], v.colors[7]) > squareEpsilon) + if (hasAnimMeshes) { + // If given vertex is animated, then it has to be preserver 1 to 1 (base mesh and animated mesh require same topology) + // NOTE: not doing this totaly breaks anim meshes as they don't have their own faces (they use pMesh->mFaces) + bool breaksAnimMesh = false; + for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) { + const Vertex& animatedUV = uniqueAnimatedVertices[animMeshIndex][ uidx]; + Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a); + if (!areVerticesEqual(aniMeshVertex, animatedUV, complex)) { + breaksAnimMesh = true; + break; + } + } + if (breaksAnimMesh) { continue; + } } // we're still here -> this vertex perfectly matches our given vertex @@ -270,6 +350,12 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // no unique vertex matches it up to now -> so add it replaceIndex[a] = (unsigned int)uniqueVertices.size(); uniqueVertices.push_back( v); + if (hasAnimMeshes) { + for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) { + Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a); + uniqueAnimatedVertices[animMeshIndex].push_back(aniMeshVertex); + } + } } } @@ -287,64 +373,10 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) )); } - // replace vertex data with the unique data sets - pMesh->mNumVertices = (unsigned int)uniqueVertices.size(); - - // ---------------------------------------------------------------------------- - // NOTE - we're *not* calling Vertex::SortBack() because it would check for - // presence of every single vertex component once PER VERTEX. And our CPU - // dislikes branches, even if they're easily predictable. - // ---------------------------------------------------------------------------- - - // Position - delete [] pMesh->mVertices; - pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) - pMesh->mVertices[a] = uniqueVertices[a].position; - - // Normals, if present - if( pMesh->mNormals) - { - delete [] pMesh->mNormals; - pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { - pMesh->mNormals[a] = uniqueVertices[a].normal; - } - } - // Tangents, if present - if( pMesh->mTangents) - { - delete [] pMesh->mTangents; - pMesh->mTangents = new aiVector3D[pMesh->mNumVertices]; - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { - pMesh->mTangents[a] = uniqueVertices[a].tangent; - } - } - // Bitangents as well - if( pMesh->mBitangents) - { - delete [] pMesh->mBitangents; - pMesh->mBitangents = new aiVector3D[pMesh->mNumVertices]; - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { - pMesh->mBitangents[a] = uniqueVertices[a].bitangent; - } - } - // Vertex colors - for( unsigned int a = 0; pMesh->HasVertexColors(a); a++) - { - delete [] pMesh->mColors[a]; - pMesh->mColors[a] = new aiColor4D[pMesh->mNumVertices]; - for( unsigned int b = 0; b < pMesh->mNumVertices; b++) { - pMesh->mColors[a][b] = uniqueVertices[b].colors[a]; - } - } - // Texture coords - for( unsigned int a = 0; pMesh->HasTextureCoords(a); a++) - { - delete [] pMesh->mTextureCoords[a]; - pMesh->mTextureCoords[a] = new aiVector3D[pMesh->mNumVertices]; - for( unsigned int b = 0; b < pMesh->mNumVertices; b++) { - pMesh->mTextureCoords[a][b] = uniqueVertices[b].texcoords[a]; + updateXMeshVertices(pMesh, uniqueVertices); + if (hasAnimMeshes) { + for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) { + updateXMeshVertices(pMesh->mAnimMeshes[animMeshIndex], uniqueAnimatedVertices[animMeshIndex]); } } diff --git a/include/assimp/Vertex.h b/include/assimp/Vertex.h index 02ae3c0f4..f1c02ee07 100644 --- a/include/assimp/Vertex.h +++ b/include/assimp/Vertex.h @@ -134,6 +134,30 @@ public: } } + // ---------------------------------------------------------------------------- + /** Extract a particular vertex from a anim mesh and interleave all components */ + explicit Vertex(const aiAnimMesh* msh, unsigned int idx) { + ai_assert(idx < msh->mNumVertices); + position = msh->mVertices[idx]; + + if (msh->HasNormals()) { + normal = msh->mNormals[idx]; + } + + if (msh->HasTangentsAndBitangents()) { + tangent = msh->mTangents[idx]; + bitangent = msh->mBitangents[idx]; + } + + for (unsigned int i = 0; msh->HasTextureCoords(i); ++i) { + texcoords[i] = msh->mTextureCoords[i][idx]; + } + + for (unsigned int i = 0; msh->HasVertexColors(i); ++i) { + colors[i] = msh->mColors[i][idx]; + } + } + public: Vertex& operator += (const Vertex& v) { From ce11aa51f5085e76303ad5c26318cad7a7cbbd62 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 7 May 2018 00:07:41 +0200 Subject: [PATCH 008/124] add win32-based make script. --- code/ObjFileImporter.cpp | 29 ++++++++++++----------------- tools/make/make_all_win32_x64.bat | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 tools/make/make_all_win32_x64.bat diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index dd0733caa..cbf2363a4 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -76,41 +76,36 @@ using namespace std; // ------------------------------------------------------------------------------------------------ // Default constructor -ObjFileImporter::ObjFileImporter() : - m_Buffer(), - m_pRootObject( NULL ), - m_strAbsPath( "" ) -{ +ObjFileImporter::ObjFileImporter() +: m_Buffer() +, m_pRootObject( nullptr ) +, m_strAbsPath( "" ) { DefaultIOSystem io; m_strAbsPath = io.getOsSeparator(); } // ------------------------------------------------------------------------------------------------ // Destructor. -ObjFileImporter::~ObjFileImporter() -{ +ObjFileImporter::~ObjFileImporter() { delete m_pRootObject; - m_pRootObject = NULL; + m_pRootObject = nullptr; } // ------------------------------------------------------------------------------------------------ // Returns true, if file is an obj file. -bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler , bool checkSig ) const -{ - if(!checkSig) //Check File Extension - { +bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler , bool checkSig ) const { + if(!checkSig) { + //Check File Extension return SimpleExtensionCheck(pFile,"obj"); - } - else //Check file Header - { + } else { + // Check file Header static const char *pTokens[] = { "mtllib", "usemtl", "v ", "vt ", "vn ", "o ", "g ", "s ", "f " }; return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9 ); } } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* ObjFileImporter::GetInfo () const -{ +const aiImporterDesc* ObjFileImporter::GetInfo () const { return &desc; } diff --git a/tools/make/make_all_win32_x64.bat b/tools/make/make_all_win32_x64.bat new file mode 100644 index 000000000..d4561df0d --- /dev/null +++ b/tools/make/make_all_win32_x64.bat @@ -0,0 +1,16 @@ +rem @echo off +call build_env_win32.bat + +set BUILD_CONFIG=release +set PLATFORM_CONFIG=x64 +set MAX_CPU_CONFIG=4 + +set CONFIG_PARAMETER=/p:Configuration="%BUILD_CONFIG%" +set PLATFORM_PARAMETER=/p:Platform="%PLATFORM_CONFIG%" +set CPU_PARAMETER=/maxcpucount:%MAX_CPU_CONFIG% +set PLATFORM_TOOLSET=/p:PlatformToolset=%PLATFORM_VER% + +pushd ..\..\ +cmake CMakeLists.txt -G "Visual Studio 15 2017 Win64" +%MSBUILD% assimp.sln %CONFIG_PARAMETER% %PLATFORM_PARAMETER% %CPU_PARAMETER% %PLATFORM_TOOLSET% +popd From a9dcbedefb46664a09fb723465652726eb7377ee Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 7 May 2018 22:07:19 +0200 Subject: [PATCH 009/124] Make: save environment during make. --- tools/make/make_all_win32_x64.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/make/make_all_win32_x64.bat b/tools/make/make_all_win32_x64.bat index d4561df0d..4a1e663e6 100644 --- a/tools/make/make_all_win32_x64.bat +++ b/tools/make/make_all_win32_x64.bat @@ -1,4 +1,5 @@ rem @echo off +setlocal call build_env_win32.bat set BUILD_CONFIG=release @@ -14,3 +15,4 @@ pushd ..\..\ cmake CMakeLists.txt -G "Visual Studio 15 2017 Win64" %MSBUILD% assimp.sln %CONFIG_PARAMETER% %PLATFORM_PARAMETER% %CPU_PARAMETER% %PLATFORM_TOOLSET% popd +endlocal From d441dcd5230989581ba1bc3ebbc48cc28ed816ba Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 9 May 2018 19:15:42 +0200 Subject: [PATCH 010/124] addmissing file. --- tools/make/build_env_win32.bat | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/make/build_env_win32.bat diff --git a/tools/make/build_env_win32.bat b/tools/make/build_env_win32.bat new file mode 100644 index 000000000..cef217b70 --- /dev/null +++ b/tools/make/build_env_win32.bat @@ -0,0 +1,58 @@ +@echo off + +set "initialdir=%cd%" +goto:main + +:exitsucc +cd /d "%initialdir%" +set initialdir= + +set MSBUILD_15="C:\Program Files (x86)\Microsoft Visual Studio\2018\Professional\MSBuild\15.0\Bin\msbuild.exe" +set MSBUILD_14="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe" + +if not "%VS150%"=="" set MSBUILD_15="%VS150%\MSBuild\15.0\Bin\msbuild.exe" + +if /i %VS_VERSION%==2017 ( + set MS_BUILD_EXE=%MSBUILD_15% + set PLATFORM_VER=v141 +) else ( + set MS_BUILD_EXE=%MSBUILD_14% + set PLATFORM_VER=v140 +) + +set MSBUILD=%MS_BUILD_EXE% + +exit /b 0 + +:main +if not defined PLATFORM set "PLATFORM=x64" + +::my work here is done? + +set PATH_VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\ +REM set PATH_STUDIO="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" + +for /f "usebackq tokens=*" %%i in (`"%PATH_VSWHERE%vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( + set InstallDir=%%i +) + +IF EXIST "%InstallDir%\VC\Auxiliary\Build\vcvarsall.bat" set VS150=%InstallDir%\ + +set "CMAKE_GENERATOR=Visual Studio 15 2017 Win64" +if not "%VS150%"=="" call "%VS150%\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% && echo found VS 2o17 && set PLATFORM_VER=v141 && set VS_VERSION=2017 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 14 2015 Win64" +if defined VS140COMNTOOLS call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o15 && set PLATFORM_VER=v140 && set VS_VERSION=2015 && goto:exitsucc + +if defined VS130COMNTOOLS echo call ghostbusters... found lost VS version + +set "CMAKE_GENERATOR=Visual Studio 12 2013 Win64" +if defined VS120COMNTOOLS call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o13 && set PLATFORM_VER=v120 && set VS_VERSION=2013 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 11 2012 Win64" +if defined VS110COMNTOOLS call "%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o12 && set PLATFORM_VER=v110 && set VS_VERSION=2012 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 10 2010 Win64" +if defined VS100COMNTOOLS call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o1o && set PLATFORM_VER=v100 && set VS_VERSION=2010 && goto:exitsucc + +goto:exitsucc \ No newline at end of file From a5a4da89008198c54095e26ee7075170a81ef59d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 10 May 2018 09:19:53 +0200 Subject: [PATCH 011/124] Appveyor: adapt install script. --- appveyor.yml | 1 + packaging/windows-innosetup/script.iss | 38 +++++++++++++------------- tools/make/build_env_win32.bat | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1b87286f6..3b4b3144e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ install: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: - code\assimp.dir\%CONFIGURATION% diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index f301bc4eb..8056e31ac 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -2,7 +2,7 @@ [Setup] AppName=Open Asset Import Library - SDK -AppVerName=Open Asset Import Library - SDK (v3.3.1) +AppVerName=Open Asset Import Library - SDK (v4.1.0) DefaultDirName={pf}\Assimp DefaultGroupName=Assimp UninstallDisplayIcon={app}\bin\x86\assimp.exe @@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico WizardImageFile=compiler:WizModernImage-IS.BMP WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP LicenseFile=License.rtf -OutputBaseFileName=assimp-sdk-3.3.1-setup -VersionInfoVersion=3.3.1.0 -VersionInfoTextVersion=3.3.1 +OutputBaseFileName=assimp-sdk-4.1.0-setup +VersionInfoVersion=4.1.0.0 +VersionInfoTextVersion=4.1.0 VersionInfoCompany=Assimp Development Team ArchitecturesInstallIn64BitMode=x64 @@ -35,15 +35,15 @@ Name: "dassimp"; Description: "D Bindings"; Types: full Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] -Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2015 redistributable package (32 Bit)"; Check: not IsWin64 -Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2015 redistributable package (64 Bit)"; Check: IsWin64 +;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 +Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (64 Bit)"; Check: IsWin64 [Files] Source: "readme_installer.txt"; DestDir: "{app}"; Flags: isreadme ; Installer stub -Source: "vc_redist.x86.exe"; DestDir: "{app}\stub\"; Check: not IsWin64 +;Source: "vc_redist.x86.exe"; DestDir: "{app}\stub\"; Check: not IsWin64 Source: "vc_redist.x64.exe"; DestDir: "{app}\stub\"; Check: IsWin64 ; Common stuff @@ -55,18 +55,18 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" -Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\x64\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" -Source: "..\..\bin\release\x64\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "D3DCompiler_42_x64.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "D3DX9_42_x64.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools -Source: "..\..\bin\release\x64\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help @@ -74,8 +74,8 @@ Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Co Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries -Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\x64\assimp.lib"; DestDir: "{app}\lib\x64" +;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" +Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples diff --git a/tools/make/build_env_win32.bat b/tools/make/build_env_win32.bat index cef217b70..4b8b4674b 100644 --- a/tools/make/build_env_win32.bat +++ b/tools/make/build_env_win32.bat @@ -1,5 +1,4 @@ @echo off - set "initialdir=%cd%" goto:main From 323d59c7aafe4ef2a4492dc98306ee56d5b1fc46 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 28 May 2018 16:12:54 +0300 Subject: [PATCH 012/124] Check for null --- code/TriangulateProcess.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/TriangulateProcess.cpp b/code/TriangulateProcess.cpp index 25d92c470..ba4c96c40 100644 --- a/code/TriangulateProcess.cpp +++ b/code/TriangulateProcess.cpp @@ -105,8 +105,10 @@ void TriangulateProcess::Execute( aiScene* pScene) bool bHas = false; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) { - if ( TriangulateMesh( pScene->mMeshes[ a ] ) ) { - bHas = true; + if (pScene->mMeshes[ a ]) { + if ( TriangulateMesh( pScene->mMeshes[ a ] ) ) { + bHas = true; + } } } if ( bHas ) { @@ -286,7 +288,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // We project it onto a plane to get a 2d triangle. // Collect all vertices of of the polygon. - for (tmp = 0; tmp < max; ++tmp) { + for (tmp = 0; tmp < MIN(max,max_out+2); ++tmp) { temp_verts3d[tmp] = verts[idx[tmp]]; } From 3023df8f7ed1185e838351cc0c6dc95e222efae6 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 28 May 2018 17:36:43 +0300 Subject: [PATCH 013/124] Norod: Configurable from script parameters: dynamic libraries and debug/release build type --- port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake | 7 ------- port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake | 7 ------- port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake | 7 ------- port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake | 7 ------- port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake | 7 ------- port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake | 7 ------- port/iOS/build.sh | 24 +++++++++++++++++++----- 7 files changed, 19 insertions(+), 47 deletions(-) diff --git a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake index 89da24f09..e37045cf4 100644 --- a/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARM64_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "arm64") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake index 686b2faab..47ac79481 100644 --- a/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV6_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv6") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake index f34aad1fe..44f58e091 100644 --- a/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7S_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7s") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake index 46a0afbea..f8e5e8657 100644 --- a/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_ARMV7_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "armv7") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake index 919817851..4b161f33a 100644 --- a/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_I386_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "i386") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake index a9514ddaa..07c103174 100644 --- a/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake +++ b/port/iOS/IPHONEOS_X86_64_TOOLCHAIN.cmake @@ -5,16 +5,9 @@ SET (CMAKE_SYSTEM_NAME "Darwin") SET (CMAKE_SYSTEM_PROCESSOR "x86_64") SET (IOS TRUE) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - SET (CC "${DEVROOT}/usr/bin/clang") SET (CXX "${DEVROOT}/usr/bin/clang++") -CMAKE_FORCE_C_COMPILER (${CC} LLVM) -CMAKE_FORCE_CXX_COMPILER (${CXX} LLVM) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 338526632..2bb88014b 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -12,21 +12,25 @@ BUILD_DIR="./lib/iOS" IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]') ################################### +################################### +# BUILD Configuration +################################### + BUILD_SHARED_LIBS=OFF -BUILD_TYPE=Release +BUILD_TYPE=Debug ################################################ # Minimum iOS deployment target version ################################################ -MIN_IOS_VERSION="8.0" +MIN_IOS_VERSION="6.0" IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="arm64 armv7" +BUILD_ARCHS_DEVICE="arm64 armv7s armv7" BUILD_ARCHS_SIMULATOR="x86_64 i386" -BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) +BUILD_ARCHS_ALL=(armv7 armv7s arm64 x86_64 i386) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= @@ -62,7 +66,7 @@ build_arch() rm CMakeCache.txt - cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS echo "[!] Building $1 library" @@ -102,12 +106,22 @@ for i in "$@"; do DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` echo "[!] Selecting architectures: $DEPLOY_ARCHS" ;; + -r=*|--release=*) + BUILD_TYPE=Release + echo "[!] Selecting build type: Release" + ;; + -s=*|--shared-lib=*) + BUILD_SHARED_LIBS=ON + echo "[!] Will generate dynamic libraries" + ;; -n|--no-fat) DEPLOY_FAT=0 echo "[!] Fat binary will not be created." ;; -h|--help) echo " - don't build fat library (--no-fat)." + echo " - don't include debug information and apply compiler optimizations (--release)." + echo " - generate dynamic libraries rather than static ones (--shared-lib)." echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')" echo " - supported C++ STD libs (--stdlib): $(echo $(join , ${CPP_STD_LIB_LIST[*]}) | sed 's/,/, /g')" echo " - supported C++ standards (--std): $(echo $(join , ${CPP_STD_LIST[*]}) | sed 's/,/, /g')" From b6888962edd5510c71bef6bebccfe96ce435b0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin=20Lemaignan?= Date: Mon, 28 May 2018 23:53:28 +0100 Subject: [PATCH 014/124] [pyassimp] Updated setup.py --- port/PyAssimp/README.md | 4 ++-- port/PyAssimp/setup.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/port/PyAssimp/README.md b/port/PyAssimp/README.md index 37ecdb65d..056794fa8 100644 --- a/port/PyAssimp/README.md +++ b/port/PyAssimp/README.md @@ -1,5 +1,5 @@ -PyAssimp Readme -=============== +PyAssimp: Python bindings for libassimp +======================================= A simple Python wrapper for Assimp using `ctypes` to access the library. Requires Python >= 2.6. diff --git a/port/PyAssimp/setup.py b/port/PyAssimp/setup.py index 4ccfaf116..8157bf0ef 100644 --- a/port/PyAssimp/setup.py +++ b/port/PyAssimp/setup.py @@ -1,12 +1,22 @@ + #!/usr/bin/env python # -*- coding: utf-8 -*- import os from distutils.core import setup +def readme(): + with open('README.md') as f: + return f.read() + setup(name='pyassimp', - version='4.1.0', + version='4.1.2', license='ISC', description='Python bindings for the Open Asset Import Library (ASSIMP)', + long_description=readme(), url='https://github.com/assimp/assimp', + author='ASSIMP developers', + author_email='assimp-discussions@lists.sourceforge.net', + maintainer='Séverin Lemaignan', + maintainer_email='severin@guakamole.org', packages=['pyassimp'], data_files=[ ('share/pyassimp', ['README.md']), From c12c56d33ee5ff9734f45acf9c884a593d3bb1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin=20Lemaignan?= Date: Tue, 29 May 2018 10:47:40 +0100 Subject: [PATCH 015/124] [pyassimp] README.{md->rst} to please distutils. Bumped to 4.1.3 --- port/PyAssimp/README.md | 94 --------------------------------------- port/PyAssimp/README.rst | 96 ++++++++++++++++++++++++++++++++++++++++ port/PyAssimp/setup.py | 6 +-- 3 files changed, 99 insertions(+), 97 deletions(-) delete mode 100644 port/PyAssimp/README.md create mode 100644 port/PyAssimp/README.rst diff --git a/port/PyAssimp/README.md b/port/PyAssimp/README.md deleted file mode 100644 index 056794fa8..000000000 --- a/port/PyAssimp/README.md +++ /dev/null @@ -1,94 +0,0 @@ -PyAssimp: Python bindings for libassimp -======================================= - -A simple Python wrapper for Assimp using `ctypes` to access the library. -Requires Python >= 2.6. - -Python 3 support is mostly here, but not well tested. - -Note that pyassimp is not complete. Many ASSIMP features are missing. - -USAGE ------ - -### Complete example: 3D viewer - -`pyassimp` comes with a simple 3D viewer that shows how to load and display a 3D -model using a shader-based OpenGL pipeline. - -![Screenshot](3d_viewer_screenshot.png) - -To use it, from within `/port/PyAssimp`: - -``` -$ cd scripts -$ python ./3D-viewer -``` - -You can use this code as starting point in your applications. - -### Writing your own code - -To get started with `pyassimp`, examine the simpler `sample.py` script in `scripts/`, -which illustrates the basic usage. All Assimp data structures are wrapped using -`ctypes`. All the data+length fields in Assimp's data structures (such as -`aiMesh::mNumVertices`, `aiMesh::mVertices`) are replaced by simple python -lists, so you can call `len()` on them to get their respective size and access -members using `[]`. - -For example, to load a file named `hello.3ds` and print the first -vertex of the first mesh, you would do (proper error handling -substituted by assertions ...): - -```python - -from pyassimp import * -scene = load('hello.3ds') - -assert len(scene.meshes) -mesh = scene.meshes[0] - -assert len(mesh.vertices) -print(mesh.vertices[0]) - -# don't forget this one, or you will leak! -release(scene) - -``` - -Another example to list the 'top nodes' in a -scene: - -```python - -from pyassimp import * -scene = load('hello.3ds') - -for c in scene.rootnode.children: - print(str(c)) - -release(scene) - -``` - -INSTALL -------- - -Install `pyassimp` by running: - -``` -$ python setup.py install -``` - -PyAssimp requires a assimp dynamic library (`DLL` on windows, -`.so` on linux, `.dynlib` on macOS) in order to work. The default search directories -are: - -- the current directory -- on linux additionally: `/usr/lib`, `/usr/local/lib`, - `/usr/lib/x86_64-linux-gnu` - -To build that library, refer to the Assimp master `INSTALL` -instructions. To look in more places, edit `./pyassimp/helper.py`. -There's an `additional_dirs` list waiting for your entries. - diff --git a/port/PyAssimp/README.rst b/port/PyAssimp/README.rst new file mode 100644 index 000000000..f909e2cd0 --- /dev/null +++ b/port/PyAssimp/README.rst @@ -0,0 +1,96 @@ +PyAssimp: Python bindings for libassimp +======================================= + +A simple Python wrapper for Assimp using ``ctypes`` to access the +library. Requires Python >= 2.6. + +Python 3 support is mostly here, but not well tested. + +Note that pyassimp is not complete. Many ASSIMP features are missing. + +USAGE +----- + +Complete example: 3D viewer +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``pyassimp`` comes with a simple 3D viewer that shows how to load and +display a 3D model using a shader-based OpenGL pipeline. + +.. figure:: 3d_viewer_screenshot.png + :alt: Screenshot + + Screenshot + +To use it, from within ``/port/PyAssimp``: + +:: + + $ cd scripts + $ python ./3D-viewer + +You can use this code as starting point in your applications. + +Writing your own code +~~~~~~~~~~~~~~~~~~~~~ + +To get started with ``pyassimp``, examine the simpler ``sample.py`` +script in ``scripts/``, which illustrates the basic usage. All Assimp +data structures are wrapped using ``ctypes``. All the data+length fields +in Assimp's data structures (such as ``aiMesh::mNumVertices``, +``aiMesh::mVertices``) are replaced by simple python lists, so you can +call ``len()`` on them to get their respective size and access members +using ``[]``. + +For example, to load a file named ``hello.3ds`` and print the first +vertex of the first mesh, you would do (proper error handling +substituted by assertions ...): + +.. code:: python + + + from pyassimp import * + scene = load('hello.3ds') + + assert len(scene.meshes) + mesh = scene.meshes[0] + + assert len(mesh.vertices) + print(mesh.vertices[0]) + + # don't forget this one, or you will leak! + release(scene) + +Another example to list the 'top nodes' in a scene: + +.. code:: python + + + from pyassimp import * + scene = load('hello.3ds') + + for c in scene.rootnode.children: + print(str(c)) + + release(scene) + +INSTALL +------- + +Install ``pyassimp`` by running: + +:: + + $ python setup.py install + +PyAssimp requires a assimp dynamic library (``DLL`` on windows, ``.so`` +on linux, ``.dynlib`` on macOS) in order to work. The default search +directories are: + +- the current directory +- on linux additionally: ``/usr/lib``, ``/usr/local/lib``, + ``/usr/lib/x86_64-linux-gnu`` + +To build that library, refer to the Assimp master ``INSTALL`` +instructions. To look in more places, edit ``./pyassimp/helper.py``. +There's an ``additional_dirs`` list waiting for your entries. diff --git a/port/PyAssimp/setup.py b/port/PyAssimp/setup.py index 8157bf0ef..e19e497f0 100644 --- a/port/PyAssimp/setup.py +++ b/port/PyAssimp/setup.py @@ -4,11 +4,11 @@ import os from distutils.core import setup def readme(): - with open('README.md') as f: + with open('README.rst') as f: return f.read() setup(name='pyassimp', - version='4.1.2', + version='4.1.3', license='ISC', description='Python bindings for the Open Asset Import Library (ASSIMP)', long_description=readme(), @@ -19,7 +19,7 @@ setup(name='pyassimp', maintainer_email='severin@guakamole.org', packages=['pyassimp'], data_files=[ - ('share/pyassimp', ['README.md']), + ('share/pyassimp', ['README.rst']), ('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')]) ], requires=['numpy'] From c6eda6729677ae86217248701cd0b24dead4d728 Mon Sep 17 00:00:00 2001 From: Sebastian Maisch Date: Tue, 29 May 2018 13:01:11 +0200 Subject: [PATCH 016/124] Changed assimp to force regeneration of normals. --- code/GenFaceNormalsProcess.cpp | 14 +++++++++++++- code/GenVertexNormalsProcess.cpp | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/code/GenFaceNormalsProcess.cpp b/code/GenFaceNormalsProcess.cpp index be726302c..6c222e154 100644 --- a/code/GenFaceNormalsProcess.cpp +++ b/code/GenFaceNormalsProcess.cpp @@ -106,7 +106,8 @@ void GenFaceNormalsProcess::Execute( aiScene* pScene) bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) { if (NULL != pMesh->mNormals) { - return false; + // return false; + delete[] pMesh->mNormals; } // If the mesh consists of lines and/or points but not of @@ -135,8 +136,19 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]]; + + auto pV12 = *pV2 - *pV1; + auto pV31 = *pV3 - *pV1; + const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize(); + if (std::isnan(vNor.x) || std::isnan(vNor.y) || std::isnan(vNor.z)) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { + pMesh->mNormals[face.mIndices[i]] = aiVector3D(0.0f, 0.0f, 0.0f); + } + continue; + } + for (unsigned int i = 0;i < face.mNumIndices;++i) { pMesh->mNormals[face.mIndices[i]] = vNor; } diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index f746f3776..e0783b0a2 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -112,8 +112,10 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene) // Executes the post processing step on the given imported data. bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int meshIndex) { - if (NULL != pMesh->mNormals) - return false; + if (NULL != pMesh->mNormals) { + delete[] pMesh->mNormals; + } +// return false; // If the mesh consists of lines and/or points but not of // triangles or higher-order polygons the normal vectors From 1ee92002772b8fd68697ff658dba4f5c52fd64f6 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Wed, 30 May 2018 08:49:11 +0300 Subject: [PATCH 017/124] smallerMax --- code/TriangulateProcess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/TriangulateProcess.cpp b/code/TriangulateProcess.cpp index 31b087acb..134d1ed41 100644 --- a/code/TriangulateProcess.cpp +++ b/code/TriangulateProcess.cpp @@ -287,7 +287,8 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // We project it onto a plane to get a 2d triangle. // Collect all vertices of of the polygon. - for (tmp = 0; tmp < MIN(max,max_out+2); ++tmp) { + int smallerMax = (max<=((int)max_out+2))?(max):((int)max_out+2); + for (tmp = 0; tmp < smallerMax; ++tmp) { temp_verts3d[tmp] = verts[idx[tmp]]; } From e3847b7996e7f3f96a0bc45abf85b09e1aeffbf4 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Wed, 30 May 2018 09:21:28 +0300 Subject: [PATCH 018/124] Default to release builds, update CC/LD/etc flags --- port/iOS/build.sh | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 2bb88014b..9ce8edf6b 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -17,7 +17,7 @@ IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 ################################### BUILD_SHARED_LIBS=OFF -BUILD_TYPE=Debug +BUILD_TYPE=Release ################################################ # Minimum iOS deployment target version @@ -28,9 +28,9 @@ IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="arm64 armv7s armv7" +BUILD_ARCHS_DEVICE="arm64 armv7" BUILD_ARCHS_SIMULATOR="x86_64 i386" -BUILD_ARCHS_ALL=(armv7 armv7s arm64 x86_64 i386) +BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= @@ -55,12 +55,14 @@ build_arch() echo '[!] Target SDK set to DEVICE.' fi - unset DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS - + unset CC CPP DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS + + export CC="$(xcrun -sdk iphoneos -find clang)" + export CPP="$CC -E" export DEVROOT=$XCODE_ROOT_DIR/Platforms/$IOS_SDK_DEVICE.platform/Developer export SDKROOT=$DEVROOT/SDKs/$IOS_SDK_DEVICE$IOS_SDK_VERSION.sdk - export CFLAGS="-arch $1 -pipe -no-cpp-precomp -stdlib=$CPP_STD_LIB -isysroot $SDKROOT -$CPP_DEV_TARGET=$IOS_SDK_TARGET -I$SDKROOT/usr/include/" - export LDFLAGS="-L$SDKROOT/usr/lib/" + export CFLAGS="-arch $1 -pipe -no-cpp-precomp -stdlib=$CPP_STD_LIB -isysroot $SDKROOT -I$SDKROOT/usr/include/ -miphoneos-version-min=$IOS_SDK_TARGET" + export LDFLAGS="-arch $1 -isysroot $SDKROOT -L$SDKROOT/usr/lib/" export CPPFLAGS=$CFLAGS export CXXFLAGS="$CFLAGS -std=$CPP_STD" @@ -74,15 +76,9 @@ build_arch() $XCODE_ROOT_DIR/usr/bin/make assimp -j 8 -l echo "[!] Moving built libraries into: $BUILD_DIR/$1/" - - if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then - mv ./lib/libassimp*.dylib $BUILD_DIR/$1/ - else - mv ./lib/libassimp.a $BUILD_DIR/$1/ - fi - - mv ./lib/libIrrXML.a $BUILD_DIR/$1/ - mv ./lib/libzlibstatic.a $BUILD_DIR/$1/ + + mv ./lib/*.dylib $BUILD_DIR/$1/ + mv ./lib/*.a $BUILD_DIR/$1/ } echo "[!] $0 - assimp iOS build script" @@ -106,9 +102,9 @@ for i in "$@"; do DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` echo "[!] Selecting architectures: $DEPLOY_ARCHS" ;; - -r=*|--release=*) - BUILD_TYPE=Release - echo "[!] Selecting build type: Release" + -d=*|--debug=*) + BUILD_TYPE=Debug + echo "[!] Selecting build type: Debug" ;; -s=*|--shared-lib=*) BUILD_SHARED_LIBS=ON @@ -120,7 +116,7 @@ for i in "$@"; do ;; -h|--help) echo " - don't build fat library (--no-fat)." - echo " - don't include debug information and apply compiler optimizations (--release)." + echo " - Include debug information and symbols, no compiler optimizations (--debug)." echo " - generate dynamic libraries rather than static ones (--shared-lib)." echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')" echo " - supported C++ STD libs (--stdlib): $(echo $(join , ${CPP_STD_LIB_LIST[*]}) | sed 's/,/, /g')" From 6e49d288c3798ec62bde337035d96d48438425f8 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Wed, 30 May 2018 09:40:18 +0300 Subject: [PATCH 019/124] now only x86_64 builds :( --- port/iOS/build.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 9ce8edf6b..d56d4bcf3 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -28,9 +28,9 @@ IOS_SDK_TARGET=$MIN_IOS_VERSION XCODE_ROOT_DIR=$(xcode-select --print-path) TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain -BUILD_ARCHS_DEVICE="arm64 armv7" +BUILD_ARCHS_DEVICE="arm64 armv7s armv7" BUILD_ARCHS_SIMULATOR="x86_64 i386" -BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386) +BUILD_ARCHS_ALL=($BUILD_ARCHS_DEVICE $BUILD_ARCHS_SIMULATOR) CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min) CPP_DEV_TARGET= @@ -55,10 +55,10 @@ build_arch() echo '[!] Target SDK set to DEVICE.' fi - unset CC CPP DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS + unset DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS - export CC="$(xcrun -sdk iphoneos -find clang)" - export CPP="$CC -E" + #export CC="$(xcrun -sdk iphoneos -find clang)" + #export CPP="$CC -E" export DEVROOT=$XCODE_ROOT_DIR/Platforms/$IOS_SDK_DEVICE.platform/Developer export SDKROOT=$DEVROOT/SDKs/$IOS_SDK_DEVICE$IOS_SDK_VERSION.sdk export CFLAGS="-arch $1 -pipe -no-cpp-precomp -stdlib=$CPP_STD_LIB -isysroot $SDKROOT -I$SDKROOT/usr/include/ -miphoneos-version-min=$IOS_SDK_TARGET" @@ -132,7 +132,9 @@ cd ../../ rm -rf $BUILD_DIR for ARCH_TARGET in $DEPLOY_ARCHS; do + echo "Creating folder: $BUILD_DIR/$ARCH_TARGET" mkdir -p $BUILD_DIR/$ARCH_TARGET + echo "Building for arc: $ARCH_TARGET" build_arch $ARCH_TARGET #rm ./lib/libassimp.a done From ffb6756d2a2dc690e173b89679335ac99d885f29 Mon Sep 17 00:00:00 2001 From: Tammo Hinrichs Date: Wed, 30 May 2018 14:56:53 +0200 Subject: [PATCH 020/124] FBX: LayeredTextures now work with embedded texture data --- code/FBXConverter.cpp | 80 +++++++++++++++++++++++-------------------- code/FBXConverter.h | 4 +++ 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index c50e88390..9c07e9c58 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1526,6 +1526,46 @@ unsigned int Converter::ConvertVideo( const Video& video ) return static_cast( textures.size() - 1 ); } +aiString Converter::GetTexturePath(const Texture* tex) +{ + aiString path; + path.Set(tex->RelativeFilename()); + + const Video* media = tex->Media(); + if (media != 0) { + bool textureReady = false; //tells if our texture is ready (if it was loaded or if it was found) + unsigned int index; + + VideoMap::const_iterator it = textures_converted.find(media); + if (it != textures_converted.end()) { + index = (*it).second; + textureReady = true; + } + else { + if (media->ContentLength() > 0) { + index = ConvertVideo(*media); + textures_converted[media] = index; + textureReady = true; + } + } + + // setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture), if the texture is ready + if (doc.Settings().useLegacyEmbeddedTextureNaming) { + if (textureReady) { + // TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING" + // In FBX files textures are now stored internally by Assimp with their filename included + // Now Assimp can lookup through the loaded textures after all data is processed + // We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it + // This may occur on this case too, it has to be studied + path.data[0] = '*'; + path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index); + } + } + } + + return path; +} + void Converter::TrySetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const std::string& propName, aiTextureType target, const MeshGeometry* const mesh ) @@ -1538,41 +1578,7 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const TextureMap& const Texture* const tex = ( *it ).second; if ( tex != 0 ) { - aiString path; - path.Set( tex->RelativeFilename() ); - - const Video* media = tex->Media(); - if (media != 0) { - bool textureReady = false; //tells if our texture is ready (if it was loaded or if it was found) - unsigned int index; - - VideoMap::const_iterator it = textures_converted.find(media); - if (it != textures_converted.end()) { - index = (*it).second; - textureReady = true; - } - else { - if (media->ContentLength() > 0) { - index = ConvertVideo(*media); - textures_converted[media] = index; - textureReady = true; - } - } - - // setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture), if the texture is ready - if (doc.Settings().useLegacyEmbeddedTextureNaming) { - if (textureReady) { - // TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING" - // In FBX files textures are now stored internally by Assimp with their filename included - // Now Assimp can lookup through the loaded textures after all data is processed - // We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it - // This may occur on this case too, it has to be studied - path.data[0] = '*'; - path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index); - } - } - } - + aiString path = GetTexturePath(tex); out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, 0 ); aiUVTransform uvTrafo; @@ -1696,9 +1702,7 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextu const Texture* const tex = ( *it ).second->getTexture(texIndex); - aiString path; - path.Set( tex->RelativeFilename() ); - + aiString path = GetTexturePath(tex); out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, texIndex ); aiUVTransform uvTrafo; diff --git a/code/FBXConverter.h b/code/FBXConverter.h index 71d93d339..fca42e8d7 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -228,6 +228,10 @@ private: // Video -> aiTexture unsigned int ConvertVideo(const Video& video); + // ------------------------------------------------------------------------------------------------ + // convert embedded texture if necessary and return actual texture path + aiString GetTexturePath(const Texture* tex); + // ------------------------------------------------------------------------------------------------ void TrySetTextureProperties(aiMaterial* out_mat, const TextureMap& textures, const std::string& propName, From fceeaa72f4a9f4547adc500f45c69202b9e89188 Mon Sep 17 00:00:00 2001 From: Michael Roer Pedersen Date: Thu, 31 May 2018 15:07:00 +0200 Subject: [PATCH 021/124] FBX animation export: Assimp animation time is already in seconds. Just convert to FBX time. --- code/FBXExporter.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index a942e31bc..2403ca845 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -980,9 +980,13 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) int64_t to_ktime(double ticks, const aiAnimation* anim) { if (anim->mTicksPerSecond <= 0) { - return static_cast(ticks) * FBX::SECOND; + return static_cast(ticks * FBX::SECOND); } - return (static_cast(ticks) / static_cast(anim->mTicksPerSecond)) * FBX::SECOND; + return (static_cast(ticks / anim->mTicksPerSecond * FBX::SECOND)); +} + +int64_t to_ktime(double time) { + return (static_cast(time * FBX::SECOND)); } void FBXExporter::WriteObjects () @@ -2089,7 +2093,7 @@ void FBXExporter::WriteObjects () // position/translation for (size_t ki = 0; ki < na->mNumPositionKeys; ++ki) { const aiVectorKey& k = na->mPositionKeys[ki]; - times.push_back(to_ktime(k.mTime, anim)); + times.push_back(to_ktime(k.mTime)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z); @@ -2103,7 +2107,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumRotationKeys; ++ki) { const aiQuatKey& k = na->mRotationKeys[ki]; - times.push_back(to_ktime(k.mTime, anim)); + times.push_back(to_ktime(k.mTime)); // TODO: aiQuaternion method to convert to Euler... aiMatrix4x4 m(k.mValue.GetMatrix()); aiVector3D qs, qr, qt; @@ -2121,7 +2125,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumScalingKeys; ++ki) { const aiVectorKey& k = na->mScalingKeys[ki]; - times.push_back(to_ktime(k.mTime, anim)); + times.push_back(to_ktime(k.mTime)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z); From 64ba839f47a8198f15a070106413fa6e55c9d610 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 31 May 2018 20:04:48 +0200 Subject: [PATCH 022/124] Update Readme.md Fix the link to the active repo containing the assimp-net-code. --- port/AssimpNET/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/AssimpNET/Readme.md b/port/AssimpNET/Readme.md index d251cecc3..dca57470c 100644 --- a/port/AssimpNET/Readme.md +++ b/port/AssimpNET/Readme.md @@ -1 +1 @@ -See https://code.google.com/p/assimp-net/ and https://github.com/assimp/assimp-net for a Github mirror. \ No newline at end of file +Please check the following github-repo for the source: https://github.com/kebby/assimp-net From 339cc2e951d0ec8d87e9c010f2fbf4ef0ae1205c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 31 May 2018 20:15:13 +0200 Subject: [PATCH 023/124] Some review findings. --- code/XFileImporter.cpp | 7 ++++++- code/XFileParser.cpp | 10 ++++++++-- tools/assimp_view/Display.cpp | 19 +++++++------------ tools/assimp_view/assimp_view.cpp | 3 +-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/code/XFileImporter.cpp b/code/XFileImporter.cpp index fd28fbb79..d6d1e0078 100644 --- a/code/XFileImporter.cpp +++ b/code/XFileImporter.cpp @@ -332,6 +332,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec // collect vertex data for indices of this face for( unsigned int d = 0; d < df.mNumIndices; ++d ) { df.mIndices[d] = newIndex; + const unsigned int newIdx( pf.mIndices[ d ] ); + if ( newIdx > sourceMesh->mPositions.size() ) { + continue; + } + orgPoints[newIndex] = pf.mIndices[d]; // Position @@ -459,7 +464,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData nbone->mNodeName.Set( bone->mBoneName); nanim->mChannels[b] = nbone; - // keyframes are given as combined transformation matrix keys + // key-frames are given as combined transformation matrix keys if( !bone->mTrafoKeys.empty() ) { nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size(); diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index bda59ba59..01cbe80b9 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -471,7 +471,10 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh) unsigned int numIndices = ReadInt(); Face& face = pMesh->mPosFaces[a]; for (unsigned int b = 0; b < numIndices; ++b) { - face.mIndices.push_back( ReadInt() ); + const int idx( ReadInt() ); + if ( idx <= numVertices ) { + face.mIndices.push_back( idx ); + } } TestForSeparator(); } @@ -1293,7 +1296,8 @@ unsigned int XFileParser::ReadBinDWord() { // ------------------------------------------------------------------------------------------------ unsigned int XFileParser::ReadInt() { - if( mIsBinaryFormat) +: +cd if( mIsBinaryFormat) { if( mBinaryNumCount == 0 && mEnd - mP >= 2) { @@ -1305,6 +1309,7 @@ unsigned int XFileParser::ReadInt() } --mBinaryNumCount; + const size_t len( mEnd - mP ); if ( mEnd - mP >= 4) { return ReadBinDWord(); } else { @@ -1340,6 +1345,7 @@ unsigned int XFileParser::ReadInt() } CheckForSeparator(); + return isNegative ? ((unsigned int) -int( number)) : number; } } diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 7d986fa9c..4124822a5 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -362,9 +362,7 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath) *tex = piTexture; m_pcCurrentTexture->piTexture = tex; - //if (!pcMesh->bSharedFX){ - pcMesh->piEffect->SetTexture(tex_string,piTexture); - //} + pcMesh->piEffect->SetTexture(tex_string,piTexture); } } @@ -562,7 +560,6 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, tvi.iImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.iSelectedImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.lParam = (LPARAM)10; - //tvi.state = TVIS_EXPANDED | TVIS_EXPANDEDONCE ; sNew.itemex = tvi; sNew.hInsertAfter = TVI_LAST; @@ -629,7 +626,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, return 1; } //------------------------------------------------------------------------------- -// Expand all elements in the treeview +// Expand all elements in the tree-view int CDisplay::ExpandTree() { // expand all materials @@ -779,7 +776,7 @@ int CDisplay::OnRender() // Now render the log display in the upper right corner of the window CLogDisplay::Instance().OnRender(); - // present the backbuffer + // present the back-buffer g_piDevice->EndScene(); g_piDevice->Present(NULL,NULL,NULL,NULL); @@ -1593,7 +1590,7 @@ int CDisplay::HandleInput() return 1; } //------------------------------------------------------------------------------- -// Process input for an empty scen view to allow for skybox rotations +// Process input for an empty scene view to allow for sky-box rotations int CDisplay::HandleInputEmptyScene() { if(CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode()) @@ -2035,7 +2032,7 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix, g_piDevice->SetVertexDeclaration( gDefaultVertexDecl); if (g_sOptions.bNoAlphaBlending) { - // manually disable alphablending + // manually disable alpha-blending g_piDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE); } @@ -2199,9 +2196,6 @@ int CDisplay::RenderTextureView() // it might be that there is no texture ... if (!m_pcCurrentTexture->piTexture) { - // FIX: no such log message. it would be repeated to often - //CLogDisplay::Instance().AddEntry("Unable to display texture. Image is unreachable.", - // D3DCOLOR_ARGB(0xFF,0xFF,0,0)); return 0; } @@ -2296,5 +2290,6 @@ int CDisplay::RenderTextureView() // do we need to draw UV coordinates? return 1; } -}; + +} diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index e68b20a00..2798a9980 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -178,7 +178,6 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) // get the end time of zje operation, calculate delta t double fEnd = (double)timeGetTime(); g_fLoadTime = (float)((fEnd - fCur) / 1000); -// char szTemp[128]; g_bLoadingFinished = true; // check whether the loading process has failed ... @@ -202,7 +201,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) //------------------------------------------------------------------------------- int LoadAsset(void) { - // set the world and world rotation matrices to the identuty + // set the world and world rotation matrices to the identity g_mWorldRotate = aiMatrix4x4(); g_mWorld = aiMatrix4x4(); From 31e75b9d5438ea4de3204555a8741119e41041d2 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 31 May 2018 20:18:17 +0200 Subject: [PATCH 024/124] Update FBXConverter.cpp Replaces a 0 by nullptr. --- code/FBXConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 9c07e9c58..981203abb 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1532,7 +1532,7 @@ aiString Converter::GetTexturePath(const Texture* tex) path.Set(tex->RelativeFilename()); const Video* media = tex->Media(); - if (media != 0) { + if (media != nullptr) { bool textureReady = false; //tells if our texture is ready (if it was loaded or if it was found) unsigned int index; From b176513efaa81b396900568dcf67b9f09a1a203e Mon Sep 17 00:00:00 2001 From: Michael Roer Pedersen Date: Fri, 1 Jun 2018 09:24:53 +0200 Subject: [PATCH 025/124] FBX export. to_ktime ticks was ok. --- .gitignore | 3 +++ code/FBXExporter.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 60884061d..d3ec794d5 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,6 @@ lib64/assimp-vc120-mt.exp xcuserdata cmake-build-debug +/.vs +/code/assimp.vcxproj.user +*.user diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index 2403ca845..037520641 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -980,9 +980,9 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) int64_t to_ktime(double ticks, const aiAnimation* anim) { if (anim->mTicksPerSecond <= 0) { - return static_cast(ticks * FBX::SECOND); + return static_cast(ticks) * FBX::SECOND; } - return (static_cast(ticks / anim->mTicksPerSecond * FBX::SECOND)); + return (static_cast(ticks) / static_cast(anim->mTicksPerSecond)) * FBX::SECOND; } int64_t to_ktime(double time) { From 4af69dbeb9e528c6f3e4b85ac1147cd68482a35c Mon Sep 17 00:00:00 2001 From: Michael Roer Pedersen Date: Fri, 1 Jun 2018 09:33:28 +0200 Subject: [PATCH 026/124] undo .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index d3ec794d5..60884061d 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,3 @@ lib64/assimp-vc120-mt.exp xcuserdata cmake-build-debug -/.vs -/code/assimp.vcxproj.user -*.user From 6aa32b41a1f64fb03f40bbd902950de3bc158d26 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 1 Jun 2018 12:05:42 +0300 Subject: [PATCH 027/124] Replace type punning with explicit memcpys --- include/assimp/qnan.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/assimp/qnan.h b/include/assimp/qnan.h index 6ee3b7ce5..251688989 100644 --- a/include/assimp/qnan.h +++ b/include/assimp/qnan.h @@ -98,8 +98,10 @@ AI_FORCE_INLINE bool is_qnan(float in) // compare against // FIXME: Use stuff instead? I think fpclassify needs C99 - return (reinterpret_cast<_IEEESingle*>(&in)->IEEE.Exp == (1u << 8)-1 && - reinterpret_cast<_IEEESingle*>(&in)->IEEE.Frac); + _IEEESingle temp; + memcpy(&temp, &in, sizeof(float)); + return (temp.IEEE.Exp == (1u << 8)-1 && + temp.IEEE.Frac); } // --------------------------------------------------------------------------- @@ -114,8 +116,10 @@ AI_FORCE_INLINE bool is_qnan(double in) // compare against // FIXME: Use stuff instead? I think fpclassify needs C99 - return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1 && - reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Frac); + _IEEEDouble temp; + memcpy(&temp, &in, sizeof(in)); + return (temp.IEEE.Exp == (1u << 11)-1 && + temp.IEEE.Frac); } // --------------------------------------------------------------------------- @@ -125,7 +129,9 @@ AI_FORCE_INLINE bool is_qnan(double in) * @param in Input value */ AI_FORCE_INLINE bool is_special_float(float in) { - return (reinterpret_cast<_IEEESingle*>(&in)->IEEE.Exp == (1u << 8)-1); + _IEEESingle temp; + memcpy(&temp, &in, sizeof(float)); + return (temp.IEEE.Exp == (1u << 8)-1); } // --------------------------------------------------------------------------- @@ -135,7 +141,9 @@ AI_FORCE_INLINE bool is_special_float(float in) * @param in Input value */ AI_FORCE_INLINE bool is_special_float(double in) { - return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1); + _IEEESingle temp; + memcpy(&temp, &in, sizeof(float)); + return (temp.IEEE.Exp == (1u << 11)-1); } // --------------------------------------------------------------------------- From bbb60c29f09f2ed378fcbe5063851b476f4bfadc Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 1 Jun 2018 12:20:16 +0300 Subject: [PATCH 028/124] Fix strict aliasing violation in MaterialSystem --- code/MaterialSystem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index 97892658f..c8262dff0 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -354,8 +354,9 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, return AI_FAILURE; } // Determine mapping type - aiTextureMapping mapping = aiTextureMapping_UV; - aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index),(int*)&mapping); + int mapping_ = static_cast(aiTextureMapping_UV); + aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index), &mapping_); + aiTextureMapping mapping = static_cast(mapping_); if (_mapping) *_mapping = mapping; From 6788d7b18b284e1efa02e59e91a3dba4b52072f6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 1 Jun 2018 12:28:33 +0300 Subject: [PATCH 029/124] 3DS: Fix strict aliasing violations --- code/3DSConverter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index e07ca4c2d..7ec79ba64 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -204,8 +204,9 @@ void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type) mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); // Setup the texture mapping mode - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0)); + int mapMode = static_cast(texture.mMapMode); + mat.AddProperty(&mapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); + mat.AddProperty(&mapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0)); // Mirroring - double the scaling values // FIXME: this is not really correct ... @@ -313,7 +314,8 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat, case D3DS::Discreet3DS::Blinn : eShading = aiShadingMode_Blinn; break; } - mat.AddProperty( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL); + int eShading_ = static_cast(eShading); + mat.AddProperty(&eShading_, 1, AI_MATKEY_SHADING_MODEL); // DIFFUSE texture if( oldMat.sTexDiffuse.mMapName.length() > 0) From b0b604850207a4bf11bc0b4d4f7ce10538c44cc5 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 1 Jun 2018 12:37:21 +0300 Subject: [PATCH 030/124] LWOMaterial: Fix strict aliasing violations --- code/LWOMaterial.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index f4f43ced6..15c210460 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -253,7 +253,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex pcMat->AddProperty((int*)&temp,1,AI_MATKEY_TEXOP(type,cur)); // setup the mapping mode - pcMat->AddProperty((int*)&mapping,1,AI_MATKEY_MAPPING(type,cur)); + int mapping_ = static_cast(mapping); + pcMat->AddProperty(&mapping_, 1, AI_MATKEY_MAPPING(type, cur)); // add the u-wrapping temp = (unsigned int)GetMapMode(texture.wrapModeWidth); @@ -365,7 +366,8 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) } if (surf.mMaximumSmoothAngle <= 0.0) m = aiShadingMode_Flat; - pcMat->AddProperty((int*)&m,1,AI_MATKEY_SHADING_MODEL); + int m_ = static_cast(m); + pcMat->AddProperty(&m_, 1, AI_MATKEY_SHADING_MODEL); // (the diffuse value is just a scaling factor) // If a diffuse texture is set, we set this value to 1.0 From f15dcf7663782e63334dc1c725b9a3ee4a7af7fa Mon Sep 17 00:00:00 2001 From: Sebastian Maisch Date: Fri, 1 Jun 2018 17:32:02 +0200 Subject: [PATCH 031/124] Added forced generation of normals with extra flag. --- code/GenFaceNormalsProcess.cpp | 5 +++-- code/GenFaceNormalsProcess.h | 3 ++- code/GenVertexNormalsProcess.cpp | 18 +++++++++++++++--- code/GenVertexNormalsProcess.h | 1 + include/assimp/postprocess.h | 5 ++++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/code/GenFaceNormalsProcess.cpp b/code/GenFaceNormalsProcess.cpp index 6c222e154..30a26b898 100644 --- a/code/GenFaceNormalsProcess.cpp +++ b/code/GenFaceNormalsProcess.cpp @@ -74,6 +74,7 @@ GenFaceNormalsProcess::~GenFaceNormalsProcess() // Returns whether the processing step is present in the given flag field. bool GenFaceNormalsProcess::IsActive( unsigned int pFlags) const { + force_ = (pFlags & aiProcess_ForceGenNormals) != 0; return (pFlags & aiProcess_GenNormals) != 0; } @@ -106,8 +107,8 @@ void GenFaceNormalsProcess::Execute( aiScene* pScene) bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) { if (NULL != pMesh->mNormals) { - // return false; - delete[] pMesh->mNormals; + if (force_) delete[] pMesh->mNormals; + else return false; } // If the mesh consists of lines and/or points but not of diff --git a/code/GenFaceNormalsProcess.h b/code/GenFaceNormalsProcess.h index 27ae7acac..e2f41e07f 100644 --- a/code/GenFaceNormalsProcess.h +++ b/code/GenFaceNormalsProcess.h @@ -78,7 +78,8 @@ public: private: - bool GenMeshFaceNormals (aiMesh* pcMesh); + bool GenMeshFaceNormals(aiMesh* pcMesh); + mutable bool force_ = false; }; } // end of namespace Assimp diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index e0783b0a2..74139a646 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -72,6 +72,7 @@ GenVertexNormalsProcess::~GenVertexNormalsProcess() { // Returns whether the processing step is present in the given flag field. bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const { + force_ = (pFlags & aiProcess_ForceGenNormals) != 0; return (pFlags & aiProcess_GenSmoothNormals) != 0; } @@ -113,9 +114,9 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene) bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int meshIndex) { if (NULL != pMesh->mNormals) { - delete[] pMesh->mNormals; + if (force_) delete[] pMesh->mNormals; + else return false; } -// return false; // If the mesh consists of lines and/or points but not of // triangles or higher-order polygons the normal vectors @@ -147,7 +148,18 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]]; - const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)); + + auto pV12 = *pV2 - *pV1; + auto pV31 = *pV3 - *pV1; + + const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize(); + + if (std::isnan(vNor.x) || std::isnan(vNor.y) || std::isnan(vNor.z)) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { + pMesh->mNormals[face.mIndices[i]] = aiVector3D(0.0f, 0.0f, 0.0f); + } + continue; + } for (unsigned int i = 0;i < face.mNumIndices;++i) { pMesh->mNormals[face.mIndices[i]] = vNor; diff --git a/code/GenVertexNormalsProcess.h b/code/GenVertexNormalsProcess.h index 5ab9eb6f5..2efafa302 100644 --- a/code/GenVertexNormalsProcess.h +++ b/code/GenVertexNormalsProcess.h @@ -107,6 +107,7 @@ private: /** Configuration option: maximum smoothing angle, in radians*/ ai_real configMaxAngle; + mutable bool force_ = false; }; } // end of namespace Assimp diff --git a/include/assimp/postprocess.h b/include/assimp/postprocess.h index f6c0833ee..1cb9c72f8 100644 --- a/include/assimp/postprocess.h +++ b/include/assimp/postprocess.h @@ -555,10 +555,13 @@ enum aiPostProcessSteps * of the imported model. And if so, it uses that. */ aiProcess_EmbedTextures = 0x10000000, - + // aiProcess_GenEntityMeshes = 0x100000, // aiProcess_OptimizeAnimations = 0x200000 // aiProcess_FixTexturePaths = 0x200000 + + + aiProcess_ForceGenNormals = 0x20000000, }; From 5f820fb6d6bbf55d33292f6719c9083c10d915c3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 3 Jun 2018 17:21:46 +0200 Subject: [PATCH 032/124] Update appveyor.yml Add Inno setup path to PATH variable. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 3b4b3144e..d574dafa6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ install: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" + - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: From 90549e9680ced21beea680525a93aadfabb948b6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 3 Jun 2018 21:29:23 +0200 Subject: [PATCH 033/124] Update script.iss Adapt names of dll only for VS2017 --- packaging/windows-innosetup/script.iss | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8056e31ac..8debcb494 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -30,16 +30,12 @@ Name: "help"; Description: "Help Files"; Types: full compact Name: "samples"; Description: "Samples"; Types: full Name: "test"; Description: "Test Models (BSD-licensed)"; Types: full Name: "test_nonbsd"; Description: "Test Models (other (free) licenses)"; Types: full -Name: "pyassimp"; Description: "Python Bindings"; Types: full -Name: "dassimp"; Description: "D Bindings"; Types: full -Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] ;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (64 Bit)"; Check: IsWin64 [Files] - Source: "readme_installer.txt"; DestDir: "{app}"; Flags: isreadme ; Installer stub @@ -55,15 +51,15 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" -;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" -Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools @@ -75,7 +71,7 @@ Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" +Source: "..\..\lib\release\assimp-vc141-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples From 24d49b0cc764e489dae5e9a4985c58cf683681a7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 09:01:17 +0200 Subject: [PATCH 034/124] Update appveyor.yml Add download request for the redistributables. --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index d574dafa6..aa2d8bc10 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,6 +33,8 @@ install: - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" + - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe + - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: From 20bfb3662f55decd0cc7b0186b9c65b7db26d60f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 11:53:44 +0200 Subject: [PATCH 035/124] Update script.iss FIx buggy names of dlls. --- packaging/windows-innosetup/script.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8debcb494..8364e51e2 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -51,14 +51,14 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -;Source: "..\..\bin\release\x86\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools From 37ed614b70bc29a00d08dcb97a0ce79317458b1c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 15:02:37 +0200 Subject: [PATCH 036/124] Update appveyor.yml Run inno script after build. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index aa2d8bc10..2b5f212f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,7 +35,6 @@ install: - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: - code\assimp.dir\%CONFIGURATION% @@ -54,6 +53,7 @@ build: project: Assimp.sln after_build: + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss - 7z a assimp.7z bin\%CONFIGURATION%\* lib\%CONFIGURATION%\* test_script: From c46008055c2f0a29126d64fffbc21f7cd60f93fc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 21:41:58 +0200 Subject: [PATCH 037/124] Update script.iss Directx: Use install path on appyevor image. --- packaging/windows-innosetup/script.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8364e51e2..471c3a53d 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,8 +53,8 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries From ab301c1acc687945fc7bc6fa35dc991d4c3f8083 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 22:08:20 +0200 Subject: [PATCH 038/124] Update script.iss - Fix x64-folders shwing to DirectX dlls - Remove dead code - Put doc copy ops for installer into brackets. --- packaging/windows-innosetup/script.iss | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 471c3a53d..33fadb57b 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -60,18 +60,18 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation -Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help -Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help -Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help +:Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\assimp-vc141-mt.lib"; DestDir: "{app}\lib\x64" +Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples @@ -93,15 +93,6 @@ Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; ;Source: "..\..\test\regression\*"; DestDir: "{app}\test\regression"; Flags: recursesubdirs; Components: test ;Source: "..\..\test\models-nonbsd\*"; DestDir: "{app}\test\models-nonbsd"; Flags: recursesubdirs; Components: test_nonbsd -; Source Code & Workspaces -;Source: "..\..\code\*"; Excludes: "*.o"; DestDir: "{app}\code"; Flags: recursesubdirs; Components: wsource -;Source: "..\..\workspaces\vc8\*.sln"; DestDir: "{app}\workspaces\vc8"; Components: wsource and vc8 -;Source: "..\..\workspaces\vc8\*.vcproj"; DestDir: "{app}\workspaces\vc8"; Components: wsource and vc8 -;Source: "..\..\workspaces\vc9\*.sln"; DestDir: "{app}\workspaces\vc9"; Components: wsource and vc9 -;Source: "..\..\workspaces\vc9\*.vcproj"; DestDir: "{app}\workspaces\vc9"; Components: wsource and vc9 - -; Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme - [Icons] Name: "{group}\Assimp Manual"; Filename: "{app}\doc\AssimpDoc.chm" ; Components: help Name: "{group}\Assimp Command Line Manual"; Filename: "{app}\doc\AssimpCmdDoc.chm"; Components: help From 12438bcdb2ae185c5487bcc3496b4c2cefe5ad9a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 22:37:05 +0200 Subject: [PATCH 039/124] Update script.iss Typ fix --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 33fadb57b..132054e88 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From d55525d16b9f0f929c4689eaab899d32fec4324b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jun 2018 10:25:35 +0200 Subject: [PATCH 040/124] Update script.iss Fix folders to DX-dlls. --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 132054e88..bed974f70 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From c313d5a3e9ad56cf50a446ea2a06ee142fc30217 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jun 2018 10:55:51 +0200 Subject: [PATCH 041/124] Update script.iss Fix folders ... again --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index bed974f70..136b828c3 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Windows\SysWOW64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Windows\SysWOW64\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Windows\SysWOW64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Windows\SysWOW64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From de088328aad6b9397989b49537790f3df0f93d17 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Tue, 5 Jun 2018 11:27:24 +0200 Subject: [PATCH 042/124] replace typo by comment statement. --- packaging/windows-innosetup/script.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 136b828c3..6c4b9cd37 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -67,7 +67,7 @@ Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Comp ; Documentation ;Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help ;Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help -:Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" From e07aedac9e24eb8164043ab56da7b044b0ca1b0a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 6 Jun 2018 10:39:17 +0200 Subject: [PATCH 043/124] Update script.iss add missing components andput the into brackets. --- packaging/windows-innosetup/script.iss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 6c4b9cd37..695740679 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -30,6 +30,9 @@ Name: "help"; Description: "Help Files"; Types: full compact Name: "samples"; Description: "Samples"; Types: full Name: "test"; Description: "Test Models (BSD-licensed)"; Types: full Name: "test_nonbsd"; Description: "Test Models (other (free) licenses)"; Types: full +;Name: "pyassimp"; Description: "Python Bindings"; Types: full +;Name: "dassimp"; Description: "D Bindings"; Types: full +;Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] ;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 @@ -80,7 +83,7 @@ Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Comp Source: "..\..\include\*"; DestDir: "{app}\include"; Flags: recursesubdirs ; dAssimp -Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; Components: dassimp +;Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; Components: dassimp ; Assimp.NET ;Source: "..\..\port\Assimp.NET\*"; DestDir: "{app}\port\C#"; Flags: recursesubdirs; Components: assimp_net From 85b0026c922460dac3ccf39f2a5e8b3d175ac6cc Mon Sep 17 00:00:00 2001 From: CwTCwT Date: Sat, 9 Jun 2018 15:45:09 +0200 Subject: [PATCH 044/124] issue_1973 added support for CustomData(Layer) to support multiple (texture) UV mappings added unittest with sample model --- code/BlenderCustomData.cpp | 212 ++++++++++++++++++ code/BlenderCustomData.h | 101 +++++++++ code/BlenderDNA.h | 22 ++ code/BlenderDNA.inl | 118 ++++++++++ code/BlenderLoader.cpp | 78 ++++++- code/BlenderScene.cpp | 45 ++++ code/BlenderScene.h | 83 ++++++- code/BlenderSceneGen.h | 11 + code/CMakeLists.txt | 2 + code/STLLoader.cpp | 25 ++- .../plane_2_textures_2_texcoords_279.blend | Bin 0 -> 512624 bytes test/unit/utBlendImportMaterials.cpp | 27 +++ 12 files changed, 707 insertions(+), 17 deletions(-) create mode 100644 code/BlenderCustomData.cpp create mode 100644 code/BlenderCustomData.h create mode 100644 test/models/BLEND/plane_2_textures_2_texcoords_279.blend diff --git a/code/BlenderCustomData.cpp b/code/BlenderCustomData.cpp new file mode 100644 index 000000000..7f518b782 --- /dev/null +++ b/code/BlenderCustomData.cpp @@ -0,0 +1,212 @@ +#pragma once + +#include "BlenderCustomData.h" +#include + +namespace Assimp { + namespace Blender + { + /** + * @brief read/convert of Structure array to memory + */ + template + bool read(const Structure &s, T *p, const size_t cnt, const FileDatabase &db) { + for (size_t i = 0; i < cnt; ++i) { + T read; + s.Convert(read, db); + *p = read; + p++; + } + return true; + } + + /** + * @brief pointer to function read memory for n CustomData types + */ + typedef bool(*PRead)(void *pOut, const size_t cnt, const FileDatabase &db); + /** + * @brief pointer to function read memory for cnt CustomData types + */ + typedef void *(*PAlloc)(const size_t cnt); + + /** + * @brief helper macro to define Structure specific read function + * for ex: when used like + * + * IMPL_STRUCT_READ(MLoop) + * + * following function is implemented + * + * bool readMLoop(void *v, const size_t cnt, const FileDatabase &db) { + * return read(db.dna["MLoop"], static_cast(v), cnt, db); + * } + */ +#define IMPL_STRUCT_READ(ty) \ + bool read##ty(void *v, const size_t cnt, const FileDatabase &db) { \ + return read(db.dna[#ty], static_cast(v), cnt, db); \ + } + + /** + * @brief helper macro to define Structure specific alloc function + * for ex: when used like + * + * IMPL_STRUCT_ALLOC(MLoop) + * + * following function is implemented + * + * void * allocMLoop(const size_t cnt) { + * return new uint8_t[cnt * sizeof MLoop]; + * } + */ +#define IMPL_STRUCT_ALLOC(ty) \ + void *alloc##ty(const size_t cnt) { \ + return new uint8_t[cnt * sizeof ty]; \ + } + + /** + * @brief helper macro to define Structure functions + */ +#define IMPL_STRUCT(ty) \ + IMPL_STRUCT_ALLOC(ty) \ + IMPL_STRUCT_READ(ty) + + // supported structures for CustomData + IMPL_STRUCT(MVert) + IMPL_STRUCT(MEdge) + IMPL_STRUCT(MFace) + IMPL_STRUCT(MTFace) + IMPL_STRUCT(MTexPoly) + IMPL_STRUCT(MLoopUV) + IMPL_STRUCT(MLoopCol) + IMPL_STRUCT(MPoly) + IMPL_STRUCT(MLoop) + + /** + * @brief describes the size of data and the read function to be used for single CustomerData.type + */ + struct CustomDataTypeDescription + { + PRead Read; ///< function to read one CustomData type element + PAlloc Alloc; ///< function to allocate n type elements + }; + + /** + * @brief shortcut for array of CustomDataTypeDescription + */ + typedef std::array CustomDataTypeDescriptions; + + /** + * @brief helper macro to define Structure type specific CustomDataTypeDescription + * @note IMPL_STRUCT_READ for same ty must be used earlier to implement the typespecific read function + */ +#define DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(ty) \ + CustomDataTypeDescription{ &read##ty, &alloc##ty } + + /** + * @brief helper macro to define CustomDataTypeDescription for UNSUPPORTED type + */ +#define DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION \ + CustomDataTypeDescription{ nullptr, nullptr } + + /** + * @brief descriptors for data pointed to from CustomDataLayer.data + * @note some of the CustomData uses already well defined Structures + * other (like CD_ORCO, ...) uses arrays of rawtypes or even arrays of Structures + * use a special readfunction for that cases + */ + CustomDataTypeDescriptions customDataTypeDescriptions = + { + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MVert), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MEdge), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MFace), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTFace), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTexPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopUV), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopCol), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoop), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION + }; + + + bool isValidCustomDataType(const int cdtype) + { + return cdtype >= 0 && cdtype < CD_NUMTYPES; + } + + bool readCustomData(std::shared_ptr &out, const CustomDataType cdtype, const size_t cnt, const FileDatabase &db) + { + if (!isValidCustomDataType(cdtype)) + { + throw Error((Formatter::format(), "CustomData.type ", cdtype, " out of index")); + } + + const CustomDataTypeDescription cdtd = customDataTypeDescriptions[cdtype]; + if (cdtd.Read && cdtd.Alloc) + { + // allocate cnt elements and parse them from file + out.reset(cdtd.Alloc(cnt)); + return cdtd.Read(out.get(), cnt, db); + } + return false; + } + + std::shared_ptr getCustomDataLayer(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) + { + for (auto it = customdata.layers.begin(); it != customdata.layers.end(); ++it) + { + if (it->get()->type == cdtype && name == it->get()->name) + { + return *it; + } + } + return nullptr; + } + + const void * getCustomDataLayerData(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) + { + const std::shared_ptr pLayer = getCustomDataLayer(customdata, cdtype, name); + if (pLayer && pLayer->data) + { + return pLayer->data.get(); + } + return nullptr; + } + } +} diff --git a/code/BlenderCustomData.h b/code/BlenderCustomData.h new file mode 100644 index 000000000..b6f3641f1 --- /dev/null +++ b/code/BlenderCustomData.h @@ -0,0 +1,101 @@ +#pragma once + +#include "BlenderDNA.h" +#include "BlenderScene.h" +#include + +namespace Assimp { + namespace Blender + { + /* CustomData.type from Blender (2.79b) */ + enum CustomDataType + { + CD_AUTO_FROM_NAME = -1, + CD_MVERT = 0, +#ifdef DNA_DEPRECATED + CD_MSTICKY = 1, /* DEPRECATED */ +#endif + CD_MDEFORMVERT = 2, + CD_MEDGE = 3, + CD_MFACE = 4, + CD_MTFACE = 5, + CD_MCOL = 6, + CD_ORIGINDEX = 7, + CD_NORMAL = 8, + /* CD_POLYINDEX = 9, */ + CD_PROP_FLT = 10, + CD_PROP_INT = 11, + CD_PROP_STR = 12, + CD_ORIGSPACE = 13, /* for modifier stack face location mapping */ + CD_ORCO = 14, + CD_MTEXPOLY = 15, + CD_MLOOPUV = 16, + CD_MLOOPCOL = 17, + CD_TANGENT = 18, + CD_MDISPS = 19, + CD_PREVIEW_MCOL = 20, /* for displaying weightpaint colors */ + /* CD_ID_MCOL = 21, */ + CD_TEXTURE_MLOOPCOL = 22, + CD_CLOTH_ORCO = 23, + CD_RECAST = 24, + + /* BMESH ONLY START */ + CD_MPOLY = 25, + CD_MLOOP = 26, + CD_SHAPE_KEYINDEX = 27, + CD_SHAPEKEY = 28, + CD_BWEIGHT = 29, + CD_CREASE = 30, + CD_ORIGSPACE_MLOOP = 31, + CD_PREVIEW_MLOOPCOL = 32, + CD_BM_ELEM_PYPTR = 33, + /* BMESH ONLY END */ + + CD_PAINT_MASK = 34, + CD_GRID_PAINT_MASK = 35, + CD_MVERT_SKIN = 36, + CD_FREESTYLE_EDGE = 37, + CD_FREESTYLE_FACE = 38, + CD_MLOOPTANGENT = 39, + CD_TESSLOOPNORMAL = 40, + CD_CUSTOMLOOPNORMAL = 41, + + CD_NUMTYPES = 42 + }; + + /** + * @brief check if given cdtype is valid (ie >= 0 and < CD_NUMTYPES) + * @param[in] cdtype to check + * @return true when valid + */ + bool isValidCustomDataType(const int cdtype); + + /** + * @brief read CustomData's data to ptr to mem + * @param[out] out memory ptr to set + * @param[in] cdtype to read + * @param[in] cnt cnt of elements to read + * @param[in] db to read elements from + * @return true when ok + */ + bool readCustomData(std::shared_ptr &out, CustomDataType cdtype, size_t cnt, const FileDatabase &db); + + /** + * @brief returns CustomDataLayer ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return CustomDataLayer * or nullptr if not found + */ + std::shared_ptr getCustomDataLayer(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + + /** + * @brief returns CustomDataLayer data ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return CustomDataLayer * or nullptr if not found + */ + const void * getCustomDataLayerData(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + } +} diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h index 6a18fe9fa..d2b897d3a 100644 --- a/code/BlenderDNA.h +++ b/code/BlenderDNA.h @@ -309,6 +309,28 @@ public: void ReadField(T& out, const char* name, const FileDatabase& db) const; + // -------------------------------------------------------- + /** + * @brief field parsing for dynamic vectors + * @param[in] out vector of struct to be filled + * @param[in] name of field + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template class TOUT, typename T> + bool ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const; + + /** + * @brief parses raw customdata + * @param[in] out shared_ptr to be filled + * @param[in] cdtype customdata type to read + * @param[in] name of field ptr + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template + bool ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const; + private: // -------------------------------------------------------- diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index e43d15d38..ae48a5896 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -307,6 +307,124 @@ void Structure :: ReadField(T& out, const char* name, const FileDatabase& db) co } +//-------------------------------------------------------------------------------- +// field parsing for raw untyped data (like CustomDataLayer.data) +template +bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const +{ + if (!isValidCustomDataType(cdtype)) + { + ASSIMP_LOG_ERROR("given rawtype out of index"); + return false; + } + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try + { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) + { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) + { + _defaultInitializer()(out, e.what()); + out.reset(); + } + + bool readOk = true; + if (ptrval.val) + { + // get block for ptr + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // read block->num instances of given type to out + readOk = readCustomData(out, static_cast(cdtype), block->num, db); + } + + // and recover the previous stream position + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return readOk; +} + +//-------------------------------------------------------------------------------- +template class TOUT, typename T> +bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const +{ + out.clear(); + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try + { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) + { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) + { + _defaultInitializer()(out, e.what()); + out.clear(); + return false; + } + + + if (ptrval.val) + { + // find the file block the pointer is pointing to + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // FIXME: basically, this could cause problems with 64 bit pointers on 32 bit systems. + // I really ought to improve StreamReader to work with 64 bit indices exclusively. + + const Structure& s = db.dna[f->type]; + for (size_t i = 0; i < block->num; ++i) + { + TOUT p(new T); + s.Convert(*p, db); + out.push_back(p); + } + } + + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return false; +} + + //-------------------------------------------------------------------------------- template