Browse Source

Merge branch 'master' into user/jakras/bitangent-fuzzer-fix

Kim Kulling 3 years ago
parent
commit
ae9f5b6fc5

+ 0 - 6
CMakeLists.txt

@@ -164,12 +164,6 @@ IF (WIN32)
           $<$<CONFIG:Debug>:/MTd>
           $<$<CONFIG:Release>:/MT>
       )
-    else()
-      add_compile_options(
-          $<$<CONFIG:>:/MD>
-          $<$<CONFIG:Debug>:/MDd>
-          $<$<CONFIG:Release>:/MD>
-      )
     endif()
   ENDIF()
 ENDIF()

+ 3 - 0
code/AssetLib/FBX/FBXConverter.cpp

@@ -2161,6 +2161,9 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
     const float ShininessExponent = PropertyGet<float>(props, "ShininessExponent", ok);
     if (ok) {
         out_mat->AddProperty(&ShininessExponent, 1, AI_MATKEY_SHININESS);
+         // Match Blender behavior to extract roughness when only shininess is present
+        const float roughness = 1.0 - (sqrt(ShininessExponent) / 10.0);
+        out_mat->AddProperty(&roughness, 1, AI_MATKEY_ROUGHNESS_FACTOR);
     }
 
     // TransparentColor / TransparencyFactor... gee thanks FBX :rolleyes:

+ 1 - 1
code/AssetLib/IFC/IFCOpenings.cpp

@@ -1476,7 +1476,7 @@ std::vector<IfcVector2> GetContourInPlane2D(std::shared_ptr<TempMesh> mesh,IfcMa
     return contour;
 }
 
-const float close{ ai_epsilon };
+const ai_real close{ ai_epsilon };
 
 static bool isClose(IfcVector2 first,IfcVector2 second) {
     auto diff = (second - first);

+ 1 - 1
code/AssetLib/Obj/ObjFileParser.cpp

@@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace Assimp {
 
-constexpr char ObjFileParser::DEFAULT_MATERIAL[];
+constexpr const char ObjFileParser::DEFAULT_MATERIAL[];
 
 ObjFileParser::ObjFileParser() :
         m_DataIt(),

+ 1 - 1
code/AssetLib/Obj/ObjFileParser.h

@@ -141,7 +141,7 @@ private:
     // because the class contains pointer to allocated memory
 
     /// Default material name
-    static constexpr char DEFAULT_MATERIAL[] = AI_DEFAULT_MATERIAL_NAME;
+    static constexpr const char DEFAULT_MATERIAL[] = AI_DEFAULT_MATERIAL_NAME;
     //! Iterator to current position in buffer
     DataArrayIt m_DataIt;
     //! Iterator to end position of buffer

+ 1 - 1
code/AssetLib/glTF/glTFAsset.inl

@@ -53,9 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endif
 
 using namespace Assimp;
-using namespace glTFCommon;
 
 namespace glTF {
+using namespace glTFCommon;
 
 #if _MSC_VER
 #pragma warning(push)

+ 13 - 1
code/AssetLib/glTF2/glTF2Asset.inl

@@ -82,9 +82,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // clang-format on
 
 using namespace Assimp;
-using namespace glTFCommon;
 
 namespace glTF2 {
+using glTFCommon::FindStringInContext;
+using glTFCommon::FindNumberInContext;
+using glTFCommon::FindUIntInContext;
+using glTFCommon::FindArrayInContext;
+using glTFCommon::FindObjectInContext;
+using glTFCommon::FindExtensionInContext;
+using glTFCommon::MemberOrDefault;
+using glTFCommon::ReadMember;
+using glTFCommon::FindMember;
+using glTFCommon::FindObject;
+using glTFCommon::FindUInt;
+using glTFCommon::FindArray;
+using glTFCommon::FindArray;
 
 namespace {
 

+ 16 - 16
include/assimp/Bitmap.h

@@ -78,11 +78,11 @@ protected:
 
         // We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
         static constexpr std::size_t header_size =
-            sizeof(type) +
-            sizeof(size) +
-            sizeof(reserved1) +
-            sizeof(reserved2) +
-            sizeof(offset);
+            sizeof(uint16_t) +
+            sizeof(uint32_t) +
+            sizeof(uint16_t) +
+            sizeof(uint16_t) +
+            sizeof(uint32_t);
     };
 
     struct DIB {
@@ -100,17 +100,17 @@ protected:
 
         // We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
         static constexpr std::size_t dib_size =
-            sizeof(size) +
-            sizeof(width) +
-            sizeof(height) +
-            sizeof(planes) +
-            sizeof(bits_per_pixel) +
-            sizeof(compression) +
-            sizeof(image_size) +
-            sizeof(x_resolution) +
-            sizeof(y_resolution) +
-            sizeof(nb_colors) +
-            sizeof(nb_important_colors);
+            sizeof(uint32_t) +
+            sizeof(int32_t) +
+            sizeof(int32_t) +
+            sizeof(uint16_t) +
+            sizeof(uint16_t) +
+            sizeof(uint32_t) +
+            sizeof(uint32_t) +
+            sizeof(int32_t) +
+            sizeof(int32_t) +
+            sizeof(uint32_t) +
+            sizeof(uint32_t);
     };
 
     static constexpr std::size_t mBytesPerPixel = 4;

+ 1 - 1
include/assimp/material.inl

@@ -157,7 +157,7 @@ AI_FORCE_INLINE
         case aiPTI_Float:
         case aiPTI_Double: {
             // Read as float and cast to bool
-            float value = 0.0f;
+            ai_real value = 0.0f;
             if (AI_SUCCESS == ::aiGetMaterialFloat(this, pKey, type, idx, &value)) {
                 pOut = static_cast<bool>(value);
                 return AI_SUCCESS;

+ 1 - 0
scripts/android_crosscompile/.gitignore

@@ -0,0 +1 @@
+output

+ 65 - 17
scripts/android_crosscompile/make_android.bat

@@ -1,28 +1,76 @@
 @echo off
 
-set ASSIMP_PATH=D:\projects\asset-importer-lib\assimp
-set CMAKE_PATH="C:\Program Files\CMake\bin\cmake.exe"
-set ANDROID_NDK_PATH=C:\Users\kimkulling\AppData\Local\Android\Sdk\ndk-bundle
-set ANDROID_CMAKE_PATH=contrib\android-cmake
+set ANDROID_PLATFORM=21
+set /p ANDROID_PLATFORM="Enter Android platform - Enter to use %ANDROID_PLATFORM%: "
 
-pushd %ASSIMP_PATH%
+set ANDROID_ABI=armeabi-v7a
+set /p ANDROID_ABI="Enter Android ABI ( armeabi-v7a, arm64-v8a , x86 , x86_64 ) - Enter to use %ANDROID_ABI% : "
 
-rmdir /s /q build
-mkdir build
-cd build
+set COMMON_CXX_FLAGS=-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++
+set COMMON_C_FLAGS=-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions
 
-%CMAKE_PATH% .. ^
-  -G"MinGW Makefiles" ^
+if %ANDROID_ABI% == armeabi-v7a (
+  set CXX_FLAGS="%COMMON_CXX_FLAGS% -march=armv7-a -mthumb --target=armv7-none-linux-androideabi%ANDROID_PLATFORM%"
+  set C_FLAGS="%COMMON_C_FLAGS% -march=armv7-a -mthumb --target=armv7-none-linux-androideabi%ANDROID_PLATFORM%"
+)
+if %ANDROID_ABI% == arm64-v8a (
+  set CXX_FLAGS="%COMMON_CXX_FLAGS% -march=armv8-a --target=aarch64-none-linux-android%ANDROID_PLATFORM%"
+  set C_FLAGS="%COMMON_C_FLAGS% -march=armv8-a --target=aarch64-none-linux-android%ANDROID_PLATFORM%"
+)
+if %ANDROID_ABI% == x86 (
+  set CXX_FLAGS="%COMMON_CXX_FLAGS% --target=i686-none-linux-android%ANDROID_PLATFORM%"
+  set C_FLAGS="%COMMON_C_FLAGS% --target=i686-none-linux-android%ANDROID_PLATFORM%"
+)
+if %ANDROID_ABI% == x86_64 (
+  set CXX_FLAGS="%COMMON_CXX_FLAGS%"
+  set C_FLAGS="%COMMON_C_FLAGS%"
+)
+
+set CMAKE_PATH="%ProgramFiles%\CMake\bin\cmake.exe"
+if exist %CMAKE_PATH% (
+    echo Found cmake at %CMAKE_PATH%
+) else (
+  set /p CMAKE_PATH="Enter cmake.exe path: "
+)
+
+set ANDROID_NDK_PATH=""
+FOR /F "tokens=* USEBACKQ" %%F IN (`dir "%LocalAppData%\Android\Sdk\ndk" /b /o:n /a:d`) DO (
+  SET ANDROID_NDK_PATH="%LocalAppData%\Android\Sdk\ndk\%%F"
+)
+if exist %ANDROID_NDK_PATH% (
+  echo Found NDK at %ANDROID_NDK_PATH%
+) else (
+  set /p ANDROID_NDK_PATH="Enter ndk path: "
+)
+
+set BUILD_FOLDER=build
+rmdir /s /q %BUILD_FOLDER%
+mkdir %BUILD_FOLDER%
+
+%CMAKE_PATH% ^
+  -G"Unix Makefiles" ^
   -DCMAKE_BUILD_TYPE=Release ^
-  -DCMAKE_TOOLCHAIN_FILE=%ANDROID_CMAKE_PATH%\android.toolchain.cmake ^
+  -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_PATH%\build\cmake\android.toolchain.cmake ^
   -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK_PATH%\prebuilt\windows-x86_64\bin\make.exe ^
   -DANDROID_NDK=%ANDROID_NDK_PATH% ^
-  -DANDROID_NATIVE_API_LEVEL=android-9 ^
+  -DOPERATING_SYSTEM="Android" ^
+  -DANDROID_PLATFORM=%ANDROID_PLATFORM% ^
+  -DANDROID_ABI=%ANDROID_ABI% ^
   -DASSIMP_ANDROID_JNIIOSYSTEM=ON ^
-  -DANDROID_ABI=arm64-v8a ^
-  -DASSIMP_BUILD_ZLIB=ON ^
-  -DASSIMP_BUILD_TESTS=OFF
+  -DASSIMP_BUILD_TESTS=OFF ^
+  -DCMAKE_CXX_FLAGS=%CXX_FLAGS% ^
+  -DMAKE_C_FLAGS=%C_FLAGS% ^
+  -S "..\.." ^
+  -B ".\%BUILD_FOLDER%\"
+
+%CMAKE_PATH% --build ".\%BUILD_FOLDER%\"" -- -j 4"
+
+set OUTPUT_FOLDER=.\output\
+mkdir %OUTPUT_FOLDER%
+mkdir "%OUTPUT_FOLDER%\lib\%ANDROID_ABI%"
 
-%CMAKE_PATH% --build .
+copy "%BUILD_FOLDER%\bin\libassimp.so" "%OUTPUT_FOLDER%\lib\%ANDROID_ABI%\"
+xcopy %BUILD_FOLDER%\include\assimp\ %OUTPUT_FOLDER%\include\assimp\ /y /s /e
+xcopy ..\..\include\assimp\ %OUTPUT_FOLDER%\include\assimp\ /y /s /e
 
-popd
+rmdir /s /q %BUILD_FOLDER%