From 3ca6b1081080355724cf02ceb31fcace1838fbb0 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 19 Mar 2018 13:17:18 +0200 Subject: [PATCH 001/214] 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/214] 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/214] 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/214] 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/214] 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/214] 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/214] 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 814b56e5e2c6da331c6b4f71b5f167ff2fa5afb1 Mon Sep 17 00:00:00 2001 From: wuxq Date: Sat, 28 Apr 2018 15:05:21 +0800 Subject: [PATCH 008/214] multi joint has bug with ReplaceData multi joint has a bug in ReplaceData_joint with "bin" change --- code/glTF2Exporter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index fcf8005ae..9bd9bae33 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -642,9 +642,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefbufferView->byteLength; unsigned int s_bytesPerComp= ComponentTypeSize(ComponentType_UNSIGNED_SHORT); unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType); - unsigned int s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp; Ref buf = vertexJointAccessor->bufferView->buffer; - uint8_t* arrys = new uint8_t[s_bytesLen]; + uint8_t* arrys = new uint8_t[bytesLen]; unsigned int i = 0; for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){ size_t len_p = offset + j; @@ -655,7 +654,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefReplaceData_joint(offset, bytesLen, arrys, s_bytesLen); + buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen); vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT; p.attributes.joint.push_back( vertexJointAccessor ); From ce11aa51f5085e76303ad5c26318cad7a7cbbd62 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 7 May 2018 00:07:41 +0200 Subject: [PATCH 009/214] 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 010/214] 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 cc1bde0514773ff9b96ca2284215e20545017f4a Mon Sep 17 00:00:00 2001 From: wuxq Date: Tue, 8 May 2018 18:31:27 +0800 Subject: [PATCH 011/214] change the length of bufferView byteLength chang the joint attribute bufferView byteLength --- code/glTF2Exporter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 431046d72..041250bee 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -642,6 +642,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefbufferView->byteLength; unsigned int s_bytesPerComp= ComponentTypeSize(ComponentType_UNSIGNED_SHORT); unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType); + unsigned int s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp; Ref buf = vertexJointAccessor->bufferView->buffer; uint8_t* arrys = new uint8_t[bytesLen]; unsigned int i = 0; @@ -656,6 +657,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefReplaceData_joint(offset, bytesLen, arrys, bytesLen); vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT; + vertexJointAccessor->bufferView->byteLength = s_bytesLen; p.attributes.joint.push_back( vertexJointAccessor ); } From 60d803f49050344f761010ac91750aa5ce67531d Mon Sep 17 00:00:00 2001 From: kimkulling Date: Wed, 9 May 2018 09:51:05 +0200 Subject: [PATCH 012/214] Some minor fixes of typos and formatting issues. --- tools/assimp_view/AnimEvaluator.cpp | 3 +- tools/assimp_view/Display.cpp | 24 ++-- tools/assimp_view/MessageProc.cpp | 31 ++--- tools/assimp_view/assimp_view.cpp | 8 +- tools/assimp_view/assimp_view.rc | 169 ++++++++++++---------------- 5 files changed, 102 insertions(+), 133 deletions(-) diff --git a/tools/assimp_view/AnimEvaluator.cpp b/tools/assimp_view/AnimEvaluator.cpp index 0d6c7c75a..94c581df4 100644 --- a/tools/assimp_view/AnimEvaluator.cpp +++ b/tools/assimp_view/AnimEvaluator.cpp @@ -3,7 +3,7 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2015, assimp team +Copyright (c) 2006-2018, assimp team All rights reserved. @@ -40,6 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "assimp_view.h" + #include using namespace AssimpView; diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 7d986fa9c..207c26fa9 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -96,8 +96,9 @@ D3DXVECTOR4 g_aclNormalColors[14] = void GetNodeCount(aiNode* pcNode, unsigned int* piCnt) { *piCnt = *piCnt+1; - for (unsigned int i = 0; i < pcNode->mNumChildren;++i) - GetNodeCount(pcNode->mChildren[i],piCnt); + for (unsigned int i = 0; i < pcNode->mNumChildren; ++i) { + GetNodeCount(pcNode->mChildren[i], piCnt); + } } //------------------------------------------------------------------------------- @@ -1042,16 +1043,23 @@ int CDisplay::OnSetupTextureView(TextureInfo* pcNew) switch (pcNew->eOp) { case aiTextureOp_Add: - szOp = "add";break; + szOp = "add"; + break; case aiTextureOp_Subtract: - szOp = "sub";break; + szOp = "sub"; + break; case aiTextureOp_Divide: - szOp = "div";break; + szOp = "div"; + break; case aiTextureOp_SignedAdd: - szOp = "addsign";break; + szOp = "addsign"; + break; case aiTextureOp_SmoothAdd: - szOp = "addsmooth";break; - default: szOp = "mul"; + szOp = "addsmooth"; + break; + default: + szOp = "mul"; + break; }; SetWindowText(GetDlgItem(g_hDlg,IDC_ELOAD),szOp); diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 71bc5c8bb..695e8cfd6 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -80,8 +80,7 @@ void SaveHistory(); // File associations are registered in HKCU\Software\Classes. They might // be overwritten by global file associations. //------------------------------------------------------------------------------- -void MakeFileAssociations() - { +void MakeFileAssociations() { char szTemp2[MAX_PATH]; char szTemp[MAX_PATH + 10]; @@ -1399,7 +1398,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, g_hDlg = hwndDlg; - // load the state of the usr interface + // load the state of the user interface InitUI(); // load the file history @@ -1643,11 +1642,6 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, xPos = xPos2 = sPoint.x; yPos = yPos2 = sPoint.y; - /* xPos -= 10; - yPos -= 10; - xPos2 = xPos-3; - yPos2 = yPos-5;*/ - RECT sRect; GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect); sRect.right -= sRect.left; @@ -1830,7 +1824,6 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, return TRUE; case WM_COMMAND: - HMENU hMenu = GetMenu(g_hDlg); if (ID_VIEWER_QUIT == LOWORD(wParam)) { @@ -2361,7 +2354,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) - { +{ UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); @@ -2371,14 +2364,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // load windows common controls library to get XP style InitCommonControls(); - // intiailize the IDirect3D9 interface + // initialize the IDirect3D9 interface g_hInstance = hInstance; - if (0 == InitD3D()) - { + if (0 == InitD3D()) { MessageBox(NULL,"Failed to initialize Direct3D 9", "ASSIMP ModelViewer",MB_OK); return -6; - } + } // create the main dialog HWND hDlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN), @@ -2395,12 +2387,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, Assimp::DefaultLogger::Debugging | Assimp::DefaultLogger::Info | Assimp::DefaultLogger::Err | Assimp::DefaultLogger::Warn); - if (NULL == hDlg) - { + if (NULL == hDlg) { MessageBox(NULL,"Failed to create dialog from resource", "ASSIMP ModelViewer",MB_OK); return -5; - } + } // display the window g_hDlg = hDlg; @@ -2410,12 +2401,12 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, UpdateWindow( hDlg ); // create the D3D device object - if (0 == CreateDevice(g_sOptions.bMultiSample,false,true)) - { + if (0 == CreateDevice(g_sOptions.bMultiSample,false,true)) { MessageBox(NULL,"Failed to initialize Direct3D 9 (2)", "ASSIMP ModelViewer",MB_OK); return -4; - } + } + CLogDisplay::Instance().AddEntry("[OK] Here we go!"); // create the log window diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index e68b20a00..ac2d1e66d 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -143,7 +143,7 @@ float g_fLoadTime = 0.0f; //------------------------------------------------------------------------------- // Entry point for the loader thread -// The laoder thread loads the asset while the progress dialog displays the +// The loader thread loads the asset while the progress dialog displays the // smart progress bar //------------------------------------------------------------------------------- DWORD WINAPI LoadThreadProc(LPVOID lpParameter) @@ -200,9 +200,9 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) // load the current asset // THe path to the asset is specified in the global path variable //------------------------------------------------------------------------------- -int LoadAsset(void) +int LoadAsset() { - // 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(); @@ -1130,8 +1130,6 @@ int GetProjectionMatrix (aiMatrix4x4& p_mOut) return 1; } - -//------------------------------------------------------------------------------- //------------------------------------------------------------------------------- aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut) { diff --git a/tools/assimp_view/assimp_view.rc b/tools/assimp_view/assimp_view.rc index 093b860fc..aca323b09 100644 --- a/tools/assimp_view/assimp_view.rc +++ b/tools/assimp_view/assimp_view.rc @@ -15,13 +15,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources +// Deutsch (Deutschland) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -32,6 +30,7 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN // remains consistent on all systems. IDI_ASSIMP_VIEW ICON "../shared/assimp_tools_icon.ico" + ///////////////////////////////////////////////////////////////////////////// // // Dialog @@ -49,104 +48,63 @@ BEGIN LTEXT "http://assimp.sourceforge.net http://www.zfx.info",IDC_STATIC,31,101,127,22 DEFPUSHBUTTON "Love this library",IDOK,186,110,84,14 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,148,283,1 - CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,0,129,514,20 + CONTROL IDB_BITMAP1,IDC_STATIC,"Static",SS_BITMAP,0,129,514,20 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,10,281,1 END -#define X_GROUP1 7 -#define W_GROUP1 6+160+6 -#define X_GROUP2 X_GROUP1+W_GROUP1+7 -#define W_GROUP2 6+150+8 -#define X_GROUP3 X_GROUP2+W_GROUP2+7 -#define W_GROUP3 6+60+35+8 - -#define W X_GROUP3+W_GROUP3+47 -#define H 450 - -#define Y_PANEL H-12-82-7-7-14-4 -#define Y_GROUPS Y_PANEL+14+7 - -#define TREE_W 143 -#define COMBO_W 100 - -IDD_DIALOGMAIN DIALOGEX 0, 0, W+TREE_W, H -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_DIALOGMAIN DIALOGEX 0, 0, 656, 450 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES | WS_EX_WINDOWEDGE CAPTION "Open Asset Import Library - Model Viewer " MENU IDR_MENU1 FONT 8, "Microsoft Sans Serif", 400, 0, 0x0 BEGIN - - CONTROL "",IDC_RT,"Static",SS_OWNERDRAW,0,0,W,Y_PANEL - CONTROL "",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS|TVS_HASLINES|TVS_SHOWSELALWAYS|WS_BORDER|WS_HSCROLL|WS_TABSTOP, W,0,TREE_W,H - -#define Y Y_PANEL+4 - CONTROL "<<",IDC_BLUBB,"Button",BS_AUTOCHECKBOX|BS_PUSHLIKE|WS_TABSTOP, W-7-35,Y,35,14 - COMBOBOX IDC_COMBO1, W-7-35-4-100,Y,100,14, CBS_DROPDOWN|WS_VSCROLL|WS_TABSTOP - PUSHBUTTON "Play",IDC_PLAY, W-7-35-4-100-35-4,Y,35,14 - CONTROL "",IDC_SLIDERANIM,"msctls_trackbar32",TBS_AUTOTICKS|TBS_BOTH|TBS_NOTICKS|WS_TABSTOP, 0,Y,W-7-35-4-100-35-4,15 - -#undef Y -#define Y Y_GROUPS+12 -#define X X_GROUP1+6 - - GROUPBOX "Display",IDC_STATIC, X_GROUP1,Y_GROUPS,W_GROUP1,12+82+7 - - CONTROL "Multisampling [M]",IDC_TOGGLEMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y,80,10 - CONTROL "Wireframe [W]",IDC_TOGGLEWIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+12,80,10 - CONTROL "No materials [D]",IDC_TOGGLEMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+24,80,10 - CONTROL "Display normals [N]",IDC_TOGGLENORMALS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+36,80,10 - CONTROL "Low quality [P]",IDC_LOWQUALITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+48,80,10 - CONTROL "No specular [S]",IDC_NOSPECULAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+60,80,10 - CONTROL "Show skeleton [K]",IDC_SHOWSKELETON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X,Y+72,80,10 - - CONTROL "AutoRotate [A]",IDC_AUTOROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y,80,10 - CONTROL "Zoom/Rotate [Z]",IDC_ZOOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y+12,80,10 - CONTROL "Rotate lights [R]",IDC_LIGHTROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y+24,80,10 - CONTROL "Two lights [L]",IDC_3LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y+36,80,10 - CONTROL "Backface culling [C]",IDC_BFCULL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y+48,80,10 - CONTROL "No transparency [T]",IDC_NOAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, X+80,Y+60,80,10 - -#undef X -#define X X_GROUP2+6 - - GROUPBOX "Statistics",IDC_STATIC, X_GROUP2,Y_GROUPS,W_GROUP2,12+36+8+7 - - LTEXT "Vertices:",IDC_NUMVERTS, X,Y,35,8 - LTEXT "Nodes:",IDC_NUMNODES, X,Y+12,35,8 - LTEXT "Shaders:",IDC_NUMSHADERS, X,Y+24,35,8 - LTEXT "Time:",IDC_LOADTIME, X,Y+36,35,8 - - EDITTEXT IDC_EVERT, X+35,Y,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_ENODEWND, X+35,Y+12,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_ESHADER, X+35,Y+24,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_ELOAD, X+35,Y+36,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - - LTEXT "Faces:",IDC_NUMFACES, X+80,Y,35,8 - LTEXT "Materials:",IDC_NUMMATS, X+80,Y+12,35,8 - LTEXT "Meshes:",IDC_NUMMESHES, X+80,Y+24,35,8 - LTEXT "FPS:",IDC_FPS, X+80,Y+36,35,8 - - EDITTEXT IDC_EFACE, X+115,Y,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_EMAT, X+115,Y+12,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_EMESH, X+115,Y+24,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - EDITTEXT IDC_EFPS, X+115,Y+36,35,8, ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | ES_RIGHT - - EDITTEXT IDC_VIEWMATRIX, X,Y+48+7,72,44, ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_VISIBLE - -#undef X -#define X X_GROUP3+6 - - GROUPBOX "Colors",IDC_STATIC, X_GROUP3,Y_GROUPS,W_GROUP3,12+54+14+7 - - LTEXT "Primary:",IDC_STATIC, X,Y+3,48,8 - LTEXT "Secondary:",IDC_STATIC, X,Y+3+18,54,8 - LTEXT "Ambient:",IDC_STATIC, X,Y+3+36,54,8 - - CONTROL "Button1",IDC_LCOLOR1,"Button",BS_OWNERDRAW | WS_TABSTOP, X+60,Y,35,14 - CONTROL "Button1",IDC_LCOLOR2,"Button",BS_OWNERDRAW | WS_TABSTOP, X+60,Y+18,35,14 - CONTROL "Button1",IDC_LCOLOR3,"Button",BS_OWNERDRAW | WS_TABSTOP, X+60,Y+36,35,14 - PUSHBUTTON "Reset",IDC_LRESET, X+60,Y+54,35,14 + CONTROL "",IDC_RT,"Static",SS_OWNERDRAW,0,0,513,324 + CONTROL "",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,513,0,143,450 + CONTROL "<<",IDC_BLUBB,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,471,328,35,14 + COMBOBOX IDC_COMBO1,367,328,100,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Play",IDC_PLAY,328,328,35,14 + CONTROL "",IDC_SLIDERANIM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,0,328,328,15 + GROUPBOX "Display",IDC_STATIC,7,345,172,101 + CONTROL "Multisampling [M]",IDC_TOGGLEMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,357,80,10 + CONTROL "Wireframe [W]",IDC_TOGGLEWIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,369,80,10 + CONTROL "No materials [D]",IDC_TOGGLEMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,381,80,10 + CONTROL "Display normals [N]",IDC_TOGGLENORMALS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,393,80,10 + CONTROL "Low quality [P]",IDC_LOWQUALITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,405,80,10 + CONTROL "No specular [S]",IDC_NOSPECULAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,417,80,10 + CONTROL "Show skeleton [K]",IDC_SHOWSKELETON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,429,80,10 + CONTROL "AutoRotate [A]",IDC_AUTOROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,357,80,10 + CONTROL "Zoom/Rotate [Z]",IDC_ZOOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,369,80,10 + CONTROL "Rotate lights [R]",IDC_LIGHTROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,381,80,10 + CONTROL "Two lights [L]",IDC_3LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,393,80,10 + CONTROL "Backface culling [C]",IDC_BFCULL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,405,80,10 + CONTROL "No transparency [T]",IDC_NOAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,417,80,10 + GROUPBOX "Statistics",IDC_STATIC,186,345,164,63 + LTEXT "Vertices:",IDC_NUMVERTS,192,357,35,8 + LTEXT "Nodes:",IDC_NUMNODES,192,369,35,8 + LTEXT "Shaders:",IDC_NUMSHADERS,192,381,35,8 + LTEXT "Time:",IDC_LOADTIME,192,393,35,8 + EDITTEXT IDC_EVERT,227,357,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_ENODEWND,227,369,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_ESHADER,227,381,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_ELOAD,227,393,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Faces:",IDC_NUMFACES,272,357,35,8 + LTEXT "Materials:",IDC_NUMMATS,272,369,35,8 + LTEXT "Meshes:",IDC_NUMMESHES,272,381,35,8 + LTEXT "FPS:",IDC_FPS,272,393,35,8 + EDITTEXT IDC_EFACE,307,357,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_EMAT,307,369,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_EMESH,307,381,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_EFPS,307,393,35,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_VIEWMATRIX,192,412,72,44,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE | NOT WS_BORDER + GROUPBOX "Colors",IDC_STATIC,357,345,109,87 + LTEXT "Primary:",IDC_STATIC,363,360,48,8 + LTEXT "Secondary:",IDC_STATIC,363,378,54,8 + LTEXT "Ambient:",IDC_STATIC,363,396,54,8 + CONTROL "Button1",IDC_LCOLOR1,"Button",BS_OWNERDRAW | WS_TABSTOP,423,357,35,14 + CONTROL "Button1",IDC_LCOLOR2,"Button",BS_OWNERDRAW | WS_TABSTOP,423,375,35,14 + CONTROL "Button1",IDC_LCOLOR3,"Button",BS_OWNERDRAW | WS_TABSTOP,423,393,35,14 + PUSHBUTTON "Reset",IDC_LRESET,423,411,35,14 END IDD_LOADDIALOG DIALOGEX 0, 0, 143, 60 @@ -268,7 +226,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_ABOUTBOX, DIALOG BEGIN @@ -279,7 +237,6 @@ BEGIN IDD_DIALOGMAIN, DIALOG BEGIN RIGHTMARGIN, 623 - BOTTOMMARGIN, 484 END IDD_LOADDIALOG, DIALOG @@ -321,23 +278,34 @@ END // IDB_BITMAP1 BITMAP "banner.bmp" + IDB_BANIM BITMAP "base_anim.bmp" + IDB_BDISPLAY BITMAP "base_display.bmp" + IDB_BINTER BITMAP "base_inter.bmp" + IDB_BRENDERING BITMAP "base_rendering.bmp" + IDB_BSTATS BITMAP "base_stats.bmp" + IDB_BTX BITMAP "tx.bmp" + IDB_BFX BITMAP "fx.bmp" + IDB_BNODE BITMAP "n.bmp" + IDB_BROOT BITMAP "root.bmp" + IDB_BTXI BITMAP "txi.bmp" + ///////////////////////////////////////////////////////////////////////////// // // Menu // -IDR_MENU1 MENU +IDR_MENU1 MENU BEGIN POPUP "Viewer" BEGIN @@ -424,7 +392,7 @@ BEGIN END END -IDR_TXPOPUP MENU +IDR_TXPOPUP MENU BEGIN POPUP "Hey" BEGIN @@ -437,7 +405,7 @@ BEGIN MENUITEM "This is not an easter egg", 0 END -IDR_MATPOPUP MENU +IDR_MATPOPUP MENU BEGIN POPUP "So long" BEGIN @@ -473,14 +441,17 @@ END IDR_TEXT1 TEXT "text1.bin" + ///////////////////////////////////////////////////////////////////////////// // // RCDATA // IDR_HUD RCDATA "HUD.png" + IDR_HUDMASK RCDATA "HUDMask.png" -#endif // German (Germany) resources + +#endif // Deutsch (Deutschland) resources ///////////////////////////////////////////////////////////////////////////// From d441dcd5230989581ba1bc3ebbc48cc28ed816ba Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 9 May 2018 19:15:42 +0200 Subject: [PATCH 013/214] 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 014/214] 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 c08614bbff531e9e3f760595b7f0577a4dca78a0 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 10 May 2018 09:44:31 +0200 Subject: [PATCH 015/214] closes https://github.com/assimp/assimp/issues/919: add missing cast for vs2015. --- code/ColladaLoader.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 45dd52710..611e487b0 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -1819,9 +1819,12 @@ void ColladaLoader::ConvertPath (aiString& ss) // Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes... // I need to filter it without destroying linux paths starting with "/somewhere" - if( ss.data[0] == '/' && isalpha( ss.data[1]) && ss.data[2] == ':' ) - { - ss.length--; +#if defined( _MSC_VER ) + if( ss.data[0] == '/' && isalpha( (unsigned char) ss.data[1]) && ss.data[2] == ':' ) { +#else + if (ss.data[ 0 ] == '/' && isalpha( ss.data[ 1 ] ) && ss.data[ 2 ] == ':') { +#endif + --ss.length; ::memmove( ss.data, ss.data+1, ss.length); ss.data[ss.length] = 0; } From f7d0e05018cbb94afca918e72150825bae678982 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 10 May 2018 14:21:43 +0200 Subject: [PATCH 016/214] closes https://github.com/assimp/assimp/issues/1952: check for postprocessing parameter before try to parse -f --- tools/assimp_cmd/Export.cpp | 3 +- tools/assimp_cmd/Main.cpp | 75 +++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/tools/assimp_cmd/Export.cpp b/tools/assimp_cmd/Export.cpp index 55c017e33..03f896822 100644 --- a/tools/assimp_cmd/Export.cpp +++ b/tools/assimp_cmd/Export.cpp @@ -106,7 +106,8 @@ int Assimp_Export(const char* const* params, unsigned int num) continue; } if (!strncmp( params[i], "-f",2)) { - outf = std::string(params[i]+2); + if ( strncmp( params[ i ], "-fi",3 )) + outf = std::string(params[i]+2); } else if ( !strncmp( params[i], "--format=",9)) { outf = std::string(params[i]+9); diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index 14d00e1e1..41412b93d 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -261,7 +261,6 @@ void PrintHorBar() printf("-----------------------------------------------------------------\n"); } - // ------------------------------------------------------------------------------ // Import a specific file const aiScene* ImportModel( @@ -390,105 +389,101 @@ int ProcessStandardArguments( for (unsigned int i = 0; i < num;++i) { - if (! strcmp(params[i], "-ptv") || ! strcmp(params[i], "--pretransform-vertices")) { + const char *param = params[ i ]; + printf( "param = %s\n", param ); + if (! strcmp( param, "-ptv") || ! strcmp( param, "--pretransform-vertices")) { fill.ppFlags |= aiProcess_PreTransformVertices; } - else if (! strcmp(params[i], "-gsn") || ! strcmp(params[i], "--gen-smooth-normals")) { + else if (! strcmp( param, "-gsn") || ! strcmp( param, "--gen-smooth-normals")) { fill.ppFlags |= aiProcess_GenSmoothNormals; } - else if (! strcmp(params[i], "-gn") || ! strcmp(params[i], "--gen-normals")) { + else if (! strcmp( param, "-gn") || ! strcmp( param, "--gen-normals")) { fill.ppFlags |= aiProcess_GenNormals; } - else if (! strcmp(params[i], "-jiv") || ! strcmp(params[i], "--join-identical-vertices")) { + else if (! strcmp( param, "-jiv") || ! strcmp( param, "--join-identical-vertices")) { fill.ppFlags |= aiProcess_JoinIdenticalVertices; } - else if (! strcmp(params[i], "-rrm") || ! strcmp(params[i], "--remove-redundant-materials")) { + else if (! strcmp( param, "-rrm") || ! strcmp( param, "--remove-redundant-materials")) { fill.ppFlags |= aiProcess_RemoveRedundantMaterials; } - else if (! strcmp(params[i], "-fd") || ! strcmp(params[i], "--find-degenerates")) { + else if (! strcmp( param, "-fd") || ! strcmp( param, "--find-degenerates")) { fill.ppFlags |= aiProcess_FindDegenerates; } - else if (! strcmp(params[i], "-slm") || ! strcmp(params[i], "--split-large-meshes")) { + else if (! strcmp( param, "-slm") || ! strcmp( param, "--split-large-meshes")) { fill.ppFlags |= aiProcess_SplitLargeMeshes; } - else if (! strcmp(params[i], "-lbw") || ! strcmp(params[i], "--limit-bone-weights")) { + else if (! strcmp( param, "-lbw") || ! strcmp( param, "--limit-bone-weights")) { fill.ppFlags |= aiProcess_LimitBoneWeights; } - else if (! strcmp(params[i], "-vds") || ! strcmp(params[i], "--validate-data-structure")) { + else if (! strcmp( param, "-vds") || ! strcmp( param, "--validate-data-structure")) { fill.ppFlags |= aiProcess_ValidateDataStructure; } - else if (! strcmp(params[i], "-icl") || ! strcmp(params[i], "--improve-cache-locality")) { + else if (! strcmp( param, "-icl") || ! strcmp( param, "--improve-cache-locality")) { fill.ppFlags |= aiProcess_ImproveCacheLocality; } - else if (! strcmp(params[i], "-sbpt") || ! strcmp(params[i], "--sort-by-ptype")) { + else if (! strcmp( param, "-sbpt") || ! strcmp( param, "--sort-by-ptype")) { fill.ppFlags |= aiProcess_SortByPType; } - else if (! strcmp(params[i], "-lh") || ! strcmp(params[i], "--left-handed")) { + else if (! strcmp( param, "-lh") || ! strcmp( param, "--left-handed")) { fill.ppFlags |= aiProcess_ConvertToLeftHanded; } - else if (! strcmp(params[i], "-fuv") || ! strcmp(params[i], "--flip-uv")) { + else if (! strcmp( param, "-fuv") || ! strcmp( param, "--flip-uv")) { fill.ppFlags |= aiProcess_FlipUVs; } - else if (! strcmp(params[i], "-fwo") || ! strcmp(params[i], "--flip-winding-order")) { + else if (! strcmp( param, "-fwo") || ! strcmp( param, "--flip-winding-order")) { fill.ppFlags |= aiProcess_FlipWindingOrder; } - else if (! strcmp(params[i], "-tuv") || ! strcmp(params[i], "--transform-uv-coords")) { + else if (! strcmp( param, "-tuv") || ! strcmp( param, "--transform-uv-coords")) { fill.ppFlags |= aiProcess_TransformUVCoords; } - else if (! strcmp(params[i], "-guv") || ! strcmp(params[i], "--gen-uvcoords")) { + else if (! strcmp( param, "-guv") || ! strcmp( param, "--gen-uvcoords")) { fill.ppFlags |= aiProcess_GenUVCoords; } - else if (! strcmp(params[i], "-fid") || ! strcmp(params[i], "--find-invalid-data")) { + else if (! strcmp( param, "-fid") || ! strcmp( param, "--find-invalid-data")) { fill.ppFlags |= aiProcess_FindInvalidData; } - else if (! strcmp(params[i], "-fixn") || ! strcmp(params[i], "--fix-normals")) { + else if (! strcmp( param, "-fixn") || ! strcmp( param, "--fix-normals")) { fill.ppFlags |= aiProcess_FixInfacingNormals; } - else if (! strcmp(params[i], "-tri") || ! strcmp(params[i], "--triangulate")) { + else if (! strcmp( param, "-tri") || ! strcmp( param, "--triangulate")) { fill.ppFlags |= aiProcess_Triangulate; } - else if (! strcmp(params[i], "-cts") || ! strcmp(params[i], "--calc-tangent-space")) { + else if (! strcmp( param, "-cts") || ! strcmp( param, "--calc-tangent-space")) { fill.ppFlags |= aiProcess_CalcTangentSpace; } - else if (! strcmp(params[i], "-fi") || ! strcmp(params[i], "--find-instances")) { + else if (! strcmp( param, "-fi") || ! strcmp( param, "--find-instances")) { fill.ppFlags |= aiProcess_FindInstances; } - else if (! strcmp(params[i], "-og") || ! strcmp(params[i], "--optimize-graph")) { + else if (! strcmp( param, "-og") || ! strcmp( param, "--optimize-graph")) { fill.ppFlags |= aiProcess_OptimizeGraph; } - else if (! strcmp(params[i], "-om") || ! strcmp(params[i], "--optimize-meshes")) { + else if (! strcmp( param, "-om") || ! strcmp( param, "--optimize-meshes")) { fill.ppFlags |= aiProcess_OptimizeMeshes; } - else if (! strcmp(params[i], "-db") || ! strcmp(params[i], "--debone")) { + else if (! strcmp( param, "-db") || ! strcmp( param, "--debone")) { fill.ppFlags |= aiProcess_Debone; } - else if (! strcmp(params[i], "-sbc") || ! strcmp(params[i], "--split-by-bone-count")) { + else if (! strcmp( param, "-sbc") || ! strcmp( param, "--split-by-bone-count")) { fill.ppFlags |= aiProcess_SplitByBoneCount; } - - - else if (! strncmp(params[i], "-c",2) || ! strncmp(params[i], "--config=",9)) { - + else if (! strncmp( param, "-c",2) || ! strncmp( param, "--config=",9)) { const unsigned int ofs = (params[i][1] == '-' ? 9 : 2); // use default configurations - if (! strncmp(params[i]+ofs,"full",4)) { - fill.ppFlags |= aiProcessPreset_TargetRealtime_MaxQuality; - } - else if (! strncmp(params[i]+ofs,"default",7)) { + if (!strncmp( param + ofs, "full", 4 )) { + fill.ppFlags |= aiProcessPreset_TargetRealtime_MaxQuality; + } else if (!strncmp( param + ofs, "default", 7 )) { fill.ppFlags |= aiProcessPreset_TargetRealtime_Quality; - } - else if (! strncmp(params[i]+ofs,"fast",4)) { + } else if (! strncmp( param +ofs,"fast",4)) { fill.ppFlags |= aiProcessPreset_TargetRealtime_Fast; } - } - else if (! strcmp(params[i], "-l") || ! strcmp(params[i], "--show-log")) { + } else if (! strcmp( param, "-l") || ! strcmp( param, "--show-log")) { fill.showLog = true; } - else if (! strcmp(params[i], "-v") || ! strcmp(params[i], "--verbose")) { + else if (! strcmp( param, "-v") || ! strcmp( param, "--verbose")) { fill.verbose = true; } - else if (! strncmp(params[i], "--log-out=",10) || ! strncmp(params[i], "-lo",3)) { + else if (! strncmp( param, "--log-out=",10) || ! strncmp( param, "-lo",3)) { fill.logFile = std::string(params[i]+(params[i][1] == '-' ? 10 : 3)); if (!fill.logFile.length()) { fill.logFile = "assimp-log.txt"; From 1c9406b2f59d5235f2b69192551f4cae391f4c92 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 08:09:07 +0200 Subject: [PATCH 017/214] add linetest files to gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2a3b68a50..f8dda3e8b 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ tools/assimp_cmd/Makefile # Tests test/results +test/readlinetest* # Python __pycache__ From ef605fecaa4c51f3b59f5d1038a9f7ddd2417967 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 08:09:27 +0200 Subject: [PATCH 018/214] FBX: small optimization to avoind static computation in loop. --- code/FBXBinaryTokenizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp index d6c34de6f..b81a9f945 100644 --- a/code/FBXBinaryTokenizer.cpp +++ b/code/FBXBinaryTokenizer.cpp @@ -448,8 +448,8 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le /*Result ignored*/ ReadByte(input, cursor, input + length); const uint32_t version = ReadWord(input, cursor, input + length); const bool is64bits = version >= 7500; - while (cursor < input + length) - { + const char *end = input + length; + while (cursor < end ) { if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) { break; } From f93ee9daced8e77227bdeba50fffd5e596eabe99 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 08:10:26 +0200 Subject: [PATCH 019/214] closes https://github.com/assimp/assimp/issues/1780: check against nullptr before accessing normal data in aiMesh instance. --- code/glTF2Exporter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 5376788b2..9bb99b0b0 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -728,8 +728,10 @@ void glTF2Exporter::ExportMeshes() /******************** Normals ********************/ // Normalize all normals as the validator can emit a warning otherwise - for (auto i = 0u; i < aim->mNumVertices; ++i) { - aim->mNormals[i].Normalize(); + if ( nullptr != aim->mNormals) { + for ( auto i = 0u; i < aim->mNumVertices; ++i ) { + aim->mNormals[ i ].Normalize(); + } } Ref n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT); From 950496c351ff7a438c812b6b4719343d8ea4ccd9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 08:39:22 +0200 Subject: [PATCH 020/214] some minor refactorings. --- code/glTF2Exporter.cpp | 17 ++++++++++------- code/glTF2Exporter.h | 28 ++++++++++++---------------- test/unit/utglTF2ImportExport.cpp | 1 + 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 9bb99b0b0..d4b3d67de 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -138,28 +138,29 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai } } +glTF2Exporter::~glTF2Exporter() { + // empty +} + /* * Copy a 4x4 matrix from struct aiMatrix to typedef mat4. * Also converts from row-major to column-major storage. */ -static void CopyValue(const aiMatrix4x4& v, mat4& o) -{ +static void CopyValue(const aiMatrix4x4& v, mat4& o) { o[ 0] = v.a1; o[ 1] = v.b1; o[ 2] = v.c1; o[ 3] = v.d1; o[ 4] = v.a2; o[ 5] = v.b2; o[ 6] = v.c2; o[ 7] = v.d2; o[ 8] = v.a3; o[ 9] = v.b3; o[10] = v.c3; o[11] = v.d3; o[12] = v.a4; o[13] = v.b4; o[14] = v.c4; o[15] = v.d4; } -static void CopyValue(const aiMatrix4x4& v, aiMatrix4x4& o) -{ +static void CopyValue(const aiMatrix4x4& v, aiMatrix4x4& o) { o.a1 = v.a1; o.a2 = v.a2; o.a3 = v.a3; o.a4 = v.a4; o.b1 = v.b1; o.b2 = v.b2; o.b3 = v.b3; o.b4 = v.b4; o.c1 = v.c1; o.c2 = v.c2; o.c3 = v.c3; o.c4 = v.c4; o.d1 = v.d1; o.d2 = v.d2; o.d3 = v.d3; o.d4 = v.d4; } -static void IdentityMatrix4(mat4& o) -{ +static void IdentityMatrix4(mat4& o) { o[ 0] = 1; o[ 1] = 0; o[ 2] = 0; o[ 3] = 0; o[ 4] = 0; o[ 5] = 1; o[ 6] = 0; o[ 7] = 0; o[ 8] = 0; o[ 9] = 0; o[10] = 1; o[11] = 0; @@ -169,7 +170,9 @@ static void IdentityMatrix4(mat4& o) inline Ref ExportData(Asset& a, std::string& meshName, Ref& buffer, unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false) { - if (!count || !data) return Ref(); + if (!count || !data) { + return Ref(); + } unsigned int numCompsIn = AttribType::GetNumComponents(typeIn); unsigned int numCompsOut = AttribType::GetNumComponents(typeOut); diff --git a/code/glTF2Exporter.h b/code/glTF2Exporter.h index ff94be9e9..616a1177c 100644 --- a/code/glTF2Exporter.h +++ b/code/glTF2Exporter.h @@ -87,28 +87,15 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ /** Helper class to export a given scene to an glTF file. */ // ------------------------------------------------------------------------------------------------ - class glTF2Exporter - { + class glTF2Exporter { public: /// Constructor for a specific scene to export glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties, bool binary); + ~glTF2Exporter(); - private: - - const char* mFilename; - IOSystem* mIOSystem; - const aiScene* mScene; - const ExportProperties* mProperties; - - std::map mTexturesByPath; - - std::shared_ptr mAsset; - - std::vector mBodyData; - + protected: void WriteBinaryData(IOStream* outfile, std::size_t sceneLength); - void GetTexSampler(const aiMaterial* mat, glTF2::Ref texture, aiTextureType tt, unsigned int slot); void GetMatTexProp(const aiMaterial* mat, unsigned int& prop, const char* propName, aiTextureType tt, unsigned int idx); void GetMatTexProp(const aiMaterial* mat, float& prop, const char* propName, aiTextureType tt, unsigned int idx); @@ -126,6 +113,15 @@ namespace Assimp unsigned int ExportNode(const aiNode* node, glTF2::Ref& parent); void ExportScene(); void ExportAnimations(); + + private: + const char* mFilename; + IOSystem* mIOSystem; + const aiScene* mScene; + const ExportProperties* mProperties + std::map mTexturesByPath; + std::shared_ptr mAsset; + std::vector mBodyData; }; } diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 91b8917a8..58ebe3017 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -89,4 +89,5 @@ TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) { TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) { EXPECT_TRUE( exporterTest() ); } + #endif // ASSIMP_BUILD_NO_EXPORT From e3548fe85046eda679a064bee81db815a8e45e16 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 08:50:17 +0200 Subject: [PATCH 021/214] Update glTF2Exporter.h Fix typo. --- code/glTF2Exporter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/glTF2Exporter.h b/code/glTF2Exporter.h index 616a1177c..06bc5ad40 100644 --- a/code/glTF2Exporter.h +++ b/code/glTF2Exporter.h @@ -118,7 +118,7 @@ namespace Assimp const char* mFilename; IOSystem* mIOSystem; const aiScene* mScene; - const ExportProperties* mProperties + const ExportProperties* mProperties; std::map mTexturesByPath; std::shared_ptr mAsset; std::vector mBodyData; From a571d013102b62b437b4623dd4fc28a042dc5945 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 12 May 2018 12:01:52 +0200 Subject: [PATCH 022/214] Create CONTRIBUTING.md --- CONTRIBUTING.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..6aebbbd01 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +#How to contribute + +If you want to contribute you can follow these setps: +- Fist create your own clone of assimp +- When you want to fix a bug or add a new feature create a branch on your own fork ( just follow https://help.github.com/articles/creating-a-pull-request-from-a-fork/ ) +- Push it to the repo and open a pull request +- A pull request will start our CI-service, which checks if the build works for linux and windows. + It will check for memory leaks, compiler warnings and memory alignment issues. If any of these tests fails: fix it and the tests will be reastarted automatically + - At the end we will perform a code review and merge your branch to the master branch. + + From 2998830d4a555f8aeccec8843152f0e3c217ca00 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sun, 13 May 2018 15:33:51 +0200 Subject: [PATCH 023/214] Fix typos on documentation using codespell --- Readme.md | 2 +- doc/dox.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index c78a0c1c8..856371d7e 100644 --- a/Readme.md +++ b/Readme.md @@ -141,7 +141,7 @@ Open Asset Import Library is implemented in C++. The directory structure is: /samples A small number of samples to illustrate possible use cases for Assimp /workspaces Build environments for vc,xcode,... (deprecated, - CMake has superseeded all legacy build options!) + CMake has superseded all legacy build options!) ### Where to get help ### diff --git a/doc/dox.h b/doc/dox.h index bc47e5584..af9eeb609 100644 --- a/doc/dox.h +++ b/doc/dox.h @@ -164,7 +164,7 @@ If done correctly you should now be able to compile, link, run and use the appli @section install_own Building the library from scratch First you need to install cmake. Now just get the code from github or download the latest version from the webside. -to buil the library just open a command-prompt / bash, navigate into the repo-folder and run cmake via: +to build the library just open a command-prompt / bash, navigate into the repo-folder and run cmake via: @code cmake CMakeLists.txt @@ -653,7 +653,7 @@ To apply such an animation you need to identify the animation tracks that refer in your mesh. Then for every track:
a) Find the keys that lay right before the current anim time.
b) Optional: interpolate between these and the following keys.
-c) Combine the calculated position, rotation and scaling to a tranformation matrix
+c) Combine the calculated position, rotation and scaling to a transformation matrix
d) Set the affected node's transformation to the calculated matrix.
If you need hints on how to convert to or from quaternions, have a look at the @@ -669,7 +669,7 @@ Such textures are loaded into an aiTexture structure. In previous versions, the path from the query for `AI_MATKEY_TEXTURE(textureType, index)` would be `*` where `` is the index of the texture in aiScene::mTextures. Now this call will -return a file path for embedded textures in FBX files. To test if it is an embdedded texture use +return a file path for embedded textures in FBX files. To test if it is an embedded texture use aiScene::GetEmbeddedTexture. If the returned pointer is not null, it is embedded und can be loaded from the data structure. If it is null, search for a separate file. Other file types still use the old behaviour.
@@ -794,7 +794,7 @@ All material key constants start with 'AI_MATKEY' (it's an ugly macro for histor COLOR_REFLECTIVE aiColor3D black (0,0,0) - Defines the reflective color of the material. This is typically scaled by the amount of incoming light from the direction of mirror reflection. Usually combined with an enviroment lightmap of some kind for real-time applications. + Defines the reflective color of the material. This is typically scaled by the amount of incoming light from the direction of mirror reflection. Usually combined with an environment lightmap of some kind for real-time applications. --- @@ -819,7 +819,7 @@ All material key constants start with 'AI_MATKEY' (it's an ugly macro for histor int false Specifies whether meshes using this material must be rendered without backface culling. 0 for false, !0 for true. - Some importers set this property if they don't know whether the output face oder is right. As long as it is not set, you may safely enable backface culling. + Some importers set this property if they don't know whether the output face order is right. As long as it is not set, you may safely enable backface culling. From 2879e0d6ef21a34180da13dd9f0a66b16d54b095 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sun, 13 May 2018 16:35:03 +0200 Subject: [PATCH 024/214] Fix typos on code using codespell --- code/AMFImporter_Macro.hpp | 8 ++++---- code/AMFImporter_Material.cpp | 2 +- code/AMFImporter_Postprocess.cpp | 2 +- code/ASEParser.h | 2 +- code/BlenderDNA.cpp | 2 +- code/BlenderDNA.h | 2 +- code/BlenderTessellator.h | 2 +- code/ColladaExporter.h | 2 +- code/ColladaLoader.cpp | 4 ++-- code/FBXConverter.cpp | 2 +- code/FBXDocument.cpp | 6 +++--- code/FBXExporter.cpp | 22 +++++++++++----------- code/FBXExporter.h | 2 +- code/FBXMaterial.cpp | 2 +- code/FindDegenerates.cpp | 2 +- code/IRRShared.h | 2 +- code/Importer.cpp | 18 +++++++++--------- code/Importer/IFC/IFCUtil.cpp | 2 +- code/JoinVerticesProcess.cpp | 2 +- code/LWSLoader.cpp | 2 +- code/MDLLoader.cpp | 4 ++-- code/MMDImporter.cpp | 2 +- code/NFFLoader.cpp | 4 ++-- code/OpenGEXImporter.cpp | 2 +- code/OptimizeGraph.h | 2 +- code/ProcessHelper.h | 2 +- code/ScenePreprocessor.cpp | 2 +- code/StandardShapes.cpp | 2 +- code/StepExporter.cpp | 2 +- code/TextureTransform.cpp | 2 +- code/Version.cpp | 2 +- code/X3DExporter.hpp | 2 +- code/X3DImporter.hpp | 2 +- code/X3DImporter_Geometry3D.cpp | 8 ++++---- code/X3DImporter_Macro.hpp | 4 ++-- code/X3DImporter_Metadata.cpp | 2 +- code/XFileExporter.cpp | 2 +- code/XGLLoader.cpp | 2 +- code/glTF2Asset.h | 2 +- code/glTFAsset.h | 2 +- code/glTFExporter.cpp | 2 +- 41 files changed, 71 insertions(+), 71 deletions(-) diff --git a/code/AMFImporter_Macro.hpp b/code/AMFImporter_Macro.hpp index afa120028..ea8c17850 100644 --- a/code/AMFImporter_Macro.hpp +++ b/code/AMFImporter_Macro.hpp @@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_REF -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then +/// Check current attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then /// "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. @@ -84,7 +84,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_RET -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. +/// Check current attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. /// If result was read then "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. @@ -130,7 +130,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } while(false) /// \def MACRO_NODECHECK_READCOMP_F -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "float". +/// Check current node name and if it equal to requested then read value. Result write to output variable of type "float". /// If result was read then "continue" will called. Also check if node data already read then raise exception. /// \param [in] pNodeName - node name. /// \param [in, out] pReadFlag - read flag. @@ -147,7 +147,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_NODECHECK_READCOMP_U32 -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "uint32_t". +/// Check current node name and if it equal to requested then read value. Result write to output variable of type "uint32_t". /// If result was read then "continue" will called. Also check if node data already read then raise exception. /// \param [in] pNodeName - node name. /// \param [in, out] pReadFlag - read flag. diff --git a/code/AMFImporter_Material.cpp b/code/AMFImporter_Material.cpp index 77f49d39e..2f65ad833 100644 --- a/code/AMFImporter_Material.cpp +++ b/code/AMFImporter_Material.cpp @@ -99,7 +99,7 @@ CAMFImporter_NodeElement* ne; ParseHelper_Node_Exit(); // check that all components was defined if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined."); - // check if is absent. Then manualy add "a == 1". + // check if is absent. Then manually add "a == 1". if(!read_flag[3]) als.Color.a = 1; }// if(!mReader->isEmptyElement()) diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 192544fcb..a6ee8fa2f 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -770,7 +770,7 @@ std::list ch_node; // find referenced object if(!Find_ConvertedNode(als.ObjectID, pNodeList, &found_node)) Throw_ID_NotFound(als.ObjectID); - // create node for apllying transformation + // create node for applying transformation t_node = new aiNode; t_node->mParent = con_node; // apply transformation diff --git a/code/ASEParser.h b/code/ASEParser.h index 8715fdfab..70eb3de66 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -427,7 +427,7 @@ public: // ------------------------------------------------------------------- //! Construct a parser from a given input file which is - //! guaranted to be terminated with zero. + //! guaranteed to be terminated with zero. //! @param szFile Input file //! @param fileFormatDefault Assumed file format version. If the //! file format is specified in the file the new value replaces diff --git a/code/BlenderDNA.cpp b/code/BlenderDNA.cpp index afcbb34e3..f84c45601 100644 --- a/code/BlenderDNA.cpp +++ b/code/BlenderDNA.cpp @@ -227,7 +227,7 @@ void DNAParser::Parse () // ------------------------------------------------------------------------------------------------ void DNA :: DumpToFile() { - // we dont't bother using the VFS here for this is only for debugging. + // we don't bother using the VFS here for this is only for debugging. // (and all your bases are belong to us). std::ofstream f("dna.txt"); diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h index 4a1e83b64..6a18fe9fa 100644 --- a/code/BlenderDNA.h +++ b/code/BlenderDNA.h @@ -663,7 +663,7 @@ public: /** Check whether a specific item is in the cache. * @param s Data type of the item * @param out Output pointer. Unchanged if the - * cache doens't know the item yet. + * cache doesn't know the item yet. * @param ptr Item address to look for. */ template void get ( const Structure& s, diff --git a/code/BlenderTessellator.h b/code/BlenderTessellator.h index 59d698295..dab3ba8aa 100644 --- a/code/BlenderTessellator.h +++ b/code/BlenderTessellator.h @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BLEND_TESSELLATOR_H // Use these to toggle between GLU Tessellate or poly2tri -// Note (acg) keep GLU Tesselate disabled by default - if it is turned on, +// Note (acg) keep GLU Tessellate disabled by default - if it is turned on, // assimp needs to be linked against GLU, which is currently not yet // made configurable in CMake and potentially not wanted by most users // as it requires a Gl environment. diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index 773039735..d1a307532 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -189,7 +189,7 @@ protected: {} }; - // summarize a material in an convinient way. + // summarize a material in an convenient way. struct Material { std::string name; diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 611e487b0..54178295c 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -956,7 +956,7 @@ void ColladaLoader::StoreSceneMaterials( aiScene* pScene) // Stores all animations void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser) { - // recursivly collect all animations from the collada scene + // recursively collect all animations from the collada scene StoreAnimations( pScene, pParser, &pParser.mAnims, ""); // catch special case: many animations with the same length, each affecting only a single node. @@ -1784,7 +1784,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars // 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 thru the loaded textures after all data is processed + // 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 // setup texture reference string diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index d6529d119..c50e88390 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1564,7 +1564,7 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const TextureMap& 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 thru the loaded textures after all data is processed + // 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] = '*'; diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index 2965a54ff..f53ae4405 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -575,11 +575,11 @@ std::vector Document::GetConnectionsSequenced(uint64_t id, bo ai_assert( count != 0 ); ai_assert( count <= MAX_CLASSNAMES); - size_t lenghts[MAX_CLASSNAMES]; + size_t lengths[MAX_CLASSNAMES]; const size_t c = count; for (size_t i = 0; i < c; ++i) { - lenghts[ i ] = strlen(classnames[i]); + lengths[ i ] = strlen(classnames[i]); } std::vector temp; @@ -597,7 +597,7 @@ std::vector Document::GetConnectionsSequenced(uint64_t id, bo for (size_t i = 0; i < c; ++i) { ai_assert(classnames[i]); - if(static_cast(std::distance(key.begin(),key.end())) == lenghts[i] && !strncmp(classnames[i],obtype,lenghts[i])) { + if(static_cast(std::distance(key.begin(),key.end())) == lengths[i] && !strncmp(classnames[i],obtype,lengths[i])) { obtype = NULL; break; } diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index 52c69161a..a942e31bc 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -450,7 +450,7 @@ void FBXExporter::WriteDocuments () p.AddP70string("ActiveAnimStackName", ""); // should do this properly? doc.AddChild(p); - // UID for root node in scene heirarchy. + // UID for root node in scene hierarchy. // always set to 0 in the case of a single document. // not sure what happens if more than one document exists, // but that won't matter to us as we're exporting a single scene. @@ -650,7 +650,7 @@ void FBXExporter::WriteDefinitions () } // Model / FbxNode - // <~~ node heirarchy + // <~~ node hierarchy count = int32_t(count_nodes(mScene->mRootNode)) - 1; // (not counting root node) if (count) { n = FBX::Node("ObjectType", "Model"); @@ -1223,7 +1223,7 @@ void FBXExporter::WriteObjects () // it's all about this material aiMaterial* m = mScene->mMaterials[i]; - // these are used to recieve material data + // these are used to receive material data float f; aiColor3D c; // start the node record @@ -1311,7 +1311,7 @@ void FBXExporter::WriteObjects () // Now the legacy system. // For safety let's include it. // thrse values don't exist in the property template, - // and usualy are completely ignored when loading. + // and usually are completely ignored when loading. // One notable exception is the "Opacity" property, // which Blender uses as (1.0 - alpha). c.r = 0.0f; c.g = 0.0f; c.b = 0.0f; @@ -1532,7 +1532,7 @@ void FBXExporter::WriteObjects () // bones. // // output structure: - // subset of node heirarchy that are "skeleton", + // subset of node hierarchy that are "skeleton", // i.e. do not have meshes but only bones. // but.. i'm not sure how anyone could guarantee that... // @@ -1544,7 +1544,7 @@ void FBXExporter::WriteObjects () // // well. we can assume a sane input, i suppose. // - // so input is the bone node heirarchy, + // so input is the bone node hierarchy, // with an extra thing for the transformation of the MESH in BONE space. // // output is a set of bone nodes, @@ -1556,7 +1556,7 @@ void FBXExporter::WriteObjects () // and represents the influence of that bone on the grandparent mesh. // the subdeformer has a list of indices, and weights, // with indices specifying vertex indices, - // and weights specifying the correspoding influence of this bone. + // and weights specifying the corresponding influence of this bone. // it also has Transform and TransformLink elements, // specifying the transform of the MESH in BONE space, // and the transformation of the BONE in WORLD space, @@ -1806,7 +1806,7 @@ void FBXExporter::WriteObjects () // and a correct skeleton would still be output. // transformlink should be the position of the bone in world space. - // if the bone is in the bind pose (or nonexistant), + // if the bone is in the bind pose (or nonexistent), // we can just use the matrix we already calculated if (bone_xform_okay) { sdnode.AddChild("TransformLink", bone_xform); @@ -1945,7 +1945,7 @@ void FBXExporter::WriteObjects () // TODO: cameras, lights - // write nodes (i.e. model heirarchy) + // write nodes (i.e. model hierarchy) // start at root node WriteModelNodes( outstream, mScene->mRootNode, 0, limbnodes @@ -2203,8 +2203,8 @@ void FBXExporter::WriteModelNode( } else { // apply the transformation chain. // these transformation elements are created when importing FBX, - // which has a complex transformation heirarchy for each node. - // as such we can bake the heirarchy back into the node on export. + // which has a complex transformation hierarchy for each node. + // as such we can bake the hierarchy back into the node on export. for (auto &item : transform_chain) { auto elem = transform_types.find(item.first); if (elem == transform_types.end()) { diff --git a/code/FBXExporter.h b/code/FBXExporter.h index 3b9de8acb..c27d1a8ce 100644 --- a/code/FBXExporter.h +++ b/code/FBXExporter.h @@ -90,7 +90,7 @@ namespace Assimp const ExportProperties* mProperties; // currently unused std::shared_ptr outfile; // file to write to - std::vector connections; // conection storage + std::vector connections; // connection storage std::vector mesh_uids; std::vector material_uids; diff --git a/code/FBXMaterial.cpp b/code/FBXMaterial.cpp index 8bb3920de..75b2e3b4b 100644 --- a/code/FBXMaterial.cpp +++ b/code/FBXMaterial.cpp @@ -302,7 +302,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std } if(Content) { - //this field is ommited when the embedded texture is already loaded, let's ignore if it's not found + //this field is omitted when the embedded texture is already loaded, let's ignore if it's not found try { const Token& token = GetRequiredToken(*Content, 0); const char* data = token.begin(); diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index c0023c9a4..760ab743a 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -161,7 +161,7 @@ void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) { // NOTE: we set the removed vertex index to an unique value // to make sure the developer gets notified when his - // application attemps to access this data. + // application attempts to access this data. face.mIndices[ face.mNumIndices ] = 0xdeadbeef; if(first) { diff --git a/code/IRRShared.h b/code/IRRShared.h index 8770d2add..2f6f87405 100644 --- a/code/IRRShared.h +++ b/code/IRRShared.h @@ -91,7 +91,7 @@ protected: // ------------------------------------------------------------------- /** Read a property of the specified type from the current XML element. - * @param out Recives output data + * @param out Receives output data */ void ReadHexProperty (HexProperty& out); void ReadStringProperty (StringProperty& out); diff --git a/code/Importer.cpp b/code/Importer.cpp index 9fbba61c4..139dc6c51 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -997,33 +997,33 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue) // Set a configuration property bool Importer::SetPropertyFloat(const char* szName, ai_real iValue) { - bool exising; + bool existing; ASSIMP_BEGIN_EXCEPTION_REGION(); - exising = SetGenericProperty(pimpl->mFloatProperties, szName,iValue); + existing = SetGenericProperty(pimpl->mFloatProperties, szName,iValue); ASSIMP_END_EXCEPTION_REGION(bool); - return exising; + return existing; } // ------------------------------------------------------------------------------------------------ // Set a configuration property bool Importer::SetPropertyString(const char* szName, const std::string& value) { - bool exising; + bool existing; ASSIMP_BEGIN_EXCEPTION_REGION(); - exising = SetGenericProperty(pimpl->mStringProperties, szName,value); + existing = SetGenericProperty(pimpl->mStringProperties, szName,value); ASSIMP_END_EXCEPTION_REGION(bool); - return exising; + return existing; } // ------------------------------------------------------------------------------------------------ // Set a configuration property bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) { - bool exising; + bool existing; ASSIMP_BEGIN_EXCEPTION_REGION(); - exising = SetGenericProperty(pimpl->mMatrixProperties, szName,value); + existing = SetGenericProperty(pimpl->mMatrixProperties, szName,value); ASSIMP_END_EXCEPTION_REGION(bool); - return exising; + return existing; } // ------------------------------------------------------------------------------------------------ diff --git a/code/Importer/IFC/IFCUtil.cpp b/code/Importer/IFC/IFCUtil.cpp index 97f621935..06cc4405a 100644 --- a/code/Importer/IFC/IFCUtil.cpp +++ b/code/Importer/IFC/IFCUtil.cpp @@ -317,7 +317,7 @@ void TempMesh::FixupFaceOrientation() IfcVector3 farthestCenter = std::accumulate(mVerts.begin() + faceStartIndices[farthestIndex], mVerts.begin() + faceStartIndices[farthestIndex] + mVertcnt[farthestIndex], IfcVector3(0.0)) / IfcFloat(mVertcnt[farthestIndex]); - // We accapt a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in + // We accept a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in // the file. if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 ) { diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index c21d71f47..7f7bcae41 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -118,7 +118,7 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) // 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 + // Square compare is useful for animeshes vertices compare if ((lhs.position - rhs.position).SquareLength() > squareEpsilon) { return false; } diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 518b893e9..6f8cbe78d 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -410,7 +410,7 @@ void LWSImporter::BuildGraph(aiNode* nd, LWS::NodeDesc& src, std::vector unique due to LWs indexing system lit->mName = nd->mName; - // detemine light type and setup additional members + // determine light type and setup additional members if (src.lightType == 2) { /* spot light */ lit->mType = aiLightSource_SPOT; diff --git a/code/MDLLoader.cpp b/code/MDLLoader.cpp index 4c43bc64f..dfe1c1311 100644 --- a/code/MDLLoader.cpp +++ b/code/MDLLoader.cpp @@ -141,7 +141,7 @@ void MDLImporter::SetupProperties(const Importer* pImp) configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); } - // AI_CONFIG_IMPORT_MDL_COLORMAP - pallette file + // AI_CONFIG_IMPORT_MDL_COLORMAP - palette file configPalette = pImp->GetPropertyString(AI_CONFIG_IMPORT_MDL_COLORMAP,"colormap.lmp"); } @@ -1496,7 +1496,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( ) groupData.vTextureCoords1.resize(iNumVertices,aiVector3D()); // check whether the triangle data structure is large enough - // to contain a second UV coodinate set + // to contain a second UV coordinate set if (pcHeader->triangle_stc_size >= AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV) { groupData.vTextureCoords2.resize(iNumVertices,aiVector3D()); groupData.bNeed2UV = true; diff --git a/code/MMDImporter.cpp b/code/MMDImporter.cpp index 76ad9115c..3d7f3c794 100644 --- a/code/MMDImporter.cpp +++ b/code/MMDImporter.cpp @@ -217,7 +217,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel, pMesh->mNumFaces = indexCount / 3; pMesh->mFaces = new aiFace[pMesh->mNumFaces]; - const int numIndices = 3; // trianglular face + const int numIndices = 3; // triangular face for (unsigned int index = 0; index < pMesh->mNumFaces; index++) { pMesh->mFaces[index].mNumIndices = numIndices; unsigned int *indices = new unsigned int[numIndices]; diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index 2c7eeaa20..1c7283db6 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -271,7 +271,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, ShadingInfo s; // current material info - // degree of tesselation + // degree of tessellation unsigned int iTesselation = 4; // some temporary variables we need to parse the file @@ -988,7 +988,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, ::ai_snprintf(currentMesh.name,128,"cone_%i",cone++); else ::ai_snprintf(currentMesh.name,128,"cylinder_%i",cylinder++); } - // 'tess' - tesselation + // 'tess' - tessellation else if (TokenMatch(sz,"tess",4)) { SkipSpaces(&sz); diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 9966c1f34..2de0aabc0 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -691,7 +691,7 @@ void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene * void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) { m_currentMesh = new aiMesh; const size_t meshidx( m_meshCache.size() ); - // ownership is transfered but a reference remains in m_currentMesh + // ownership is transferred but a reference remains in m_currentMesh m_meshCache.emplace_back( m_currentMesh ); Property *prop = node->getProperties(); diff --git a/code/OptimizeGraph.h b/code/OptimizeGraph.h index aa6aa8651..6781ec534 100644 --- a/code/OptimizeGraph.h +++ b/code/OptimizeGraph.h @@ -102,7 +102,7 @@ public: } // ------------------------------------------------------------------- - /** @brief Rmeove a node from the list of locked nodes. + /** @brief Remove a node from the list of locked nodes. * @param name Name to be unlocked */ inline void RemoveLockedNode(std::string& name) diff --git a/code/ProcessHelper.h b/code/ProcessHelper.h index c668b946f..dcf71e853 100644 --- a/code/ProcessHelper.h +++ b/code/ProcessHelper.h @@ -212,7 +212,7 @@ template <> struct MinMaxChooser { // ------------------------------------------------------------------------------- /** @brief Find the min/max values of an array of Ts * @param in Input array - * @param size Numebr of elements to process + * @param size Number of elements to process * @param[out] min minimum value * @param[out] max maximum value */ diff --git a/code/ScenePreprocessor.cpp b/code/ScenePreprocessor.cpp index eff6ecc6e..1228ab2c2 100644 --- a/code/ScenePreprocessor.cpp +++ b/code/ScenePreprocessor.cpp @@ -104,7 +104,7 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh) aiVector3D* p = mesh->mTextureCoords[i], *end = p+mesh->mNumVertices; - // Ensure unsued components are zeroed. This will make 1D texture channels work + // Ensure unused components are zeroed. This will make 1D texture channels work // as if they were 2D channels .. just in case an application doesn't handle // this case if (2 == mesh->mNumUVComponents[i]) { diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index a5b368f7f..7d2319401 100644 --- a/code/StandardShapes.cpp +++ b/code/StandardShapes.cpp @@ -377,7 +377,7 @@ void StandardShapes::MakeSphere(unsigned int tess, MakeIcosahedron(positions); // ... and subdivide it until the requested output - // tesselation is reached + // tessellation is reached for (unsigned int i = 0; i& pVertices); diff --git a/code/X3DImporter_Geometry3D.cpp b/code/X3DImporter_Geometry3D.cpp index a366e8062..b6d130098 100644 --- a/code/X3DImporter_Geometry3D.cpp +++ b/code/X3DImporter_Geometry3D.cpp @@ -136,7 +136,7 @@ void X3DImporter::ParseNode_Geometry3D_Cone() } else { - const unsigned int tess = 30;///TODO: IME tesselation factor through ai_property + const unsigned int tess = 30;///TODO: IME tessellation factor through ai_property std::vector tvec;// temp array for vertices. @@ -209,7 +209,7 @@ void X3DImporter::ParseNode_Geometry3D_Cylinder() } else { - const unsigned int tess = 30;///TODO: IME tesselation factor through ai_property + const unsigned int tess = 30;///TODO: IME tessellation factor through ai_property std::vector tside;// temp array for vertices of side. std::vector tcir;// temp array for vertices of circle. @@ -480,7 +480,7 @@ static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx tvec = pSpine[1] - pSpine[0]; } else - {// The Y-axis used for the last point it is the vector from spine[n-2] to spine[n-1]. In our case(see above about droping tail) spine[n - 1] is + {// The Y-axis used for the last point it is the vector from spine[n-2] to spine[n-1]. In our case(see above about dropping tail) spine[n - 1] is // the spine[0]. tvec = pSpine[spine_idx_last] - pSpine[spine_idx_last - 1]; } @@ -967,7 +967,7 @@ void X3DImporter::ParseNode_Geometry3D_Sphere() } else { - const unsigned int tess = 3;///TODO: IME tesselation factor through ai_property + const unsigned int tess = 3;///TODO: IME tessellation factor through ai_property std::vector tlist; diff --git a/code/X3DImporter_Macro.hpp b/code/X3DImporter_Macro.hpp index cff521408..d1172798c 100644 --- a/code/X3DImporter_Macro.hpp +++ b/code/X3DImporter_Macro.hpp @@ -76,7 +76,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_REF -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then +/// Check current attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then /// "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. @@ -89,7 +89,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_RET -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. +/// Check current attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. /// If result was read then "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. diff --git a/code/X3DImporter_Metadata.cpp b/code/X3DImporter_Metadata.cpp index 0dc9bcec1..a566f0aa9 100644 --- a/code/X3DImporter_Metadata.cpp +++ b/code/X3DImporter_Metadata.cpp @@ -79,7 +79,7 @@ namespace Assimp if(!mReader->isEmptyElement()) \ ParseNode_Metadata(pNE, pMetaName);/* in that case node element will be added to child elements list of current node. */ \ else \ - NodeElement_Cur->Child.push_back(pNE);/* else - add element to child list manualy */ \ + NodeElement_Cur->Child.push_back(pNE);/* else - add element to child list manually */ \ \ NodeElement_List.push_back(pNE);/* add new element to elements list. */ \ }/* if(!pUSE_Var.empty()) else */ \ diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index b2862c6d9..1510ae6d4 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -132,7 +132,7 @@ void XFileExporter::WriteFile() { // note, that all realnumber values must be comma separated in x files mOutput.setf(std::ios::fixed); - mOutput.precision(16); // precission for double + mOutput.precision(16); // precision for double // entry of writing the file WriteHeader(); diff --git a/code/XGLLoader.cpp b/code/XGLLoader.cpp index a9fd6a5ab..0706ffd55 100644 --- a/code/XGLLoader.cpp +++ b/code/XGLLoader.cpp @@ -498,7 +498,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo() right = forward ^ up; if (std::fabs(up * forward) > 1e-4) { // this is definitely wrong - a degenerate coordinate space ruins everything - // so subtitute identity transform. + // so substitute identity transform. LogError(" and vectors in are skewing, ignoring trafo"); return m; } diff --git a/code/glTF2Asset.h b/code/glTF2Asset.h index 358d6bcb4..dd9b11df5 100644 --- a/code/glTF2Asset.h +++ b/code/glTF2Asset.h @@ -386,7 +386,7 @@ namespace glTF2 }; - //! Base classe for all glTF top-level objects + //! Base class for all glTF top-level objects struct Object { int index; //!< The index of this object within its property container diff --git a/code/glTFAsset.h b/code/glTFAsset.h index 018106309..bc79f72ec 100644 --- a/code/glTFAsset.h +++ b/code/glTFAsset.h @@ -381,7 +381,7 @@ namespace glTF }; - //! Base classe for all glTF top-level objects + //! Base class for all glTF top-level objects struct Object { std::string id; //!< The globally unique ID used to reference this object diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 7dfe5b3ff..29a88af8b 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -703,7 +703,7 @@ void glTFExporter::ExportMeshes() // Coordinates indices comp_o3dgc_ifs.SetNCoordIndex(aim->mNumFaces); comp_o3dgc_ifs.SetCoordIndex((IndicesType* const)&b->GetPointer()[idx_srcdata_ind]); - // Prepare to enconding + // Prepare to encoding comp_o3dgc_params.SetNumFloatAttributes(comp_o3dgc_ifs.GetNumFloatAttributes()); if(mProperties->GetPropertyBool("extensions.Open3DGC.binary", true)) comp_o3dgc_params.SetStreamType(o3dgc::O3DGC_STREAM_TYPE_BINARY); From d8af63519d7feef64a5a01aa71f78cab143cfed3 Mon Sep 17 00:00:00 2001 From: Lieven Dekeyser Date: Tue, 15 May 2018 12:38:50 +0200 Subject: [PATCH 025/214] Create fat binaries for libIrrXML and libzlibstatic too --- port/iOS/build.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 44683f0c7..cf17240ab 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -59,9 +59,9 @@ build_arch() $XCODE_ROOT_DIR/Developer/usr/bin/make clean $XCODE_ROOT_DIR/Developer/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/ + mv ./lib/*.a $BUILD_DIR/$1/ } echo "[!] $0 - assimp iOS build script" @@ -110,14 +110,27 @@ for ARCH_TARGET in $DEPLOY_ARCHS; do #rm ./lib/libassimp.a done -if [[ "$DEPLOY_FAT" -eq 1 ]]; then - echo '[+] Creating fat binary ...' + +make_fat_binary() +{ + LIB_NAME=$1 + LIPO_ARGS='' for ARCH_TARGET in $DEPLOY_ARCHS; do - LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.a " + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/$LIB_NAME.a " done - LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.a" + LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/$LIB_NAME-fat.a" lipo $LIPO_ARGS - echo "[!] Done! The fat binary can be found at $BUILD_DIR" +} + +if [[ "$DEPLOY_FAT" -eq 1 ]]; then + echo '[+] Creating fat binaries ...' + + make_fat_binary 'libassimp' + make_fat_binary 'libIrrXML' + make_fat_binary 'libzlibstatic' + + echo "[!] Done! The fat binaries can be found at $BUILD_DIR" fi + From f4fd5840b143b5e57cbb820e9804386d414b6bf3 Mon Sep 17 00:00:00 2001 From: Andor Goetzendorff Date: Tue, 15 May 2018 15:22:19 +0200 Subject: [PATCH 026/214] Encode filename using file system encoding instead of ASCII --- port/PyAssimp/pyassimp/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 573ce27b1..8950e54aa 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -312,7 +312,7 @@ def load(filename, file_type) else: # a filename string has been passed - model = _assimp_lib.load(filename.encode("ascii"), processing) + model = _assimp_lib.load(filename.encode(sys.getfilesystemencoding()), processing) if not model: raise AssimpError('Could not import file!') @@ -342,7 +342,7 @@ def export(scene, ''' from ctypes import pointer - exportStatus = _assimp_lib.export(pointer(scene), file_type.encode("ascii"), filename.encode("ascii"), processing) + exportStatus = _assimp_lib.export(pointer(scene), file_type.encode("ascii"), filename.encode(sys.getfilesystemencoding()), processing) if exportStatus != 0: raise AssimpError('Could not export scene!') From 46ed73c768461e3e853ecd35d1d4200d32e69763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B6ber?= Date: Wed, 16 May 2018 11:02:07 +0200 Subject: [PATCH 027/214] Do not throw exception on empty mesh after removal of degenerates Remove mesh instead. This keeps one edge case open: nodes without mesh references. They are kept as it is for now (they may stilol contain transformations and child references). --- code/FindDegenerates.cpp | 56 +++++++++++++++++++++++++++++++++++++--- code/FindDegenerates.h | 3 ++- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index c0023c9a4..7bc6186bb 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -54,6 +54,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +//remove mesh at position 'index' from the scene +static void removeMesh(aiScene* pScene, unsigned const index); +//correct node indices to meshes and remove references to deleted mesh +static void updateSceneGraph(aiNode* pNode, unsigned const index); + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer FindDegeneratesProcess::FindDegeneratesProcess() @@ -87,11 +92,50 @@ void FindDegeneratesProcess::SetupProperties(const Importer* pImp) { void FindDegeneratesProcess::Execute( aiScene* pScene) { ASSIMP_LOG_DEBUG("FindDegeneratesProcess begin"); for (unsigned int i = 0; i < pScene->mNumMeshes;++i){ - ExecuteOnMesh( pScene->mMeshes[ i ] ); + if (ExecuteOnMesh(pScene->mMeshes[i])) { + removeMesh(pScene, i); + --i; //the current i is removed, do not skip the next one + } } ASSIMP_LOG_DEBUG("FindDegeneratesProcess finished"); } +static void removeMesh(aiScene* pScene, unsigned const index) { + //we start at index and copy the pointers one position forward + //save the mesh pointer to delete it later + auto delete_me = pScene->mMeshes[index]; + for (unsigned i = index; i < pScene->mNumMeshes - 1; ++i) { + pScene->mMeshes[i] = pScene->mMeshes[i+1]; + } + pScene->mMeshes[pScene->mNumMeshes - 1] = nullptr; + --(pScene->mNumMeshes); + delete delete_me; + + //removing a mesh also requires updating all references to it in the scene graph + updateSceneGraph(pScene->mRootNode, index); +} + +static void updateSceneGraph(aiNode* pNode, unsigned const index) { + for (unsigned i = 0; i < pNode->mNumMeshes; ++i) { + if (pNode->mMeshes[i] > index) { + --(pNode->mMeshes[i]); + continue; + } + if (pNode->mMeshes[i] == index) { + for (unsigned j = i; j < pNode->mNumMeshes -1; ++j) { + pNode->mMeshes[j] = pNode->mMeshes[j+1]; + } + --(pNode->mNumMeshes); + --i; + continue; + } + } + //recurse to all children + for (unsigned i = 0; i < pNode->mNumChildren; ++i) { + updateSceneGraph(pNode->mChildren[i], index); + } +} + static ai_real heron( ai_real a, ai_real b, ai_real c ) { ai_real s = (a + b + c) / 2; ai_real area = pow((s * ( s - a ) * ( s - b ) * ( s - c ) ), (ai_real)0.5 ); @@ -125,7 +169,7 @@ static ai_real calculateAreaOfTriangle( const aiFace& face, aiMesh* mesh ) { // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported mesh -void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) { +bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) { mesh->mPrimitiveTypes = 0; std::vector remove_me; @@ -227,19 +271,22 @@ evil_jump_outside: if (&face_src != &face_dest) { // clear source face_src.mNumIndices = 0; - face_src.mIndices = NULL; + face_src.mIndices = nullptr; } } else { // Otherwise delete it if we don't need this face delete[] face_src.mIndices; - face_src.mIndices = NULL; + face_src.mIndices = nullptr; face_src.mNumIndices = 0; } } // Just leave the rest of the array unreferenced, we don't care for now mesh->mNumFaces = n; if (!mesh->mNumFaces) { + //The whole mesh consists of degenerated faces + //signal upward, that this mesh should be deleted. + return true; // WTF!? // OK ... for completeness and because I'm not yet tired, // let's write code that will hopefully never be called @@ -253,4 +300,5 @@ evil_jump_outside: if (deg && !DefaultLogger::isNullLogger()) { ASSIMP_LOG_WARN_F( "Found ", deg, " degenerated primitives"); } + return false; } diff --git a/code/FindDegenerates.h b/code/FindDegenerates.h index 2df94710a..c234c57f5 100644 --- a/code/FindDegenerates.h +++ b/code/FindDegenerates.h @@ -74,7 +74,8 @@ public: // ------------------------------------------------------------------- // Execute step on a given mesh - void ExecuteOnMesh( aiMesh* mesh); + ///@returns true if the current mesh should be deleted, false otherwise + bool ExecuteOnMesh( aiMesh* mesh); // ------------------------------------------------------------------- /// @brief Enable the instant removal of degenerated primitives From 9e80e18b1a331a9b284cd9cbd0f7caeb8d612314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B6ber?= Date: Wed, 16 May 2018 11:10:48 +0200 Subject: [PATCH 028/214] Remove dead code --- code/FindDegenerates.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index 7bc6186bb..3917975fd 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -286,14 +286,8 @@ evil_jump_outside: if (!mesh->mNumFaces) { //The whole mesh consists of degenerated faces //signal upward, that this mesh should be deleted. + ASSIMP_LOG_DEBUG("FindDegeneratesProcess removed a mesh full of degenerated primitives"); return true; - // WTF!? - // OK ... for completeness and because I'm not yet tired, - // let's write code that will hopefully never be called - // (famous last words) - - // OK ... bad idea. - throw DeadlyImportError("Mesh is empty after removal of degenerated primitives ... WTF!?"); } } From 7251c3c51a774c2828f62787e3aa6ad743ca5628 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Wed, 16 May 2018 13:45:25 +0200 Subject: [PATCH 029/214] Fix build with Qt 5.11.0_beta3 (qt5_use_modules is gone) --- tools/assimp_qt_viewer/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/assimp_qt_viewer/CMakeLists.txt b/tools/assimp_qt_viewer/CMakeLists.txt index 42ef0fb34..9f1b68cab 100644 --- a/tools/assimp_qt_viewer/CMakeLists.txt +++ b/tools/assimp_qt_viewer/CMakeLists.txt @@ -3,7 +3,7 @@ project(assimp_qt_viewer) cmake_minimum_required(VERSION 2.6) -find_package(Qt5Widgets REQUIRED) +find_package(Qt5 COMPONENTS Gui Widgets OpenGL REQUIRED) find_package(DevIL REQUIRED) find_package(OpenGL REQUIRED) @@ -25,9 +25,8 @@ qt5_wrap_ui(UISrcs mainwindow.ui) qt5_wrap_cpp(MOCrcs mainwindow.hpp glview.hpp) add_executable(${PROJECT_NAME} ${assimp_qt_viewer_SRCS} ${UISrcs} ${MOCrcs}) -target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${IL_LIBRARIES} ${OPENGL_LIBRARIES} assimp) +target_link_libraries(${PROJECT_NAME} Qt5::Gui Qt5::Widgets Qt5::OpenGL ${IL_LIBRARIES} ${OPENGL_LIBRARIES} assimp) -qt5_use_modules(${PROJECT_NAME} Widgets OpenGL) if(WIN32) # Check if we are on Windows if(MSVC) # Check if we are using the Visual Studio compiler #set_target_properties(TestProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") From 5bbf0a8afa5a3cbaa9281e47cc327b0d9560b03f Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Wed, 16 May 2018 13:58:30 +0200 Subject: [PATCH 030/214] Add missing assimp_qt_viewer install target --- tools/assimp_qt_viewer/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/assimp_qt_viewer/CMakeLists.txt b/tools/assimp_qt_viewer/CMakeLists.txt index 9f1b68cab..b41291e3d 100644 --- a/tools/assimp_qt_viewer/CMakeLists.txt +++ b/tools/assimp_qt_viewer/CMakeLists.txt @@ -42,3 +42,5 @@ else() endif() set_property(TARGET ${PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) + +install(TARGETS assimp_qt_viewer DESTINATION "${ASSIMP_BIN_INSTALL_DIR}") From df9faaae41d65e41209ae011beca38e973d5bf2d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 16 May 2018 19:39:27 +0200 Subject: [PATCH 031/214] Update Readme.md Remove deprecated doc. --- Readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/Readme.md b/Readme.md index 856371d7e..449efc547 100644 --- a/Readme.md +++ b/Readme.md @@ -140,8 +140,6 @@ Open Asset Import Library is implemented in C++. The directory structure is: /tools Tools (old assimp viewer, command line `assimp`) /samples A small number of samples to illustrate possible use cases for Assimp - /workspaces Build environments for vc,xcode,... (deprecated, - CMake has superseded all legacy build options!) ### Where to get help ### From 224b43a3a9c8993c0ca96b1189ba91d968fe4e5d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 16 May 2018 21:19:30 +0200 Subject: [PATCH 032/214] Update CHANGES Add 4.1.0 release notes --- CHANGES | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 258 insertions(+) diff --git a/CHANGES b/CHANGES index d5faab2e0..c0c73b98c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,264 @@ ---------------------------------------------------------------------- CHANGELOG ---------------------------------------------------------------------- +4.1.0 (2017-12): +- FEATURES: + - Export 3MF ( experimental ) + - Import / Export glTF 2 + - Introduce new zib-lib to eb able to export zip-archives +- FIXES/HOUSEKEEPING: + - Added missing include to stdlib.h and remove load library call + - Fix install for builds with MSVC compiler and NMake. + - Update list of supported file formats. + - Add TriLib to the official list of supported ports. + - Re-enabling PACK_STRUCT for MDL files. + - Use std.::unique_ptr + - Update D3MFExporter.h + - Update MD3Loader.cpp, using index + - Fix all warnings on MSVC14 + - Copy assimp dll to unit folder on windows + - Update jvm port supported formats + - Add support for building Mac OS X Framework bundles + - Check for nullptr dereferencing before copying scene data + - Update ValidateDataStructure.h, typo + - Enable data structure validation in cases where it doesn't cause failures + - Remove some dead assignments + - fast_atof: Silence some uninitialized variable warnings + - Check for area test if the face is a triangle. + - Set mNumUVComponents to 0 when deleting texture coordinate sets + - Only scale the root node because this will rescale all children nodes as well. + - Issue 1514: Fix frame pointer arithmetic + - Prevent failing stringstream to crash the export process + - powf -> pow + - add Defines.h to include folder for install. + - Android: + - Fix android build + - Fix assimp for cross compile for android + - Use define for D_FILE_OFFSET_BITS only for not-android systems. + - FBX: + - Fix handling with embedded textures + - FBX 7500 Binary reading + - Remove dead assignment + - Fix export of deleted meshes; Add LazyDict::Remove method + - Log an error instead of letting the fbx-importer crash. ( issue 213 ) + - Replace bad pointer casting with memcpy + - Remove useless const qualifier from return value + - Add explicit instantiation of log_prefix so other FBX source files can see it + - add missing inversion of postrotation matrix for fbx. + - FIReader: Silence uninitialized variable warning + - Update version check in FBX reader to check for version >= 7500 + - Use actual min/max of anim keys when start/stop time is missing +- GLTF1: + - Fix output of glTF 1 version string + - Fix delete / delete[] mismatch in glTFAsset + - Don’t ignore rgba(1,1,1,1) color properties + - glTF2 primitives fixes + - Don’t ignore rgba(1,1,1,1) color properties + - Fix delete / delete[] mismatch in glTFAsset + - Remove KHR_binary_glTF code + - glTF nodes can only hold one mesh. this simply assigns to and check’s a Node’s Mesh + - version in glb header is stored as uint32_t +- GLTF2: + - node name conflict fix + - Fix transform matrices multiplication order + - Preserve node names when importing + - Add support for tangents in import + - Fix typo on gltf2 camera parameters + - Moved byteStride from accessor to bufferView + - Implemented reading binary glTF2 (glb) files + - Fix signed/unsigned warning + - Add postprocess step for scaling + - Fix shininess to roughness conversion + - Prefer “BLEND” over “MASK” as an alphaMode default + - Approximate specularity / glossiness in metallicRoughness materials + - Diffuse color and diffuse texture import and export improvements + - Addressed some mismatched news/deletes caused by the new glTF2 sources. + - Fix delete / delete[] mismatches in glTF2 importer + - use correct name of exporter to gltf2 + - Fix possible infinite loop when exporting to gltf2 + - Fix glTF2::Asset::FindUniqueID() when the input string is >= 256 chars + - Fix glTF2 alphaMode storage and reading + - Fix glTF 2.0 multi-primitive support + - Load gltf .bin files from correct directory + - Add support for importing both glTF and glTF2 files + - ampler improvements; Add new LazyDict method + - Changes to GLTF2 materials + - Remove Light, Technique references + - Start removing materials common, and adding pbrSpecularGlossiness + - Use !ObjectEmpty() vs. MemberCount() > 0 + - Working read, import, export, and write of gltf2 (pbr) material + - Check in gltf2 models to test directory + - Remove un-needed test models + - Start managing and importing gltf2 pbr materials + - Update glTF2 Asset to use indexes + - Duplicate gltfImporter as gltf2Importer; Include glTF2 importer in CMake List + - glTF2: Fix animation export + - use opacity for diffuse alpha + alphaMode +- STL: + - Restore import of multi mesh binary STLs +- Blender: + - Silence warning about uninitialized member +- MDLImporter: + - Don't take address of packed struct member +- assimp_cmd: + - Fix strict-aliasing warnings +- Open3DGC: + - Fix strict-aliasing warnings + - Add assertions to silence static analyzer warnings + - Remove redundant const qualifiers from return types + - Fix some uninitialized variable warnings + - Remove OPEN3DGC and compression references +- unzip: + - Remove dead assignment + - Bail on bad compression method + - Fix possibly uninitialized variables +- clipper: + - Add assertion to silence a static analyzer warning +- OpenDDLExport: + - Reduce scope of a variable + - Remove dead variable + - Remove dead assignment + - Fix another potential memory leak +- X3DImporter: + - Add assertions to silence static analyzer warnings + - Add missing unittest + - Workaround for buggy Android NDK (issue #1361) +- TerragenLoader: + - Remove unused variable +- SIBImporter: + - Add assertions to silence static analyzer warnings +- IFC: + - Remove dead code + - Add explicit instantiation of log_prefix so IFCMaterial.cpp can see it +- PLY: + - Remove dead assignment and reduce scope of a variable + - fix vertex attribute lookup. +- OpenGEX: + - Add assertion to silence a static analyzer warning + - Fix for TextureFile with number in file name + - Return early when element is TextureFile +- NFF: + - Add assertions to silence static analyzer warnings + - Split up some complicated assignments +- Raw: Fix misleading indentation warning + - Reduce scope of a variable +- LWO + - Reduce scope of a variable +- IRRLoader: + - Fix confusing boolean casting +- AssbinExporter: + - Add assertion to silence a static analyzer warning +- ASE: + - Add assertion to silence a static analyzer warning +- AMFImporter: + - Add assertion to silence a static analyzer warning + - Add a block +- OptimizeGraph: + - Fix possible null pointer dereference + - RemoveRedundantMaterials: + - Add assertion to silence a static analyzer warning +- ImproveCacheLocality: + - Add assertion to silence a static analyzer warning +- RemoveRedundantMaterials: + - Set pointer to nullptr after deleting it +- Travis: + - Disable unit tests in scan-build config + - Move slower builds earlier to improve parallelization + - Add static analysis to build + - Remove unused branch rule for travis. + - Add Clang UBSan build configuration + - Treat warnings as errors, without typos this time +- Unittests: + - Add VS-based source groups for the unittests. +- Collada: + - export tag + - Update ColladaExporter.cpp + - Silence uninitialized variable warning + - Add support for line strip primitives +- Obj Wavefront: + - check in exporting against out-of-bounds-access . + - Issue 1351: use correct name for obj-meshname export for groups. + - fix mem-lead: face will be not released in case of an error. + - Anatoscope obj exporter nomtl + - Raise exception when obj file contains invalid face indices + - Added alternative displacement texture token in OBJ MTL material. + - Obj: rename attribute from exporter. + - Fix OBJ discarding all material names if the material library is missing +- Step: + - use correct lookup for utf32 +- MD2: + - Fix MD2 frames containing garbage +- STL + - add missing const. + - Fix memory-alignment bug. + - Fix issue 104: deal with more solids in one STL file. +- CMake + - Fix issue 213: use correct include folder for assimp +- Doxygen + - Fix issue 1513: put irrXML onto exclucde list for doxygen run +- PyAssimp: + - Search for libassimp.so in LD_LIBRARY_PATH if available. + - Fix operator precedence issue in header check + - Split setup.py into multiple lines + - Detect if Anaconda and fixed 3d_viewer for Python 3 + - created a python3 version of the 3dviewer and fixed the / = float in py3 +- Blender: + - Fix invalid access to mesh array when the array is empty. + - Fix short overflow. + - Silence warning about inline function which is declared but not defined +- JAssimp + - Changed license header for IHMC contributions from Apache 2.0 to BSD + - Add Node metadata to the Jassmip Java API + - Added supported for custom IO Systems in Java. Implemented ClassLoader IO System + - Added a link to pure jvm assimp port +- Clang sanitizer: + - Undefined Behavior sanitizer + - Fixed a divide by zero error in IFCBoolean that was latent, but nevertheless a bug +- B3DImporter: + - Replace bad pointer casting with memcpy +- AppVeyor: + - Cleanup and Addition of VS 2017 and running Tests + - Fixed File Size reported as 0 in tests that use temporary files + - x86 isn't a valid VS platform. Win32 it is, then. + - Replaced the worker image name, which doesn't work as generator name, with a manually created generator name. + - Cleaned up appveyor setup, added VS 2017 to the build matrix and attempted to add running of tests. + - Treat warnings as errors on Appveyor + - Disable warning 4351 on MSVC 2013 +- OpenGEXImporter: + - Copy materials to scene + - Store RefInfo in unique_ptr so they get automatically cleaned up + - Fix IOStream leak + - Store ChildInfo in unique_ptr so they get automatically cleaned up + - improve logging to be able to detect error-prone situations. +- AMFImporter: + - Fix memory leak +- UnrealLoader: + - Fix IOStream leak +- Upgrade RapidJSON to get rid of a clang warning +- zlib: + - Update zlib contribution + - Removed unnecessary files from zlib contribution + - Replaced unsigned long for the crc table to z_crc_t, to match what is returned by get-crc_table +- MakeVerboseFormat: + - Fix delete / delete[] mismatches in MakeVerboseFormat +- MaterialSystem: + - Fix out-of-bounds read in MaterialSystem unit test +- SIB: + - Added support for SIB models from Silo 2.5 +- AssbinExporter: + - Fix strict aliasing violation + - Add Write specialization for aiColor3D +- DefaultLogger: + - Whitespace cleanup to fix GCC misleading indentation warning +- MDP: + - Fix encoding issues. + - PreTransformVertices: + - fix name lost in mesh and nodes when load with flag +- C4D: + - Fixes for C4D importer +- Unzip: + - Latest greatest. + 4.0.1 (2017-07-28) - FIXES/HOUSEKEEPING: - fix version test. From a1a17c1dda127adbd571fb063af9309eebaac4bd Mon Sep 17 00:00:00 2001 From: Stanlo Slasinski Date: Fri, 18 May 2018 14:01:25 -0700 Subject: [PATCH 033/214] Read and write the KHR_materials_unlit glTF/2.0 extension. --- code/glTF2Asset.h | 5 +++++ code/glTF2Asset.inl | 4 ++++ code/glTF2AssetWriter.h | 1 + code/glTF2AssetWriter.inl | 10 ++++++++++ code/glTF2Exporter.cpp | 6 ++++++ code/glTF2Importer.cpp | 3 +++ include/assimp/pbrmaterial.h | 1 + 7 files changed, 30 insertions(+) diff --git a/code/glTF2Asset.h b/code/glTF2Asset.h index dd9b11df5..0ce843d09 100644 --- a/code/glTF2Asset.h +++ b/code/glTF2Asset.h @@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * glTF Extensions Support: * KHR_materials_pbrSpecularGlossiness full + * KHR_materials_unlit full */ #ifndef GLTF2ASSET_H_INC #define GLTF2ASSET_H_INC @@ -741,6 +742,9 @@ namespace glTF2 //extension: KHR_materials_pbrSpecularGlossiness Nullable pbrSpecularGlossiness; + //extension: KHR_materials_unlit + bool unlit; + Material() { SetDefaults(); } void Read(Value& obj, Asset& r); void SetDefaults(); @@ -1037,6 +1041,7 @@ namespace glTF2 struct Extensions { bool KHR_materials_pbrSpecularGlossiness; + bool KHR_materials_unlit; } extensionsUsed; diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index d96db6d74..acf8cb331 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -860,6 +860,8 @@ inline void Material::Read(Value& material, Asset& r) this->pbrSpecularGlossiness = Nullable(pbrSG); } } + + unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit"); } } @@ -882,6 +884,7 @@ inline void Material::SetDefaults() alphaMode = "OPAQUE"; alphaCutoff = 0.5; doubleSided = false; + unlit = false; } inline void PbrSpecularGlossiness::SetDefaults() @@ -1253,6 +1256,7 @@ inline void Asset::ReadExtensionsUsed(Document& doc) if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true; CHECK_EXT(KHR_materials_pbrSpecularGlossiness); + CHECK_EXT(KHR_materials_unlit); #undef CHECK_EXT } diff --git a/code/glTF2AssetWriter.h b/code/glTF2AssetWriter.h index e2b97e8c4..493ca1c0a 100644 --- a/code/glTF2AssetWriter.h +++ b/code/glTF2AssetWriter.h @@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * glTF Extensions Support: * KHR_materials_pbrSpecularGlossiness: full + * KHR_materials_unlit: full */ #ifndef GLTF2ASSETWRITER_H_INC #define GLTF2ASSETWRITER_H_INC diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index 6be012676..0579dfdac 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -343,6 +343,12 @@ namespace glTF2 { } } + if (m.unlit) { + Value unlit; + unlit.SetObject(); + exts.AddMember("KHR_materials_unlit", unlit, w.mAl); + } + if (!exts.ObjectEmpty()) { obj.AddMember("extensions", exts, w.mAl); } @@ -683,6 +689,10 @@ namespace glTF2 { if (this->mAsset.extensionsUsed.KHR_materials_pbrSpecularGlossiness) { exts.PushBack(StringRef("KHR_materials_pbrSpecularGlossiness"), mAl); } + + if (this->mAsset.extensionsUsed.KHR_materials_unlit) { + exts.PushBack(StringRef("KHR_materials_unlit"), mAl); + } } if (!exts.Empty()) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index d4b3d67de..9e8dfc822 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -526,6 +526,12 @@ void glTF2Exporter::ExportMaterials() m->pbrSpecularGlossiness = Nullable(pbrSG); } + + bool unlit; + if (mat->Get(AI_MATKEY_GLTF_UNLIT, unlit) == AI_SUCCESS && unlit) { + mAsset->extensionsUsed.KHR_materials_unlit = true; + m->unlit = true; + } } } diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 2bcf8b5de..f478ca487 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -281,6 +281,9 @@ static aiMaterial* ImportMaterial(std::vector& embeddedTexIdxs, Asset& r, M SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR); } + if (mat.unlit) { + aimat->AddProperty(&mat.unlit, 1, AI_MATKEY_GLTF_UNLIT); + } return aimat; } diff --git a/include/assimp/pbrmaterial.h b/include/assimp/pbrmaterial.h index cd9b5e2bf..723957300 100644 --- a/include/assimp/pbrmaterial.h +++ b/include/assimp/pbrmaterial.h @@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0 #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0 #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0 +#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0 #define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord" #define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname" From 6c0553d810b2050e6291c8e0115c18f915ffa29b Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sat, 19 May 2018 22:02:54 +0200 Subject: [PATCH 034/214] Add mesh name to ValidateDataStructure log --- code/ValidateDataStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 51e04b96b..ed6bde724 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -369,7 +369,7 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh) // positions must always be there ... if (!pMesh->mNumVertices || (!pMesh->mVertices && !mScene->mFlags)) { - ReportError("The mesh contains no vertices"); + ReportError("The mesh %s contains no vertices", pMesh->mName.C_Str()); } if (pMesh->mNumVertices > AI_MAX_VERTICES) { @@ -386,7 +386,7 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh) // faces, too if (!pMesh->mNumFaces || (!pMesh->mFaces && !mScene->mFlags)) { - ReportError("Mesh contains no faces"); + ReportError("Mesh %s contains no faces", pMesh->mName.C_Str()); } // now check whether the face indexing layout is correct: From 4b5c49b0872e76eb1bd41af63bb3081236c5bb9f Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sat, 19 May 2018 22:03:59 +0200 Subject: [PATCH 035/214] Add test for issue 1970: STL with empty solid --- test/models/STL/triangle_with_empty_solid.stl | 11 +++++++++++ test/unit/utSTLImportExport.cpp | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/models/STL/triangle_with_empty_solid.stl diff --git a/test/models/STL/triangle_with_empty_solid.stl b/test/models/STL/triangle_with_empty_solid.stl new file mode 100644 index 000000000..2364b792f --- /dev/null +++ b/test/models/STL/triangle_with_empty_solid.stl @@ -0,0 +1,11 @@ +solid testTriangle + facet normal 0.0 0.0 1.0 + outer loop + vertex 1.0 1.0 0.0 + vertex -1.0 1.0 0.0 + vertex 0.0 -1.0 0.0 + endloop + endfacet +endsolid +solid emptySolid +endsolid diff --git a/test/unit/utSTLImportExport.cpp b/test/unit/utSTLImportExport.cpp index 181862560..de1e78a26 100644 --- a/test/unit/utSTLImportExport.cpp +++ b/test/unit/utSTLImportExport.cpp @@ -73,6 +73,16 @@ TEST_F( utSTLImporterExporter, test_with_two_solids ) { EXPECT_NE( nullptr, scene ); } +TEST_F(utSTLImporterExporter, test_with_empty_solid) { + Assimp::Importer importer; + //STL File with empty mesh. We should still be able to import other meshes in this file. ValidateDataStructure should fail. + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_empty_solid.stl", 0); + EXPECT_NE(nullptr, scene); + + const aiScene *scene2 = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_empty_solid.stl", aiProcess_ValidateDataStructure); + EXPECT_EQ(nullptr, scene2); +} + #ifndef ASSIMP_BUILD_NO_EXPORT TEST_F(utSTLImporterExporter, exporterTest) { From 84739fda0abd018a673b948b78999b4a6df0b92d Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sat, 19 May 2018 22:05:06 +0200 Subject: [PATCH 036/214] Fix #1970: stl with empty solid Log warning instead of stopping whole import. --- code/STLLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 46808503d..73a780e34 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -352,7 +352,7 @@ void STLImporter::LoadASCIIFile( aiNode *root ) { if (positionBuffer.empty()) { pMesh->mNumFaces = 0; - throw DeadlyImportError("STL: ASCII file is empty or invalid; no data loaded"); + ASSIMP_LOG_WARN("STL: mesh is empty or invalid; no data loaded"); } if (positionBuffer.size() % 3 != 0) { pMesh->mNumFaces = 0; From 978a7cbeb20c5a4aa0112dc2403379f7fbf84014 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Mon, 21 May 2018 11:50:19 +0200 Subject: [PATCH 037/214] Fix #1587 : add validation to LWS unit test It seems that the validation is now OK. Also add a bunch of tests to try to import each file we have in this format. --- test/unit/utLWSImportExport.cpp | 84 +++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/test/unit/utLWSImportExport.cpp b/test/unit/utLWSImportExport.cpp index dcf456b56..e34cfc90e 100644 --- a/test/unit/utLWSImportExport.cpp +++ b/test/unit/utLWSImportExport.cpp @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" #include "AbstractImportExportBase.h" +#include #include @@ -52,13 +53,90 @@ class utLWSImportExport : public AbstractImportExportBase { public: virtual bool importerTest() { Assimp::Importer importer; - const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", 0 ); + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", aiProcess_ValidateDataStructure); return nullptr != scene; - - return true; } }; TEST_F( utLWSImportExport, importLWSFromFileTest ) { EXPECT_TRUE( importerTest() ); } + +TEST_F(utLWSImportExport, importLWSmove_x_post_linear) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_linear.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_xz_bezier) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_bezier.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_xz_stepped) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_stepped.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_oldformat_56) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_56.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_post_offset_repeat) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_offset_repeat.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_xz_hermite) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_hermite.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_y_pre_ofrep_post_osc) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_y_pre_ofrep_post_osc.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_oldformat_6) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_6.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_post_repeat) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_repeat.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_xz_linear) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_linear.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_post_constant) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_constant.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_x_post_reset) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_reset.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + +TEST_F(utLWSImportExport, importLWSmove_xz_spline) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_spline.lws", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); +} + From 8abcc454ada68ff96f4c373cf1bd64403470021a Mon Sep 17 00:00:00 2001 From: smalcom Date: Mon, 21 May 2018 17:38:01 +0300 Subject: [PATCH 038/214] [F] Uninitialized variables. --- code/D3MFExporter.cpp | 2 +- test/unit/utMetadata.cpp | 2 +- test/unit/utSharedPPData.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/D3MFExporter.cpp b/code/D3MFExporter.cpp index 204e6f77b..99e2ff3f5 100644 --- a/code/D3MFExporter.cpp +++ b/code/D3MFExporter.cpp @@ -222,7 +222,7 @@ void D3MFExporter::writeMetaData() { return; } - const aiString *key; + const aiString *key = nullptr; const aiMetadataEntry *entry(nullptr); for ( size_t i = 0; i < numMetaEntries; ++i ) { mScene->mMetaData->Get( i, key, entry ); diff --git a/test/unit/utMetadata.cpp b/test/unit/utMetadata.cpp index 0801ffd3f..c2cd6e1ef 100644 --- a/test/unit/utMetadata.cpp +++ b/test/unit/utMetadata.cpp @@ -210,7 +210,7 @@ TEST_F( utMetadata, copy_test ) { // int32_t test { - int32_t v; + int32_t v = 0; bool ok = copy.Get( "int32", v ); EXPECT_TRUE( ok ); EXPECT_EQ( i32v, v ); diff --git a/test/unit/utSharedPPData.cpp b/test/unit/utSharedPPData.cpp index a7c3043a5..94f2a5678 100644 --- a/test/unit/utSharedPPData.cpp +++ b/test/unit/utSharedPPData.cpp @@ -78,7 +78,7 @@ TEST_F(SharedPPDataTest, testPODProperty) { int i = 5; shared->AddProperty("test",i); - int o; + int o = 0; EXPECT_TRUE(shared->GetProperty("test",o)); EXPECT_EQ(5, o); EXPECT_FALSE(shared->GetProperty("test2",o)); From 348b34a2de53e14be058f2beadf5d2c506c02104 Mon Sep 17 00:00:00 2001 From: smalcom Date: Mon, 21 May 2018 17:38:43 +0300 Subject: [PATCH 039/214] [F] Wrong type in equation. --- tools/assimp_qt_viewer/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index d7d809086..ae68a2234 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -301,7 +301,7 @@ QMap exportersMap; return; } - for (int i = 0; i < exporter.GetExportFormatCount(); ++i) + for (size_t i = 0; i < exporter.GetExportFormatCount(); ++i) { const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i); exportersList.push_back(desc->id + QString(": ") + desc->description); From 7777883fe73bd401777f68e78659c504c48c6cb6 Mon Sep 17 00:00:00 2001 From: Adrian Mark Perez Date: Tue, 22 May 2018 13:55:36 -0700 Subject: [PATCH 040/214] Fix GenVertexNormals --- code/GenVertexNormalsProcess.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index 7f29411c3..f0fb0ba19 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -146,7 +146,7 @@ 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)); + const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); for (unsigned int i = 0;i < face.mNumIndices;++i) { pMesh->mNormals[face.mIndices[i]] = vNor; @@ -214,17 +214,15 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound); aiVector3D vr = pMesh->mNormals[i]; - ai_real vrlen = vr.Length(); aiVector3D pcNor; for (unsigned int a = 0; a < verticesFound.size(); ++a) { aiVector3D v = pMesh->mNormals[verticesFound[a]]; - // check whether the angle between the two normals is not too large - // HACK: if v.x is qnan the dot product will become qnan, too - // therefore the comparison against fLimit should be false - // in every case. - if (v * vr >= fLimit * vrlen * v.Length()) + // Check whether the angle between the two normals is not too large. + // Skip the angle check on our own normal to avoid false negatives + // (v*v is not guaranteed to be 1.0 for all unit vectors v) + if (is_not_qnan(v.x) && (verticesFound[a] == i || (v * vr >= fLimit))) pcNor += v; } pcNew[i] = pcNor.NormalizeSafe(); From 0c07397720bc722cba1af6bf379e72a62b1fb77c Mon Sep 17 00:00:00 2001 From: gstanlo Date: Tue, 22 May 2018 17:32:12 -0700 Subject: [PATCH 041/214] glTF/2.0: Pick scene zero as scene to recursively load if no "scene" property is specified. --- code/glTF2Asset.inl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index acf8cb331..5aa658f61 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -1216,12 +1216,15 @@ inline void Asset::Load(const std::string& pFile, bool isBinary) // Read the "scene" property, which specifies which scene to load // and recursively load everything referenced by it + unsigned int sceneIndex = 0; if (Value* scene = FindUInt(doc, "scene")) { - unsigned int sceneIndex = scene->GetUint(); + sceneIndex = scene->GetUint(); + } - Ref s = scenes.Retrieve(sceneIndex); - - this->scene = s; + if (Value* scenesArray = FindArray(doc, "scenes")) { + if (sceneIndex < scenesArray->Size()) { + this->scene = scenes.Retrieve(sceneIndex); + } } // Clean up From e201fcf4f43e0fe929aaddb10dce907fed59d839 Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 12:25:27 +0300 Subject: [PATCH 042/214] [-] Function "GetExtension" always return lowercase string. Using uppercase extension in desc is not needed. --- code/3DSLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index 3c95d8193..cd79b0a6d 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -71,7 +71,7 @@ static const aiImporterDesc desc = { 0, 0, 0, - "3ds prj 3DS PRJ" + "3ds prj" }; @@ -127,7 +127,7 @@ Discreet3DSImporter::~Discreet3DSImporter() { // Returns whether the class can handle the format of the given file. bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const { std::string extension = GetExtension(pFile); - if(extension == "3ds" || extension == "3DS" || extension == "prj"|| extension == "PRJ" ) { + if(extension == "3ds" || extension == "prj") { return true; } From 6093769da1d62fe115b633d6b5ce9f1eacf954a0 Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 12:31:49 +0300 Subject: [PATCH 043/214] [*] Refactoring of "draw axes" procedure. [-] Removed not working part of code for reloading textures. That do nothing, just show checkbox. As Yoda said: "Do. Or do not. There is no try." --- tools/assimp_qt_viewer/glview.cpp | 39 ++++++--------------------- tools/assimp_qt_viewer/glview.hpp | 16 +++++------ tools/assimp_qt_viewer/mainwindow.cpp | 15 +---------- tools/assimp_qt_viewer/mainwindow.hpp | 2 -- 4 files changed, 17 insertions(+), 55 deletions(-) diff --git a/tools/assimp_qt_viewer/glview.cpp b/tools/assimp_qt_viewer/glview.cpp index a9a60a6fc..c52ac34e3 100644 --- a/tools/assimp_qt_viewer/glview.cpp +++ b/tools/assimp_qt_viewer/glview.cpp @@ -560,30 +560,6 @@ void CGLView::Enable_Textures(const bool pEnable) } } -void CGLView::Enable_Axes(const bool pEnable){ - if(pEnable) - { - this->mAxesEnabled = true; - } - else - { - this->mAxesEnabled = false; - } -} - -void CGLView::Enable_Reload_Textures(const bool pEnable) -{ - if(pEnable) - { - this->mReloadTexturesEnabled = true; -// this->mScene->ImportTextures(this->mScene->pScenePath); - } - else - { - this->mReloadTexturesEnabled = false; - } -} - /********************************************************************/ /*********************** Override functions ************************/ /********************************************************************/ @@ -619,7 +595,11 @@ void CGLView::resizeGL(int pWidth, int pHeight) } void CGLView::drawCoordSystem() { - glBindTexture(GL_TEXTURE_1D, 0); + // Disable lighting. Colors must be bright and colorful) + if ( mLightingEnabled ) glDisable( GL_LIGHTING );///TODO: display list + + // For same reason - disable textures. + glBindTexture(GL_TEXTURE_1D, 0); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_3D, 0); glEnable(GL_COLOR_MATERIAL); @@ -635,6 +615,8 @@ void CGLView::drawCoordSystem() { qglColor(QColor(Qt::yellow)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, -100000.0); qglColor(QColor(Qt::white)); glEnd(); + // Restore previous state of lighting. + if(mLightingEnabled) glEnable(GL_LIGHTING); } void CGLView::paintGL() @@ -651,17 +633,12 @@ void CGLView::paintGL() glTranslatef(-mHelper_Camera.Translation_ToScene.x, -mHelper_Camera.Translation_ToScene.y, -mHelper_Camera.Translation_ToScene.z); glMultMatrixf((GLfloat*)&mHelper_Camera.Rotation_Scene); // Coordinate system - if ( mLightingEnabled ) { - glDisable( GL_LIGHTING );///TODO: display list - } - if (this->mAxesEnabled == true) + if (mScene_AxesEnabled == true) { drawCoordSystem(); } glDisable(GL_COLOR_MATERIAL); - if(mLightingEnabled) glEnable(GL_LIGHTING); - // Scene if(mScene != nullptr) { diff --git a/tools/assimp_qt_viewer/glview.hpp b/tools/assimp_qt_viewer/glview.hpp index 1c397f13f..3bfb8fa08 100644 --- a/tools/assimp_qt_viewer/glview.hpp +++ b/tools/assimp_qt_viewer/glview.hpp @@ -75,9 +75,7 @@ private: }; public: - bool mAxesEnabled = true; - // Textures - bool mReloadTexturesEnabled = false; // If true then textures will reload when the window is activated. + /// \enum ELightType /// Type of light source. enum class ELightType { Directional, Point, Spot }; @@ -146,6 +144,7 @@ private: SBBox mScene_BBox;///< Bounding box of scene. aiVector3D mScene_Center;///< Coordinates of center of the scene. bool mScene_DrawBBox = false;///< Flag which control drawing scene BBox. + bool mScene_AxesEnabled = true;///< Flag which control drawing axes of the coordinate system. // Meshes size_t mHelper_Mesh_Quantity = 0;///< Quantity of meshes in scene. SHelper_Mesh** mHelper_Mesh = nullptr;///< Array of pointers to helper objects for drawing mesh. Sequence of meshes are equivalent to \ref aiScene::mMeshes. @@ -254,7 +253,11 @@ private: /********************************************************************/ protected: + + /// \fn void drawCoordSystem() + /// Draw axes of the coordinate system. void drawCoordSystem(); + /// \fn void initializeGL() override /// Override function to initialise OpenGL. void initializeGL() override; @@ -307,11 +310,8 @@ public: /// \param [in] pEnable - if true then enable textures, false - disable textures. void Enable_Textures(const bool pEnable); - void Enable_Axes(const bool pEnable); - /// \fn void Enable_Textures(const bool pEnable) - /// Control textures drawing. - /// \param [in] pEnable - if true then enable textures, false - disable textures. - void Enable_Reload_Textures(const bool pEnable); + ///TODO: doc + void Enable_Axes(const bool pEnable) { this->mScene_AxesEnabled = pEnable; } /********************************************************************/ /******************** Lighting control functions ********************/ diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index ae68a2234..cd52230f3 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -48,7 +48,7 @@ QTime time_begin = QTime::currentTime(); ui->cbxLighting->setChecked(true); mGLView->Lighting_Enable(); ui->cbxBBox->setChecked(false); mGLView->Enable_SceneBBox(false); ui->cbxTextures->setChecked(true); mGLView->Enable_Textures(true); - ui->cbxReloadTextures->setChecked(true); mGLView->Enable_Reload_Textures(false); + // // Fill info labels // @@ -195,13 +195,6 @@ GLfloat step; /********************************************************************/ /********************** Constructor/Destructor **********************/ /********************************************************************/ -bool MainWindow::event(QEvent *e) -{ - if (e->type() == QEvent::WindowActivate && this->mGLView->mReloadTexturesEnabled == true) { - qInfo() << "Window Activated"; - } - return QWidget::event(e); -} MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -378,12 +371,6 @@ void MainWindow::on_cbxDrawAxes_clicked(bool checked) mGLView->updateGL(); } -void MainWindow::on_cbxReloadTextures_clicked(bool checked) -{ - mGLView->Enable_Reload_Textures(checked); - mGLView->updateGL(); -} - void MainWindow::on_cbxTextures_clicked(bool checked) { mGLView->Enable_Textures(checked); diff --git a/tools/assimp_qt_viewer/mainwindow.hpp b/tools/assimp_qt_viewer/mainwindow.hpp index da8a852ac..14e870f51 100644 --- a/tools/assimp_qt_viewer/mainwindow.hpp +++ b/tools/assimp_qt_viewer/mainwindow.hpp @@ -90,7 +90,6 @@ protected: /// \param [in] pEvent - pointer to event data. void keyPressEvent(QKeyEvent* pEvent) override; - bool event(QEvent*); public: /********************************************************************/ @@ -134,5 +133,4 @@ private slots: void on_cbxBBox_clicked(bool checked); void on_cbxTextures_clicked(bool checked); void on_cbxDrawAxes_clicked(bool checked); - void on_cbxReloadTextures_clicked(bool checked); }; From c23f99919673331bb578846c25068568ae86bc86 Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 12:34:18 +0300 Subject: [PATCH 044/214] [+] QtCreator temporary file. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f8dda3e8b..60884061d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ build bin/ lib/ +# QtCreator +CMakeLists.txt.user # Generated assimp.pc From f56432f713f9cfa99210db2f050ea850b51be74e Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 13:04:39 +0300 Subject: [PATCH 045/214] [F] One alignment for labels. [-] Unused checkbox. --- tools/assimp_qt_viewer/mainwindow.ui | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/assimp_qt_viewer/mainwindow.ui b/tools/assimp_qt_viewer/mainwindow.ui index 9b139bafd..04208f585 100644 --- a/tools/assimp_qt_viewer/mainwindow.ui +++ b/tools/assimp_qt_viewer/mainwindow.ui @@ -302,6 +302,9 @@ + + Qt::AlignCenter + @@ -312,6 +315,9 @@ + + Qt::AlignCenter + @@ -325,6 +331,9 @@ + + Qt::AlignCenter + @@ -335,6 +344,9 @@ + + Qt::AlignCenter + @@ -349,6 +361,9 @@ + + Qt::AlignCenter + @@ -511,13 +526,6 @@ - - - - Live Reload Textures - - - From fd7f07068c2f173037e2f606f7308421ff6dc5fe Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 13:05:50 +0300 Subject: [PATCH 046/214] [F] React on mouse pressing ig view only. --- tools/assimp_qt_viewer/mainwindow.cpp | 64 ++++++++++++++++----------- tools/assimp_qt_viewer/mainwindow.hpp | 1 + 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index cd52230f3..2d87005a0 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -128,40 +128,54 @@ void MainWindow::LogError(const QString& pMessage) void MainWindow::mousePressEvent(QMouseEvent* pEvent) { - if(pEvent->button() & Qt::LeftButton) - mPosition_Pressed_LMB = pEvent->pos(); - else if(pEvent->button() & Qt::RightButton) - mPosition_Pressed_RMB = pEvent->pos(); +const QPoint ms_pt = pEvent->pos(); + + // Check if GLView is pointed. + if(childAt(ms_pt) == mGLView) + { + mPosition_Pressed_Valid = true; + if(pEvent->button() & Qt::LeftButton) + mPosition_Pressed_LMB = ms_pt; + else if(pEvent->button() & Qt::RightButton) + mPosition_Pressed_RMB = ms_pt; + } + else + { + mPosition_Pressed_Valid = false; + } } void MainWindow::mouseMoveEvent(QMouseEvent* pEvent) { - if(pEvent->buttons() & Qt::LeftButton) + if(mPosition_Pressed_Valid) { - GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width(); - GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_LMB.y()) / mGLView->height(); + if(pEvent->buttons() & Qt::LeftButton) + { + GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width(); + GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_LMB.y()) / mGLView->height(); - if(pEvent->modifiers() & Qt::ShiftModifier) - mGLView->Camera_RotateScene(dy, 0, dx);// Rotate around oX and oZ axises. - else - mGLView->Camera_RotateScene(dy, dx, 0);// Rotate around oX and oY axises. + if(pEvent->modifiers() & Qt::ShiftModifier) + mGLView->Camera_RotateScene(dy, 0, dx);// Rotate around oX and oZ axises. + else + mGLView->Camera_RotateScene(dy, dx, 0);// Rotate around oX and oY axises. - mGLView->updateGL(); - mPosition_Pressed_LMB = pEvent->pos(); - } + mGLView->updateGL(); + mPosition_Pressed_LMB = pEvent->pos(); + } - if(pEvent->buttons() & Qt::RightButton) - { - GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_RMB.x()) / mGLView->width(); - GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_RMB.y()) / mGLView->height(); + if(pEvent->buttons() & Qt::RightButton) + { + GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_RMB.x()) / mGLView->width(); + GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_RMB.y()) / mGLView->height(); - if(pEvent->modifiers() & Qt::ShiftModifier) - mGLView->Camera_Rotate(dy, 0, dx);// Rotate around oX and oZ axises. - else - mGLView->Camera_Rotate(dy, dx, 0);// Rotate around oX and oY axises. + if(pEvent->modifiers() & Qt::ShiftModifier) + mGLView->Camera_Rotate(dy, 0, dx);// Rotate around oX and oZ axises. + else + mGLView->Camera_Rotate(dy, dx, 0);// Rotate around oX and oY axises. - mGLView->updateGL(); - mPosition_Pressed_RMB = pEvent->pos(); + mGLView->updateGL(); + mPosition_Pressed_RMB = pEvent->pos(); + } } } @@ -198,7 +212,7 @@ GLfloat step; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - mScene(nullptr) + mScene(nullptr), mPosition_Pressed_Valid(false) { using namespace Assimp; diff --git a/tools/assimp_qt_viewer/mainwindow.hpp b/tools/assimp_qt_viewer/mainwindow.hpp index 14e870f51..fc31599b7 100644 --- a/tools/assimp_qt_viewer/mainwindow.hpp +++ b/tools/assimp_qt_viewer/mainwindow.hpp @@ -36,6 +36,7 @@ private: CLoggerView* mLoggerView;///< Pointer to logging object. Assimp::Importer mImporter;///< Assimp importer. const aiScene* mScene;///< Pointer to loaded scene (\ref aiScene). + bool mPosition_Pressed_Valid;///< Mouse button pressed on GLView. QPoint mPosition_Pressed_LMB;///< Position where was pressed left mouse button. QPoint mPosition_Pressed_RMB;///< Position where was pressed right mouse button. From e761f13c8042f6a840b8e29e77698046fc0b9a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=B6ller?= Date: Thu, 24 May 2018 12:07:05 +0200 Subject: [PATCH 047/214] does not access undefined memory area anymore. This will fix some Debuggers, which throw an exception, when accessing out-of-bound memory --- code/STLLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 73a780e34..b0ace74b6 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -365,10 +365,10 @@ void STLImporter::LoadASCIIFile( aiNode *root ) { pMesh->mNumFaces = static_cast(positionBuffer.size() / 3); pMesh->mNumVertices = static_cast(positionBuffer.size()); pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mVertices, &positionBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + memcpy(pMesh->mVertices, positionBuffer.data(), pMesh->mNumVertices * sizeof(aiVector3D)); positionBuffer.clear(); pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mNormals, &normalBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + memcpy(pMesh->mNormals, normalBuffer.data(), pMesh->mNumVertices * sizeof(aiVector3D)); normalBuffer.clear(); // now copy faces From f59ab5c34f2e464ac247b5185f705959a6e20d42 Mon Sep 17 00:00:00 2001 From: smalcom Date: Thu, 24 May 2018 17:11:21 +0300 Subject: [PATCH 048/214] [F] More correct control by a mouse --- tools/assimp_qt_viewer/glview.cpp | 21 +++++++++--- tools/assimp_qt_viewer/glview.hpp | 23 ++++++++++--- tools/assimp_qt_viewer/mainwindow.cpp | 47 ++++++++++++++++++--------- tools/assimp_qt_viewer/mainwindow.hpp | 19 +++++++++-- 4 files changed, 82 insertions(+), 28 deletions(-) diff --git a/tools/assimp_qt_viewer/glview.cpp b/tools/assimp_qt_viewer/glview.cpp index c52ac34e3..833400c46 100644 --- a/tools/assimp_qt_viewer/glview.cpp +++ b/tools/assimp_qt_viewer/glview.cpp @@ -1073,24 +1073,30 @@ void CGLView::Camera_Set(const size_t pCameraNumber) gluLookAt(hcam.Position.x, hcam.Position.y, hcam.Position.z, hcam.Target.x, hcam.Target.y, hcam.Target.z, up.x, up.y, up.z); } -void CGLView::Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z) +void CGLView::Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial) { auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 180.0; }; aiMatrix4x4 mat_rot; mat_rot.FromEulerAnglesXYZ(deg2rad(pAngle_X), deg2rad(pAngle_Y), deg2rad(pAngle_Z)); - mHelper_Camera.Rotation_Scene *= mat_rot; + if(pMatrix_Rotation_Initial != nullptr) + mHelper_Camera.Rotation_Scene = *pMatrix_Rotation_Initial * mat_rot; + else + mHelper_Camera.Rotation_Scene *= mat_rot; } -void CGLView::Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z) +void CGLView::Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial) { auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 180.0; }; aiMatrix4x4 mat_rot; mat_rot.FromEulerAnglesXYZ(deg2rad(pAngle_X), deg2rad(pAngle_Y), deg2rad(pAngle_Z)); - mHelper_Camera.Rotation_AroundCamera *= mat_rot; + if(pMatrix_Rotation_Initial != nullptr) + mHelper_Camera.Rotation_AroundCamera = *pMatrix_Rotation_Initial * mat_rot; + else + mHelper_Camera.Rotation_AroundCamera *= mat_rot; } void CGLView::Camera_Translate(const GLfloat pTranslate_X, const GLfloat pTranslate_Y, const GLfloat pTranslate_Z) @@ -1100,3 +1106,10 @@ aiVector3D vect_tr(pTranslate_X, pTranslate_Y, pTranslate_Z); vect_tr *= mHelper_Camera.Rotation_AroundCamera; mHelper_Camera.Translation_ToScene += vect_tr; } + +void CGLView::Camera_Matrix(aiMatrix4x4& pRotation_Camera, aiMatrix4x4& pRotation_Scene, aiVector3D& pTranslation_Camera) +{ + pRotation_Camera = mHelper_Camera.Rotation_AroundCamera; + pRotation_Scene = mHelper_Camera.Rotation_Scene; + pTranslation_Camera = mHelper_Camera.Translation_ToScene; +} diff --git a/tools/assimp_qt_viewer/glview.hpp b/tools/assimp_qt_viewer/glview.hpp index 3bfb8fa08..2d8614e21 100644 --- a/tools/assimp_qt_viewer/glview.hpp +++ b/tools/assimp_qt_viewer/glview.hpp @@ -310,7 +310,9 @@ public: /// \param [in] pEnable - if true then enable textures, false - disable textures. void Enable_Textures(const bool pEnable); - ///TODO: doc + /// \fn void Enable_Axes(const bool pEnable) + /// Control axes drawing. + /// \param [in] pEnable - if true then enable axes, false - disable axes. void Enable_Axes(const bool pEnable) { this->mScene_AxesEnabled = pEnable; } /********************************************************************/ @@ -350,19 +352,23 @@ public: /// \param [in] pCamera_Index - index of the camera (\ref aiScene::mCameras). void Camera_Set(const size_t pCameraNumber); - /// \fn void Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z) + /// \fn void Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial) /// Rotate scene around axisees. /// \param [in] pAngle_X - specifies the angle of rotation around axis oX, in degrees. /// \param [in] pAngle_Y - specifies the angle of rotation around axis oY, in degrees. /// \param [in] pAngle_Z - specifies the angle of rotation around axis oZ, in degrees. - void Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z); + /// \param [in] pMatrix_Rotation_Initial - matrix from which calculates new transformation matrix. If not set (equal to nullptr) then current transformation matrix + /// will be used. + void Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial = nullptr); - /// \fn void Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z) + /// \fn void Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial = nullptr) /// Rotate camera around axisees. /// \param [in] pAngle_X - specifies the angle of rotation around axis oX, in degrees. /// \param [in] pAngle_Y - specifies the angle of rotation around axis oY, in degrees. /// \param [in] pAngle_Z - specifies the angle of rotation around axis oZ, in degrees. - void Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z); + /// \param [in] pMatrix_Rotation_Initial - matrix from which calculates new transformation matrix. If not set (equal to nullptr) then current transformation matrix + /// will be used. + void Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial = nullptr); /// \fn void Camera_Translate(const size_t pTranslate_X, const size_t pTranslate_Y, const size_t pTranslate_Z) /// Translate camera along axises. In local coordinates. @@ -371,6 +377,13 @@ public: /// \param [in] pTranslate_Z - specifies the Z coordinate of translation vector. void Camera_Translate(const GLfloat pTranslate_X, const GLfloat pTranslate_Y, const GLfloat pTranslate_Z); + /// \fn void Camera_Matrix(aiMatrix4x4& pRotation_Camera, aiMatrix4x4& pRotation_Scene, aiVector3D& pTranslation_Camera) + /// Return data about camera position in world. + /// \param [out] pRotation_Camera - rotation matrix which set rotation angles of the scene around camera. + /// \param [out] pRotation_Scene - rotation matrix which set rotation angles of the scene around own center. + /// \param [out] pTranslation_Camera - translation vector from camera to the scene. + void Camera_Matrix(aiMatrix4x4& pRotation_Camera, aiMatrix4x4& pRotation_Scene, aiVector3D& pTranslation_Camera); + signals: /// \fn void Paint_Finished(const size_t pPaintTime, const GLfloat pDistance) diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index 2d87005a0..c17188472 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -130,51 +130,63 @@ void MainWindow::mousePressEvent(QMouseEvent* pEvent) { const QPoint ms_pt = pEvent->pos(); +__unused aiVector3D temp_v3; + // Check if GLView is pointed. if(childAt(ms_pt) == mGLView) { - mPosition_Pressed_Valid = true; + if(!mMouse_Transformation.Position_Pressed_Valid) + { + mMouse_Transformation.Position_Pressed_Valid = true;// set flag + // Store current transformation matrices. + mGLView->Camera_Matrix(mMouse_Transformation.Rotation_AroundCamera, mMouse_Transformation.Rotation_Scene, temp_v3); + } + if(pEvent->button() & Qt::LeftButton) - mPosition_Pressed_LMB = ms_pt; + mMouse_Transformation.Position_Pressed_LMB = ms_pt; else if(pEvent->button() & Qt::RightButton) - mPosition_Pressed_RMB = ms_pt; + mMouse_Transformation.Position_Pressed_RMB = ms_pt; } else { - mPosition_Pressed_Valid = false; + mMouse_Transformation.Position_Pressed_Valid = false; } } +void MainWindow::mouseReleaseEvent(QMouseEvent *pEvent) +{ + if(pEvent->buttons() == 0) mMouse_Transformation.Position_Pressed_Valid = false; + +} + void MainWindow::mouseMoveEvent(QMouseEvent* pEvent) { - if(mPosition_Pressed_Valid) + if(mMouse_Transformation.Position_Pressed_Valid) { if(pEvent->buttons() & Qt::LeftButton) { - GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width(); - GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_LMB.y()) / mGLView->height(); + GLfloat dx = 180 * GLfloat(pEvent->x() - mMouse_Transformation.Position_Pressed_LMB.x()) / mGLView->width(); + GLfloat dy = 180 * GLfloat(pEvent->y() - mMouse_Transformation.Position_Pressed_LMB.y()) / mGLView->height(); if(pEvent->modifiers() & Qt::ShiftModifier) - mGLView->Camera_RotateScene(dy, 0, dx);// Rotate around oX and oZ axises. + mGLView->Camera_RotateScene(dy, 0, dx, &mMouse_Transformation.Rotation_Scene);// Rotate around oX and oZ axises. else - mGLView->Camera_RotateScene(dy, dx, 0);// Rotate around oX and oY axises. + mGLView->Camera_RotateScene(dy, dx, 0, &mMouse_Transformation.Rotation_Scene);// Rotate around oX and oY axises. mGLView->updateGL(); - mPosition_Pressed_LMB = pEvent->pos(); } if(pEvent->buttons() & Qt::RightButton) { - GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_RMB.x()) / mGLView->width(); - GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_RMB.y()) / mGLView->height(); + GLfloat dx = 180 * GLfloat(pEvent->x() - mMouse_Transformation.Position_Pressed_RMB.x()) / mGLView->width(); + GLfloat dy = 180 * GLfloat(pEvent->y() - mMouse_Transformation.Position_Pressed_RMB.y()) / mGLView->height(); if(pEvent->modifiers() & Qt::ShiftModifier) - mGLView->Camera_Rotate(dy, 0, dx);// Rotate around oX and oZ axises. + mGLView->Camera_Rotate(dy, 0, dx, &mMouse_Transformation.Rotation_AroundCamera);// Rotate around oX and oZ axises. else - mGLView->Camera_Rotate(dy, dx, 0);// Rotate around oX and oY axises. + mGLView->Camera_Rotate(dy, dx, 0, &mMouse_Transformation.Rotation_AroundCamera);// Rotate around oX and oY axises. mGLView->updateGL(); - mPosition_Pressed_RMB = pEvent->pos(); } } } @@ -212,10 +224,13 @@ GLfloat step; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - mScene(nullptr), mPosition_Pressed_Valid(false) + mScene(nullptr) { using namespace Assimp; + // other variables + mMouse_Transformation.Position_Pressed_Valid = false; + ui->setupUi(this); // Create OpenGL widget mGLView = new CGLView(this); diff --git a/tools/assimp_qt_viewer/mainwindow.hpp b/tools/assimp_qt_viewer/mainwindow.hpp index fc31599b7..2eedf18f2 100644 --- a/tools/assimp_qt_viewer/mainwindow.hpp +++ b/tools/assimp_qt_viewer/mainwindow.hpp @@ -36,9 +36,17 @@ private: CLoggerView* mLoggerView;///< Pointer to logging object. Assimp::Importer mImporter;///< Assimp importer. const aiScene* mScene;///< Pointer to loaded scene (\ref aiScene). - bool mPosition_Pressed_Valid;///< Mouse button pressed on GLView. - QPoint mPosition_Pressed_LMB;///< Position where was pressed left mouse button. - QPoint mPosition_Pressed_RMB;///< Position where was pressed right mouse button. + + /// \struct SMouse_Transformation + /// Holds data about transformation of the scene/camera when mouse us used. + struct SMouse_Transformation + { + bool Position_Pressed_Valid;///< Mouse button pressed on GLView. + QPoint Position_Pressed_LMB;///< Position where was pressed left mouse button. + QPoint Position_Pressed_RMB;///< Position where was pressed right mouse button. + aiMatrix4x4 Rotation_AroundCamera;///< Rotation matrix which set rotation angles of the scene around camera. + aiMatrix4x4 Rotation_Scene;///< Rotation matrix which set rotation angles of the scene around own center. + } mMouse_Transformation; /**********************************/ /************ Functions ***********/ @@ -81,6 +89,11 @@ protected: /// \param [in] pEvent - pointer to event data. void mousePressEvent(QMouseEvent* pEvent) override; + /// \fn void mouseReleaseEvent(QMouseEvent *pEvent) override + /// Override function which handles mouse event "button released". + /// \param [in] pEvent - pointer to event data. + void mouseReleaseEvent(QMouseEvent *pEvent) override; + /// \fn void mouseMoveEvent(QMouseEvent* pEvent) override /// Override function which handles mouse event "move". /// \param [in] pEvent - pointer to event data. From 97cecc858a8d2dbedcd1f3517b8dc02f616d5143 Mon Sep 17 00:00:00 2001 From: gstanlo Date: Thu, 24 May 2018 17:25:26 -0700 Subject: [PATCH 049/214] Properly reads in glTF/2.0 sampler address modes. Assimp was returning glTF/2.0 values as address modes instead of aiTextureMapModes. Also modified text glTF/2.0 model's sampler uv address modes to mirror/clamp respectively, and tests for them in the unit test. --- code/glTF2Importer.cpp | 21 +++++++++++++++++-- .../glTF2/BoxTextured-glTF/BoxTextured.gltf | 4 ++-- test/unit/utglTF2ImportExport.cpp | 17 ++++++++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index f478ca487..15c338716 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -121,6 +121,21 @@ bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool return false; } +static aiTextureMapMode ConvertWrappingMode(SamplerWrap gltfWrapMode) +{ + switch (gltfWrapMode) { + case SamplerWrap::Mirrored_Repeat: + return aiTextureMapMode_Mirror; + + case SamplerWrap::Clamp_To_Edge: + return aiTextureMapMode_Clamp; + + case SamplerWrap::UNSET: + case SamplerWrap::Repeat: + default: + return aiTextureMapMode_Wrap; + } +} //static void CopyValue(const glTF2::vec3& v, aiColor3D& out) //{ @@ -198,8 +213,10 @@ inline void SetMaterialTextureProperty(std::vector& embeddedTexIdxs, Asset& mat->AddProperty(&name, AI_MATKEY_GLTF_MAPPINGNAME(texType, texSlot)); mat->AddProperty(&id, AI_MATKEY_GLTF_MAPPINGID(texType, texSlot)); - mat->AddProperty(&sampler->wrapS, 1, AI_MATKEY_MAPPINGMODE_U(texType, texSlot)); - mat->AddProperty(&sampler->wrapT, 1, AI_MATKEY_MAPPINGMODE_V(texType, texSlot)); + aiTextureMapMode wrapS = ConvertWrappingMode(sampler->wrapS); + aiTextureMapMode wrapT = ConvertWrappingMode(sampler->wrapT); + mat->AddProperty(&wrapS, 1, AI_MATKEY_MAPPINGMODE_U(texType, texSlot)); + mat->AddProperty(&wrapT, 1, AI_MATKEY_MAPPINGMODE_V(texType, texSlot)); if (sampler->magFilter != SamplerMagFilter::UNSET) { mat->AddProperty(&sampler->magFilter, 1, AI_MATKEY_GLTF_MAPPINGFILTER_MAG(texType, texSlot)); diff --git a/test/models/glTF2/BoxTextured-glTF/BoxTextured.gltf b/test/models/glTF2/BoxTextured-glTF/BoxTextured.gltf index eff658f02..88d65391e 100644 --- a/test/models/glTF2/BoxTextured-glTF/BoxTextured.gltf +++ b/test/models/glTF2/BoxTextured-glTF/BoxTextured.gltf @@ -146,8 +146,8 @@ { "magFilter": 9729, "minFilter": 9986, - "wrapS": 10497, - "wrapT": 10497 + "wrapS": 33648, + "wrapT": 33071 } ], "bufferViews": [ diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 58ebe3017..5117a56fc 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include using namespace Assimp; @@ -54,7 +55,21 @@ public: virtual bool importerTest() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure); - return nullptr != scene; + EXPECT_NE( scene, nullptr ); + if ( !scene ) return false; + + EXPECT_TRUE( scene->HasMaterials() ); + if ( !scene->HasMaterials() ) return false; + const aiMaterial *material = scene->mMaterials[0]; + + aiString path; + aiTextureMapMode modes[2]; + EXPECT_EQ( aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes) ); + EXPECT_STREQ( path.C_Str(), "CesiumLogoFlat.png" ); + EXPECT_EQ( modes[0], aiTextureMapMode_Mirror ); + EXPECT_EQ( modes[1], aiTextureMapMode_Clamp ); + + return true; } virtual bool binaryImporterTest() { From d72ff712cb70f8345a3eb02a633c790d719da348 Mon Sep 17 00:00:00 2001 From: smalcom Date: Fri, 25 May 2018 21:16:08 +0300 Subject: [PATCH 050/214] [F] List of importers can be empty. --- code/Importer.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/code/Importer.cpp b/code/Importer.cpp index 139dc6c51..347ce12d2 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -970,15 +970,19 @@ void Importer::GetExtensionList(aiString& szOut) const (*i)->GetExtensionList(str); } - for (std::set::const_iterator it = str.begin();; ) { - szOut.Append("*."); - szOut.Append((*it).c_str()); + // List can be empty + if(str.size() > 0) + { + for (std::set::const_iterator it = str.begin();; ) { + szOut.Append("*."); + szOut.Append((*it).c_str()); - if (++it == str.end()) { - break; - } - szOut.Append(";"); - } + if (++it == str.end()) { + break; + } + szOut.Append(";"); + } + } ASSIMP_END_EXCEPTION_REGION(void); } From 67eff10d8f3197dea997039cdeb63de59825861b Mon Sep 17 00:00:00 2001 From: smalcom Date: Fri, 25 May 2018 21:19:06 +0300 Subject: [PATCH 051/214] [*] qt_assimp_viewer can be built with Qt4 or Qt5. [F] Working in doule precision. --- CMakeLists.txt | 27 +-- tools/assimp_qt_viewer/CMakeLists.txt | 127 ++++++++++---- tools/assimp_qt_viewer/glview.cpp | 233 ++++++++++++++++++++++++-- tools/assimp_qt_viewer/glview.hpp | 16 +- tools/assimp_qt_viewer/mainwindow.cpp | 41 ++++- tools/assimp_qt_viewer/mainwindow.hpp | 6 +- 6 files changed, 370 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb407c4b1..d5a7bc278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,32 +412,7 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) ENDIF ( WIN32 AND DirectX_D3DX9_LIBRARY ) ADD_SUBDIRECTORY( tools/assimp_cmd/ ) - - # Check dependencies for assimp_qt_viewer. - # 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 ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND) - ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ ) - ELSE() - SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "") - IF (NOT Qt5_FOUND) - SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt5") - ENDIF (NOT Qt5_FOUND) - - IF (NOT IL_FOUND) - SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL") - ENDIF (NOT IL_FOUND) - - IF (NOT OPENGL_FOUND) - SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} OpengGL") - ENDIF (NOT OPENGL_FOUND) - - MESSAGE (WARNING "Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: ${ASSIMP_QT_VIEWER_DEPENDENCIES}") - ENDIF ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND) + ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ ) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( ASSIMP_BUILD_SAMPLES) diff --git a/tools/assimp_qt_viewer/CMakeLists.txt b/tools/assimp_qt_viewer/CMakeLists.txt index b41291e3d..51a4efad8 100644 --- a/tools/assimp_qt_viewer/CMakeLists.txt +++ b/tools/assimp_qt_viewer/CMakeLists.txt @@ -3,44 +3,103 @@ project(assimp_qt_viewer) cmake_minimum_required(VERSION 2.6) -find_package(Qt5 COMPONENTS Gui Widgets OpenGL REQUIRED) -find_package(DevIL REQUIRED) -find_package(OpenGL REQUIRED) - -include_directories( - ${Qt5Widgets_INCLUDES} - ${Assimp_SOURCE_DIR}/include - ${Assimp_SOURCE_DIR}/code - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR} - ${OPENGL_INCLUDE_DIR} - ${IL_INCLUDE_DIR} +OPTION( ASSIMP_QT4_VIEWER + "Set to ON to enable Qt4 against Qt5 for assimp_qt_viewer" + OFF ) -link_directories(${Assimp_BINARY_DIR}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall") +FIND_PACKAGE(DevIL QUIET) +FIND_PACKAGE(OpenGL QUIET) -set(assimp_qt_viewer_SRCS main.cpp loggerview.cpp glview.cpp mainwindow.cpp) -qt5_wrap_ui(UISrcs mainwindow.ui) -qt5_wrap_cpp(MOCrcs mainwindow.hpp glview.hpp) +IF(ASSIMP_QT4_VIEWER) + # Qt4 version + FIND_PACKAGE(Qt4 QUIET) +ELSE(ASSIMP_QT4_VIEWER) + # Qt5 version + FIND_PACKAGE(Qt5 COMPONENTS Gui Widgets OpenGL QUIET) +ENDIF(ASSIMP_QT4_VIEWER) -add_executable(${PROJECT_NAME} ${assimp_qt_viewer_SRCS} ${UISrcs} ${MOCrcs}) -target_link_libraries(${PROJECT_NAME} Qt5::Gui Qt5::Widgets Qt5::OpenGL ${IL_LIBRARIES} ${OPENGL_LIBRARIES} assimp) +SET(VIEWER_BUILD:BOOL FALSE) -if(WIN32) # Check if we are on Windows - if(MSVC) # Check if we are using the Visual Studio compiler - #set_target_properties(TestProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") - elseif(CMAKE_COMPILER_IS_GNUCXX) - # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Not tested - else() - message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)") - endif() -elseif(UNIX) - # Nothing special required -else() - message(SEND_ERROR "You are on an unsupported platform! (Not Win32 or Unix)") -endif() +IF((Qt4_FOUND OR Qt5Widgets_FOUND) AND IL_FOUND AND OPENGL_FOUND) + SET(VIEWER_BUILD TRUE) -set_property(TARGET ${PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) +ELSE((Qt4_FOUND OR Qt5Widgets_FOUND) AND IL_FOUND AND OPENGL_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "") -install(TARGETS assimp_qt_viewer DESTINATION "${ASSIMP_BIN_INSTALL_DIR}") + IF(ASSIMP_QT4_VIEWER) + IF (NOT Qt4_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt4") + ENDIF (NOT Qt4_FOUND) + + ELSE(ASSIMP_QT4_VIEWER) + IF (NOT Qt5_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt5") + ENDIF (NOT Qt5_FOUND) + + ENDIF(ASSIMP_QT4_VIEWER) + + IF (NOT IL_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL") + ENDIF (NOT IL_FOUND) + + IF (NOT OPENGL_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} OpengGL") + ENDIF (NOT OPENGL_FOUND) + + MESSAGE (WARNING "Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: ${ASSIMP_QT_VIEWER_DEPENDENCIES}") +ENDIF((Qt4_FOUND OR Qt5Widgets_FOUND) AND IL_FOUND AND OPENGL_FOUND) + +IF(VIEWER_BUILD) + INCLUDE_DIRECTORIES( + ${Assimp_SOURCE_DIR}/include + ${Assimp_SOURCE_DIR}/code + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${OPENGL_INCLUDE_DIR} + ${IL_INCLUDE_DIR} + ) + + LINK_DIRECTORIES(${Assimp_BINARY_DIR}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall") + + SET(assimp_qt_viewer_SRCS main.cpp loggerview.cpp glview.cpp mainwindow.cpp) + + IF(ASSIMP_QT4_VIEWER) + MESSAGE("assimp_qt_viewer use Qt4") + ADD_DEFINITIONS( -DASSIMP_QT4_VIEWER ) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + qt4_wrap_ui(UISrcs mainwindow.ui) + qt4_wrap_cpp(MOCrcs mainwindow.hpp glview.hpp) + ELSE() + MESSAGE("assimp_qt_viewer use Qt5") + INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDES}) + qt5_wrap_ui(UISrcs mainwindow.ui) + qt5_wrap_cpp(MOCrcs mainwindow.hpp glview.hpp) + ENDIF() + + add_executable(${PROJECT_NAME} ${assimp_qt_viewer_SRCS} ${UISrcs} ${MOCrcs}) + + IF(ASSIMP_QT4_VIEWER) + target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${IL_LIBRARIES} ${OPENGL_LIBRARIES} assimp) + ELSE() + target_link_libraries(${PROJECT_NAME} Qt5::Gui Qt5::Widgets Qt5::OpenGL ${IL_LIBRARIES} ${OPENGL_LIBRARIES} assimp) + ENDIF() + + IF(WIN32) # Check if we are on Windows + IF(MSVC) # Check if we are using the Visual Studio compiler + #set_target_properties(TestProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") + ELSEIF(CMAKE_COMPILER_IS_GNUCXX) + # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Not tested + ELSE() + MESSAGE(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)") + ENDIF() + ELSEIF(UNIX) + # Nothing special required + ELSE() + MESSAGE(SEND_ERROR "You are on an unsupported platform! (Not Win32 or Unix)") + ENDIF() + + SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) + INSTALL(TARGETS assimp_qt_viewer DESTINATION "${ASSIMP_BIN_INSTALL_DIR}") +ENDIF(VIEWER_BUILD) diff --git a/tools/assimp_qt_viewer/glview.cpp b/tools/assimp_qt_viewer/glview.cpp index 833400c46..c67420c06 100644 --- a/tools/assimp_qt_viewer/glview.cpp +++ b/tools/assimp_qt_viewer/glview.cpp @@ -5,6 +5,9 @@ #include "glview.hpp" +// Header files, Qt. +#include + // Header files, OpenGL. #if defined(__APPLE__) # include @@ -58,6 +61,33 @@ void CGLView::SHelper_Camera::SetDefault() /************ CGLView *************/ /**********************************/ +#if !ASSIMP_QT4_VIEWER +# define ConditionalContextControl_Begin \ + bool ContextEnabledHere; \ + \ + if(mGLContext_Current) \ + { \ + ContextEnabledHere = false; \ + } \ + else \ + { \ + makeCurrent(); \ + mGLContext_Current = true; \ + ContextEnabledHere = true; \ + } \ + \ + do {} while(false) + +# define ConditionalContextControl_End \ + if(ContextEnabledHere) \ + { \ + doneCurrent(); \ + mGLContext_Current = false; \ + } \ + \ + do {} while(false) +#endif // ASSIMP_QT4_VIEWER + void CGLView::Material_Apply(const aiMaterial* pMaterial) { GLfloat tcol[4]; @@ -105,7 +135,7 @@ void CGLView::Material_Apply(const aiMaterial* pMaterial) glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, tcol); // Shininess - float shininess, strength; + ai_real shininess, strength; max = 1; ret1 = aiGetMaterialFloatArray(pMaterial, AI_MATKEY_SHININESS, &shininess, &max); @@ -406,10 +436,11 @@ void CGLView::BBox_GetFromVertices(const aiVector3D* pVertices, const size_t pVe for(size_t idx_vert = 1; idx_vert < pVerticesQuantity; idx_vert++) { - const GLfloat x = pVertices[idx_vert].x; - const GLfloat y = pVertices[idx_vert].y; - const GLfloat z = pVertices[idx_vert].z; + const ai_real x = pVertices[idx_vert].x; + const ai_real y = pVertices[idx_vert].y; + const ai_real z = pVertices[idx_vert].z; + printf("vert[%lu]=%g,%g,%g\r\n", idx_vert, x, y, z);///TODO: dbg // search minimal... AssignIfLesser(&pBBox.Minimum.x, x); AssignIfLesser(&pBBox.Minimum.y, y); @@ -439,14 +470,29 @@ void CGLView::LogError(const QString& pMessage) /************************** Draw functions **************************/ /********************************************************************/ +static void print_matrix(const aiMatrix4x4 pMatrix)///TODO: dbg +{ + printf("Matrix:\r\n"); + printf("\t%g,%g,%g%g\r\n", pMatrix.a1, pMatrix.a2, pMatrix.a3, pMatrix.a4); + printf("\t%g,%g,%g%g\r\n", pMatrix.b1, pMatrix.b2, pMatrix.b3, pMatrix.b4); + printf("\t%g,%g,%g%g\r\n", pMatrix.c1, pMatrix.c2, pMatrix.c3, pMatrix.c4); + printf("\t%g,%g,%g%g\r\n", pMatrix.d1, pMatrix.d2, pMatrix.d3, pMatrix.d4); +} + void CGLView::Draw_Node(const aiNode* pNode) { aiMatrix4x4 mat_node = pNode->mTransformation; // Apply node transformation matrix. mat_node.Transpose(); + print_matrix(mat_node); glPushMatrix(); +#if ASSIMP_DOUBLE_PRECISION + glMultMatrixd((GLdouble*)mat_node[0]); +#else glMultMatrixf((GLfloat*)&mat_node); +#endif // ASSIMP_DOUBLE_PRECISION + // Draw all meshes assigned to this node for(size_t idx_mesh_arr = 0; idx_mesh_arr < pNode->mNumMeshes; idx_mesh_arr++) Draw_Mesh(pNode->mMeshes[idx_mesh_arr]); @@ -473,13 +519,21 @@ void CGLView::Draw_Mesh(const size_t pMesh_Index) // Vertices array // glEnableClientState(GL_VERTEX_ARRAY); +#if ASSIMP_DOUBLE_PRECISION + glVertexPointer(3, GL_DOUBLE, 0, mesh_cur.mVertices); +#else glVertexPointer(3, GL_FLOAT, 0, mesh_cur.mVertices); +#endif // ASSIMP_DOUBLE_PRECISION if(mesh_cur.HasVertexColors(0)) { glEnable(GL_COLOR_MATERIAL);///TODO: cache glEnableClientState(GL_COLOR_ARRAY); +#if ASSIMP_DOUBLE_PRECISION + glColorPointer(4, GL_DOUBLE, 0, mesh_cur.mColors[0]); +#else glColorPointer(4, GL_FLOAT, 0, mesh_cur.mColors[0]); +#endif // ASSIMP_DOUBLE_PRECISION } // @@ -488,7 +542,11 @@ void CGLView::Draw_Mesh(const size_t pMesh_Index) if(mesh_cur.HasTextureCoords(0)) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); +#if ASSIMP_DOUBLE_PRECISION + glTexCoordPointer(2, GL_DOUBLE, sizeof(aiVector3D), mesh_cur.mTextureCoords[0]); +#else glTexCoordPointer(2, GL_FLOAT, sizeof(aiVector3D), mesh_cur.mTextureCoords[0]); +#endif // ASSIMP_DOUBLE_PRECISION } // @@ -497,7 +555,11 @@ void CGLView::Draw_Mesh(const size_t pMesh_Index) if(mesh_cur.HasNormals()) { glEnableClientState(GL_NORMAL_ARRAY); +#if ASSIMP_DOUBLE_PRECISION + glNormalPointer(GL_DOUBLE, 0, mesh_cur.mNormals); +#else glNormalPointer(GL_FLOAT, 0, mesh_cur.mNormals); +#endif // ASSIMP_DOUBLE_PRECISION } // @@ -530,22 +592,46 @@ void CGLView::Draw_BBox(const SBBox& pBBox) glBindTexture(GL_TEXTURE_1D, 0); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_3D, 0); +#if ASSIMP_QT4_VIEWER qglColor(QColor(Qt::white)); +#else + const QColor c_w(Qt::white); + + glColor3f(c_w.redF(), c_w.greenF(), c_w.blueF()); +#endif // ASSIMP_QT4_VIEWER + glBegin(GL_LINE_STRIP); +# if ASSIMP_DOUBLE_PRECISION + glVertex3dv(&vertex[0][0]), glVertex3dv(&vertex[1][0]), glVertex3dv(&vertex[2][0]), glVertex3dv(&vertex[3][0]), glVertex3dv(&vertex[0][0]);// "Minimum" side. + glVertex3dv(&vertex[4][0]), glVertex3dv(&vertex[5][0]), glVertex3dv(&vertex[6][0]), glVertex3dv(&vertex[7][0]), glVertex3dv(&vertex[4][0]);// Edge and "maximum" side. +# else glVertex3fv(&vertex[0][0]), glVertex3fv(&vertex[1][0]), glVertex3fv(&vertex[2][0]), glVertex3fv(&vertex[3][0]), glVertex3fv(&vertex[0][0]);// "Minimum" side. glVertex3fv(&vertex[4][0]), glVertex3fv(&vertex[5][0]), glVertex3fv(&vertex[6][0]), glVertex3fv(&vertex[7][0]), glVertex3fv(&vertex[4][0]);// Edge and "maximum" side. +# endif // ASSIMP_DOUBLE_PRECISION glEnd(); + glBegin(GL_LINES); +# if ASSIMP_DOUBLE_PRECISION + glVertex3dv(&vertex[1][0]), glVertex3dv(&vertex[5][0]); + glVertex3dv(&vertex[2][0]), glVertex3dv(&vertex[6][0]); + glVertex3dv(&vertex[3][0]), glVertex3dv(&vertex[7][0]); +# else glVertex3fv(&vertex[1][0]), glVertex3fv(&vertex[5][0]); glVertex3fv(&vertex[2][0]), glVertex3fv(&vertex[6][0]); glVertex3fv(&vertex[3][0]), glVertex3fv(&vertex[7][0]); +# endif // ASSIMP_DOUBLE_PRECISION glEnd(); glDisable(GL_COLOR_MATERIAL); if(mLightingEnabled) glEnable(GL_LIGHTING); + } void CGLView::Enable_Textures(const bool pEnable) { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + if(pEnable) { glEnable(GL_TEXTURE_1D); @@ -558,6 +644,10 @@ void CGLView::Enable_Textures(const bool pEnable) glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_3D); } + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } /********************************************************************/ @@ -566,7 +656,13 @@ void CGLView::Enable_Textures(const bool pEnable) void CGLView::initializeGL() { +#if ASSIMP_QT4_VIEWER qglClearColor(Qt::gray); +#else + mGLContext_Current = true; + initializeOpenGLFunctions(); + glClearColor(0.5f, 0.5f, 0.5f, 1.0f); +#endif // ASSIMP_QT4_VIEWER glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); @@ -583,15 +679,25 @@ void CGLView::initializeGL() glCullFace(GL_BACK); glFrontFace(GL_CCW); + +#if !ASSIMP_QT4_VIEWER + mGLContext_Current = false; +#endif // ASSIMP_QT4_VIEWER } void CGLView::resizeGL(int pWidth, int pHeight) { +#if !ASSIMP_QT4_VIEWER + mGLContext_Current = true; +#endif // ASSIMP_QT4_VIEWER mCamera_Viewport_AspectRatio = (GLdouble)pWidth / pHeight; glViewport(0, 0, pWidth, pHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(mCamera_FOVY, mCamera_Viewport_AspectRatio, 1.0, 100000.0);///TODO: znear/zfar depend on scene size. +#if !ASSIMP_QT4_VIEWER + mGLContext_Current = false; +#endif // ASSIMP_QT4_VIEWER } void CGLView::drawCoordSystem() { @@ -604,7 +710,8 @@ void CGLView::drawCoordSystem() { glBindTexture(GL_TEXTURE_3D, 0); glEnable(GL_COLOR_MATERIAL); glBegin(GL_LINES); - // X, -X +#if ASSIMP_QT4_VIEWER + // X, -X qglColor(QColor(Qt::red)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(100000.0, 0.0, 0.0); qglColor(QColor(Qt::cyan)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(-100000.0, 0.0, 0.0); // Y, -Y @@ -614,14 +721,31 @@ void CGLView::drawCoordSystem() { qglColor(QColor(Qt::blue)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, 100000.0); qglColor(QColor(Qt::yellow)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, -100000.0); qglColor(QColor(Qt::white)); - glEnd(); +#else + // X, -X + glColor3f(1.0f, 0.0f, 0.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(100000.0, 0.0, 0.0); + glColor3f(0.5f, 0.5f, 1.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(-100000.0, 0.0, 0.0); + // Y, -Y + glColor3f(0.0f, 1.0f, 0.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 100000.0, 0.0); + glColor3f(1.0f, 0.0f, 1.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, -100000.0, 0.0); + // Z, -Z + glColor3f(0.0f, 0.0f, 1.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, 100000.0); + glColor3f(1.0f, 1.0f, 0.0f), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, -100000.0); + glColor3f(1.0f, 1.0f, 1.0f); +#endif // ASSIMP_QT4_VIEWER + glEnd(); // Restore previous state of lighting. if(mLightingEnabled) glEnable(GL_LIGHTING); + } void CGLView::paintGL() { - QTime time_paintbegin; +#if !ASSIMP_QT4_VIEWER + mGLContext_Current = true; +#endif // ASSIMP_QT4_VIEWER + + QTime time_paintbegin; time_paintbegin = QTime::currentTime(); @@ -629,9 +753,16 @@ void CGLView::paintGL() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply current camera transformations. +#if ASSIMP_DOUBLE_PRECISION + glMultMatrixd((GLdouble*)&mHelper_Camera.Rotation_AroundCamera); + glTranslated(-mHelper_Camera.Translation_ToScene.x, -mHelper_Camera.Translation_ToScene.y, -mHelper_Camera.Translation_ToScene.z); + glMultMatrixd((GLdouble*)&mHelper_Camera.Rotation_Scene); +#else glMultMatrixf((GLfloat*)&mHelper_Camera.Rotation_AroundCamera); glTranslatef(-mHelper_Camera.Translation_ToScene.x, -mHelper_Camera.Translation_ToScene.y, -mHelper_Camera.Translation_ToScene.z); glMultMatrixf((GLfloat*)&mHelper_Camera.Rotation_Scene); +#endif // ASSIMP_DOUBLE_PRECISION + // Coordinate system if (mScene_AxesEnabled == true) { @@ -645,9 +776,13 @@ void CGLView::paintGL() Draw_Node(mScene->mRootNode); // Scene BBox if(mScene_DrawBBox) Draw_BBox(mScene_BBox); + } emit Paint_Finished((size_t)time_paintbegin.msecsTo(QTime::currentTime()), mHelper_Camera.Translation_ToScene.Length()); +#if !ASSIMP_QT4_VIEWER + mGLContext_Current = false; +#endif // ASSIMP_QT4_VIEWER } /********************************************************************/ @@ -655,10 +790,12 @@ void CGLView::paintGL() /********************************************************************/ CGLView::CGLView(QWidget *pParent) +#if ASSIMP_QT4_VIEWER : QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer), pParent) +#else + : QOpenGLWidget(pParent), mGLContext_Current(false) +#endif // ASSIMP_QT4_VIEWER { - static_assert(sizeof(GLfloat) == sizeof(ai_real), "ai_real in Assimp must be equal to GLfloat/float.");///TODO: may be templates can be used. - // set initial view mHelper_CameraDefault.SetDefault(); Camera_Set(0); @@ -675,6 +812,10 @@ CGLView::~CGLView() void CGLView::FreeScene() { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + // Set scene to null and after that \ref paintGL will not try to render it. mScene = nullptr; // Clean helper objects. @@ -704,10 +845,18 @@ void CGLView::FreeScene() mTexture_IDMap.clear(); delete [] id_tex; } + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } void CGLView::SetScene(const aiScene *pScene, const QString& pScenePath) { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + FreeScene();// Clear old data // Why checking here, not at begin of function. Because old scene may not exist at know. So, need cleanup. if(pScene == nullptr) return; @@ -934,6 +1083,10 @@ void CGLView::SetScene(const aiScene *pScene, const QString& pScenePath) emit SceneObject_Camera(mScene->mCameras[idx_cam]->mName.C_Str()); } }// if(!mScene->HasCameras()) else + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } /********************************************************************/ @@ -942,39 +1095,65 @@ void CGLView::SetScene(const aiScene *pScene, const QString& pScenePath) void CGLView::Lighting_Enable() { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + mLightingEnabled = true; glEnable(GL_LIGHTING); + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } void CGLView::Lighting_Disable() { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + glDisable(GL_LIGHTING); mLightingEnabled = false; + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } void CGLView::Lighting_EditSource(const size_t pLightNumber, const SLightParameters& pLightParameters) { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + const size_t light_num = GL_LIGHT0 + pLightNumber; GLfloat farr[4]; if(pLightNumber >= GL_MAX_LIGHTS) return;///TODO: return value; - glLightfv(light_num, GL_AMBIENT, &pLightParameters.Ambient.r);// Ambient color - glLightfv(light_num, GL_DIFFUSE, &pLightParameters.Diffuse.r);// Diffuse color - glLightfv(light_num, GL_SPECULAR, &pLightParameters.Specular.r);// Specular color + // Ambient color + farr[0] = pLightParameters.Ambient.r, farr[1] = pLightParameters.Ambient.g; farr[2] = pLightParameters.Ambient.b; farr[3] = pLightParameters.Ambient.a; + glLightfv(light_num, GL_AMBIENT, farr); + // Diffuse color + farr[0] = pLightParameters.Diffuse.r, farr[1] = pLightParameters.Diffuse.g; farr[2] = pLightParameters.Diffuse.b; farr[3] = pLightParameters.Diffuse.a; + glLightfv(light_num, GL_DIFFUSE, farr); + // Specular color + farr[0] = pLightParameters.Specular.r, farr[1] = pLightParameters.Specular.g; farr[2] = pLightParameters.Specular.b; farr[3] = pLightParameters.Specular.a; + glLightfv(light_num, GL_SPECULAR, farr); // Other parameters switch(pLightParameters.Type) { case aiLightSource_DIRECTIONAL: // Direction - farr[0] = pLightParameters.For.Directional.Direction.x, farr[2] = pLightParameters.For.Directional.Direction.y; + farr[0] = pLightParameters.For.Directional.Direction.x, farr[1] = pLightParameters.For.Directional.Direction.y; farr[2] = pLightParameters.For.Directional.Direction.z; farr[3] = 0; glLightfv(light_num, GL_POSITION, farr); break; case aiLightSource_POINT: // Position - farr[0] = pLightParameters.For.Point.Position.x, farr[2] = pLightParameters.For.Point.Position.y; + farr[0] = pLightParameters.For.Point.Position.x, farr[1] = pLightParameters.For.Point.Position.y; farr[2] = pLightParameters.For.Point.Position.z; farr[3] = 1; glLightfv(light_num, GL_POSITION, farr); // Attenuation @@ -985,20 +1164,20 @@ GLfloat farr[4]; break; case aiLightSource_SPOT: // Position - farr[0] = pLightParameters.For.Spot.Position.x, farr[2] = pLightParameters.For.Spot.Position.y, farr[2] = pLightParameters.For.Spot.Position.z; farr[3] = 1; + farr[0] = pLightParameters.For.Spot.Position.x, farr[1] = pLightParameters.For.Spot.Position.y, farr[2] = pLightParameters.For.Spot.Position.z; farr[3] = 1; glLightfv(light_num, GL_POSITION, farr); // Attenuation glLightf(light_num, GL_CONSTANT_ATTENUATION, pLightParameters.For.Spot.Attenuation_Constant); glLightf(light_num, GL_LINEAR_ATTENUATION, pLightParameters.For.Spot.Attenuation_Linear); glLightf(light_num, GL_QUADRATIC_ATTENUATION, pLightParameters.For.Spot.Attenuation_Quadratic); // Spot specific - farr[0] = pLightParameters.For.Spot.Direction.x, farr[2] = pLightParameters.For.Spot.Direction.y, farr[2] = pLightParameters.For.Spot.Direction.z; farr[3] = 0; + farr[0] = pLightParameters.For.Spot.Direction.x, farr[1] = pLightParameters.For.Spot.Direction.y, farr[2] = pLightParameters.For.Spot.Direction.z; farr[3] = 0; glLightfv(light_num, GL_SPOT_DIRECTION, farr); glLightf(light_num, GL_SPOT_CUTOFF, pLightParameters.For.Spot.CutOff); break; default:// For unknown light source types use point source. // Position - farr[0] = pLightParameters.For.Point.Position.x, farr[2] = pLightParameters.For.Point.Position.y; + farr[0] = pLightParameters.For.Point.Position.x, farr[1] = pLightParameters.For.Point.Position.y; farr[2] = pLightParameters.For.Point.Position.z; farr[3] = 1; glLightfv(light_num, GL_POSITION, farr); // Attenuation @@ -1008,20 +1187,40 @@ GLfloat farr[4]; glLightf(light_num, GL_SPOT_CUTOFF, 180.0); break; }// switch(pLightParameters.Type) + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } void CGLView::Lighting_EnableSource(const size_t pLightNumber) { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + if(pLightNumber >= GL_MAX_LIGHTS) return;///TODO: return value; glEnable(GL_LIGHT0 + pLightNumber); + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } void CGLView::Lighting_DisableSource(const size_t pLightNumber) { +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_Begin; +#endif // ASSIMP_QT4_VIEWER + if(pLightNumber >= GL_MAX_LIGHTS) return;///TODO: return value; glDisable(GL_LIGHT0 + pLightNumber); + +#if !ASSIMP_QT4_VIEWER + ConditionalContextControl_End; +#endif // ASSIMP_QT4_VIEWER } /********************************************************************/ diff --git a/tools/assimp_qt_viewer/glview.hpp b/tools/assimp_qt_viewer/glview.hpp index 2d8614e21..6068e1448 100644 --- a/tools/assimp_qt_viewer/glview.hpp +++ b/tools/assimp_qt_viewer/glview.hpp @@ -6,14 +6,24 @@ #pragma once // Header files, Qt. -#include +#include +#if ASSIMP_QT4_VIEWER +# include +#else +# include +# include +#endif // ASSIMP_QT4_VIEWER // Header files Assimp #include /// \class CGLView /// Class which hold and render scene. +#if ASSIMP_QT4_VIEWER class CGLView : public QGLWidget +#else +class CGLView : public QOpenGLWidget, protected QOpenGLFunctions +#endif // ASSIMP_QT4_VIEWER { Q_OBJECT @@ -139,6 +149,10 @@ public: private: +#if !ASSIMP_QT4_VIEWER + // Qt5 widget has another behavior, so you must to know that you already made context are current. Yes, its a dirty hack. Better decision are welcome. + bool mGLContext_Current;///< Widget's GL-context made current. +#endif // ASSIMP_QT4_VIEWER // Scene const aiScene* mScene = nullptr;///< Copy of pointer to scene (\ref aiScene). SBBox mScene_BBox;///< Bounding box of scene. diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index c17188472..85a70ba6b 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -84,7 +84,11 @@ QTime time_begin = QTime::currentTime(); mGLView->Camera_Set(0); // Scene is loaded, do first rendering. LogInfo("Scene is ready for rendering."); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } else { @@ -173,7 +177,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent* pEvent) else mGLView->Camera_RotateScene(dy, dx, 0, &mMouse_Transformation.Rotation_Scene);// Rotate around oX and oY axises. + #if ASSIMP_QT4_VIEWER mGLView->updateGL(); + #else + mGLView->update(); + #endif // ASSIMP_QT4_VIEWER } if(pEvent->buttons() & Qt::RightButton) @@ -186,7 +194,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent* pEvent) else mGLView->Camera_Rotate(dy, dx, 0, &mMouse_Transformation.Rotation_AroundCamera);// Rotate around oX and oY axises. + #if ASSIMP_QT4_VIEWER mGLView->updateGL(); + #else + mGLView->update(); + #endif // ASSIMP_QT4_VIEWER } } } @@ -215,7 +227,11 @@ GLfloat step; else if(pEvent->key() == Qt::Key_Down) mGLView->Camera_Translate(0, 0, step); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } /********************************************************************/ @@ -303,7 +319,6 @@ QString filename, filter; if(!filename.isEmpty()) ImportFile(filename); } - void MainWindow::on_butExport_clicked() { using namespace Assimp; @@ -367,7 +382,11 @@ void MainWindow::on_cbxLighting_clicked(bool pChecked) else mGLView->Lighting_Disable(); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } void MainWindow::on_lstLight_itemSelectionChanged() @@ -379,29 +398,49 @@ bool selected = ui->lstLight->isItemSelected(ui->lstLight->currentItem()); else mGLView->Lighting_DisableSource(ui->lstLight->currentRow()); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } void MainWindow::on_lstCamera_clicked( const QModelIndex &) { mGLView->Camera_Set(ui->lstLight->currentRow()); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } void MainWindow::on_cbxBBox_clicked(bool checked) { mGLView->Enable_SceneBBox(checked); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } void MainWindow::on_cbxDrawAxes_clicked(bool checked) { mGLView->Enable_Axes(checked); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } void MainWindow::on_cbxTextures_clicked(bool checked) { mGLView->Enable_Textures(checked); +#if ASSIMP_QT4_VIEWER mGLView->updateGL(); +#else + mGLView->update(); +#endif // ASSIMP_QT4_VIEWER } diff --git a/tools/assimp_qt_viewer/mainwindow.hpp b/tools/assimp_qt_viewer/mainwindow.hpp index 2eedf18f2..e0d17181d 100644 --- a/tools/assimp_qt_viewer/mainwindow.hpp +++ b/tools/assimp_qt_viewer/mainwindow.hpp @@ -6,7 +6,11 @@ #pragma once // Header files, Qt. -#include +#if ASSIMP_QT4_VIEWER +# include +#else +# include +#endif // Header files, project. #include "glview.hpp" From 02d2b6e0d8e5dfd43e310fe1774eff4e6a522c0f Mon Sep 17 00:00:00 2001 From: smalcom Date: Fri, 25 May 2018 21:30:59 +0300 Subject: [PATCH 052/214] [F] Get return "like true" when error occured. --- code/glTF2Exporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 9e8dfc822..1001a2d94 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -514,9 +514,9 @@ void glTF2Exporter::ExportMaterials() GetMatColor(mat, pbrSG.specularFactor, AI_MATKEY_COLOR_SPECULAR); if (mat->Get(AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR, pbrSG.glossinessFactor) != AI_SUCCESS) { - float shininess; + float shininess; - if (mat->Get(AI_MATKEY_SHININESS, shininess)) { + if (mat->Get(AI_MATKEY_SHININESS, shininess) == AI_SUCCESS) { pbrSG.glossinessFactor = shininess / 1000; } } From f29af1abc08b2e3d08efa3808f6458bed39e4150 Mon Sep 17 00:00:00 2001 From: smalcom Date: Fri, 25 May 2018 21:31:22 +0300 Subject: [PATCH 053/214] [-] Trace print removed. --- tools/assimp_qt_viewer/glview.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tools/assimp_qt_viewer/glview.cpp b/tools/assimp_qt_viewer/glview.cpp index c67420c06..85dbbbae1 100644 --- a/tools/assimp_qt_viewer/glview.cpp +++ b/tools/assimp_qt_viewer/glview.cpp @@ -440,7 +440,6 @@ void CGLView::BBox_GetFromVertices(const aiVector3D* pVertices, const size_t pVe const ai_real y = pVertices[idx_vert].y; const ai_real z = pVertices[idx_vert].z; - printf("vert[%lu]=%g,%g,%g\r\n", idx_vert, x, y, z);///TODO: dbg // search minimal... AssignIfLesser(&pBBox.Minimum.x, x); AssignIfLesser(&pBBox.Minimum.y, y); @@ -470,22 +469,12 @@ void CGLView::LogError(const QString& pMessage) /************************** Draw functions **************************/ /********************************************************************/ -static void print_matrix(const aiMatrix4x4 pMatrix)///TODO: dbg -{ - printf("Matrix:\r\n"); - printf("\t%g,%g,%g%g\r\n", pMatrix.a1, pMatrix.a2, pMatrix.a3, pMatrix.a4); - printf("\t%g,%g,%g%g\r\n", pMatrix.b1, pMatrix.b2, pMatrix.b3, pMatrix.b4); - printf("\t%g,%g,%g%g\r\n", pMatrix.c1, pMatrix.c2, pMatrix.c3, pMatrix.c4); - printf("\t%g,%g,%g%g\r\n", pMatrix.d1, pMatrix.d2, pMatrix.d3, pMatrix.d4); -} - void CGLView::Draw_Node(const aiNode* pNode) { aiMatrix4x4 mat_node = pNode->mTransformation; // Apply node transformation matrix. mat_node.Transpose(); - print_matrix(mat_node); glPushMatrix(); #if ASSIMP_DOUBLE_PRECISION glMultMatrixd((GLdouble*)mat_node[0]); From aa18e8a2a5bb85597814084978b8293e651de83d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 25 May 2018 21:43:39 +0200 Subject: [PATCH 054/214] Update Importer.cpp Make check more expressive. --- code/Importer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/Importer.cpp b/code/Importer.cpp index 347ce12d2..c258f0519 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -971,8 +971,7 @@ void Importer::GetExtensionList(aiString& szOut) const } // List can be empty - if(str.size() > 0) - { + if( !str.empty() ) { for (std::set::const_iterator it = str.begin();; ) { szOut.Append("*."); szOut.Append((*it).c_str()); From 323d59c7aafe4ef2a4492dc98306ee56d5b1fc46 Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Mon, 28 May 2018 16:12:54 +0300 Subject: [PATCH 055/214] 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 056/214] 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 057/214] [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 058/214] [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 059/214] 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 060/214] 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 061/214] 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 062/214] 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 063/214] 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 064/214] 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 065/214] 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 066/214] 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 067/214] 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 068/214] 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 069/214] 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 070/214] 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 071/214] 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 072/214] 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 073/214] 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 074/214] 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 075/214] 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 076/214] 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 077/214] 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 078/214] 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 079/214] 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 080/214] 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 081/214] 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 082/214] 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 083/214] 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 084/214] 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 085/214] 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 086/214] 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 087/214] 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