[neon/backports-focal/assimp/Neon/release] /: New upstream version 5.1.5~ds0

IOhannes m zmölnig (Debian/GNU) null at kde.org
Wed Jan 26 13:21:02 GMT 2022


Git commit 1a5a524bdbca0cebbbe183a82681b42d6513aea0 by IOhannes m zmölnig (Debian/GNU).
Committed on 09/01/2022 at 21:28.
Pushed by jriddell into branch 'Neon/release'.

New upstream version 5.1.5~ds0

M  +2    -2    CMakeLists.txt
M  +5    -2    code/AssetLib/Blender/BlenderScene.cpp
M  +1    -0    code/AssetLib/FBX/FBXConverter.cpp
M  +5    -0    code/AssetLib/LWS/LWSLoader.cpp
M  +6    -2    code/AssetLib/MDL/MDLMaterialLoader.cpp
M  +28   -1    code/AssetLib/Obj/ObjFileData.h
M  +39   -0    code/AssetLib/Obj/ObjFileImporter.cpp
M  +61   -0    code/AssetLib/Obj/ObjFileMtlImporter.cpp
M  +2    -2    code/CMakeLists.txt
M  +5    -1    code/Common/BaseImporter.cpp
M  +9    -8    code/Common/DefaultProgressHandler.h
M  +1    -1    code/Common/Importer.cpp
M  +1    -0    contrib/android-cmake/android.toolchain.cmake
M  +1    -0    include/assimp/ProgressHandler.hpp
M  +3    -0    include/assimp/material.h
M  +27   -4    tools/assimp_cmd/Main.cpp

https://invent.kde.org/neon/backports-focal/assimp/commit/1a5a524bdbca0cebbbe183a82681b42d6513aea0

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 570c293..13b2ef9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -246,7 +246,7 @@ IF( UNIX )
 ENDIF()
 
 # Grouped compiler settings ########################################
-IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
+IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
   IF(NOT ASSIMP_HUNTER_ENABLED)
     SET(CMAKE_CXX_STANDARD 11)
     SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -283,7 +283,7 @@ ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
   ENDIF()
   SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
   SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
-ELSEIF( CMAKE_COMPILER_IS_MINGW )
+ELSEIF( MINGW )
   IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
     message(FATAL_ERROR "MinGW is too old to be supported. Please update MinGW and try again.")
   ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp
index c93d913..9ad086f 100644
--- a/code/AssetLib/Blender/BlenderScene.cpp
+++ b/code/AssetLib/Blender/BlenderScene.cpp
@@ -49,8 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "BlenderDNA.h"
 #include "BlenderSceneGen.h"
 
-using namespace Assimp;
-using namespace Assimp::Blender;
+namespace Assimp {
+namespace Blender {
 
 //--------------------------------------------------------------------------------
 template <>
@@ -885,4 +885,7 @@ void DNA::RegisterConverters() {
     converters["CollectionObject"] = DNA::FactoryPair(&Structure::Allocate<CollectionObject>, &Structure::Convert<CollectionObject>);
 }
 
+} // namespace Blender
+} //namespace Assimp
+
 #endif // ASSIMP_BUILD_NO_BLEND_IMPORTER
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index 5a3ae0a..b1be6ed 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -2070,6 +2070,7 @@ void FBXConverter::SetTextureProperties(aiMaterial *out_mat, const LayeredTextur
     TrySetTextureProperties(out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS, mesh);
     TrySetTextureProperties(out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh);
     TrySetTextureProperties(out_mat, layeredTextures, "TransparencyFactor", aiTextureType_OPACITY, mesh);
+    TrySetTextureProperties(out_mat, layeredTextures, "ReflectionFactor", aiTextureType_METALNESS, mesh);
 }
 
 aiColor3D FBXConverter::GetColorPropertyFactored(const PropertyTable &props, const std::string &colorName,
diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp
index cb07787..cf04579 100644
--- a/code/AssetLib/LWS/LWSLoader.cpp
+++ b/code/AssetLib/LWS/LWSLoader.cpp
@@ -537,6 +537,11 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
 
     // get file format version and print to log
     ++it;
+    
+    if ((*it).tokens[0].empty()) {
+        ASSIMP_LOG_ERROR("Invalid LWS file detectedm abort import.");
+        return;
+    }
     unsigned int version = strtoul10((*it).tokens[0].c_str());
     ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]);
     first = 0.;
diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp
index 6232081..4f441a0 100644
--- a/code/AssetLib/MDL/MDLMaterialLoader.cpp
+++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp
@@ -463,8 +463,12 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
             ASSIMP_LOG_WARN("Found a reference to an embedded DDS texture, "
                             "but texture height is not equal to 1, which is not supported by MED");
         }
-
-        pcNew.reset(new aiTexture());
+        if (iWidth == 0) {
+            ASSIMP_LOG_ERROR("Found a reference to an embedded DDS texture, but texture width is zero, aborting import.");
+            return;
+        }
+        
+        pcNew.reset(new aiTexture);
         pcNew->mHeight = 0;
         pcNew->mWidth = iWidth;
 
diff --git a/code/AssetLib/Obj/ObjFileData.h b/code/AssetLib/Obj/ObjFileData.h
index b142500..bc65058 100644
--- a/code/AssetLib/Obj/ObjFileData.h
+++ b/code/AssetLib/Obj/ObjFileData.h
@@ -133,6 +133,10 @@ struct Material {
     aiString textureSpecularity;
     aiString textureOpacity;
     aiString textureDisp;
+    aiString textureRoughness;
+    aiString textureMetallic;
+    aiString textureSheen;
+    aiString textureRMA;
 
     enum TextureType {
         TextureDiffuseType = 0,
@@ -151,6 +155,10 @@ struct Material {
         TextureSpecularityType,
         TextureOpacityType,
         TextureDispType,
+        TextureRoughnessType,
+        TextureMetallicType,
+        TextureSheenType,
+        TextureRMAType,
         TextureTypeCount
     };
     bool clamp[TextureTypeCount];
@@ -174,6 +182,19 @@ struct Material {
     //! Transparency color
     aiColor3D transparent;
 
+    //! PBR Roughness
+    ai_real roughness;
+    //! PBR Metallic
+    ai_real metallic;
+    //! PBR Metallic
+    aiColor3D sheen;
+    //! PBR Clearcoat Thickness
+    ai_real clearcoat_thickness;
+    //! PBR Clearcoat Rougness
+    ai_real clearcoat_roughness;
+    //! PBR Anisotropy
+    ai_real anisotropy;
+
     //! Constructor
     Material() :
             diffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
@@ -181,7 +202,13 @@ struct Material {
             shineness(ai_real(0.0)),
             illumination_model(1),
             ior(ai_real(1.0)),
-            transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)) {
+            transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)),
+            roughness(ai_real(1.0)),
+            metallic(ai_real(0.0)),
+            sheen(ai_real(1.0), ai_real(1.0), ai_real(1.0)),
+            clearcoat_thickness(ai_real(0.0)),
+            clearcoat_roughness(ai_real(0.0)),
+            anisotropy(ai_real(0.0)) {
         std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
     }
 
diff --git a/code/AssetLib/Obj/ObjFileImporter.cpp b/code/AssetLib/Obj/ObjFileImporter.cpp
index 4e943fb..3e56e31 100644
--- a/code/AssetLib/Obj/ObjFileImporter.cpp
+++ b/code/AssetLib/Obj/ObjFileImporter.cpp
@@ -618,6 +618,12 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
         mat->AddProperty(&pCurrentMaterial->shineness, 1, AI_MATKEY_SHININESS);
         mat->AddProperty(&pCurrentMaterial->alpha, 1, AI_MATKEY_OPACITY);
         mat->AddProperty(&pCurrentMaterial->transparent, 1, AI_MATKEY_COLOR_TRANSPARENT);
+        mat->AddProperty(&pCurrentMaterial->roughness, 1, AI_MATKEY_ROUGHNESS_FACTOR);
+        mat->AddProperty(&pCurrentMaterial->metallic, 1, AI_MATKEY_METALLIC_FACTOR);
+        mat->AddProperty(&pCurrentMaterial->sheen, 1, AI_MATKEY_SHEEN_COLOR_FACTOR);
+        mat->AddProperty(&pCurrentMaterial->clearcoat_thickness, 1, AI_MATKEY_CLEARCOAT_FACTOR);
+        mat->AddProperty(&pCurrentMaterial->clearcoat_roughness, 1, AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR);
+        mat->AddProperty(&pCurrentMaterial->anisotropy, 1, AI_MATKEY_ANISOTROPY_FACTOR);
 
         // Adding refraction index
         mat->AddProperty(&pCurrentMaterial->ior, 1, AI_MATKEY_REFRACTI);
@@ -709,6 +715,39 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
             }
         }
 
+        if (0 != pCurrentMaterial->textureRoughness.length) {
+            mat->AddProperty(&pCurrentMaterial->textureRoughness, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE_ROUGHNESS, 0);
+            mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_DIFFUSE_ROUGHNESS, 0 );
+            if (pCurrentMaterial->clamp[ObjFile::Material::TextureRoughnessType]) {
+                addTextureMappingModeProperty(mat, aiTextureType_DIFFUSE_ROUGHNESS);
+            }
+        }
+
+        if (0 != pCurrentMaterial->textureMetallic.length) {
+            mat->AddProperty(&pCurrentMaterial->textureMetallic, _AI_MATKEY_TEXTURE_BASE, aiTextureType_METALNESS, 0);
+            mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_METALNESS, 0 );
+            if (pCurrentMaterial->clamp[ObjFile::Material::TextureMetallicType]) {
+                addTextureMappingModeProperty(mat, aiTextureType_METALNESS);
+            }
+        }
+
+        if (0 != pCurrentMaterial->textureSheen.length) {
+            mat->AddProperty(&pCurrentMaterial->textureSheen, _AI_MATKEY_TEXTURE_BASE, aiTextureType_SHEEN, 0);
+            mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_SHEEN, 0 );
+            if (pCurrentMaterial->clamp[ObjFile::Material::TextureSheenType]) {
+                addTextureMappingModeProperty(mat, aiTextureType_SHEEN);
+            }
+        }
+
+        if (0 != pCurrentMaterial->textureRMA.length) {
+            // NOTE: glTF importer places Rough/Metal/AO texture in Unknown so doing the same here for consistency.
+            mat->AddProperty(&pCurrentMaterial->textureRMA, _AI_MATKEY_TEXTURE_BASE, aiTextureType_UNKNOWN, 0);
+            mat->AddProperty(&uvwIndex, 1, _AI_MATKEY_UVWSRC_BASE, aiTextureType_UNKNOWN, 0 );
+            if (pCurrentMaterial->clamp[ObjFile::Material::TextureRMAType]) {
+                addTextureMappingModeProperty(mat, aiTextureType_UNKNOWN);
+            }
+        }
+
         // Store material property info in material array in scene
         pScene->mMaterials[pScene->mNumMaterials] = mat;
         pScene->mNumMaterials++;
diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp
index 548401d..7d59305 100644
--- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp
+++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp
@@ -67,6 +67,10 @@ static const std::string ReflectionTexture = "refl";
 static const std::string DisplacementTexture1 = "map_disp";
 static const std::string DisplacementTexture2 = "disp";
 static const std::string SpecularityTexture = "map_ns";
+static const std::string RoughnessTexture = "map_Pr";
+static const std::string MetallicTexture = "map_Pm";
+static const std::string SheenTexture = "map_Ps";
+static const std::string RMATexture = "map_Ps";
 
 // texture option specific token
 static const std::string BlendUOption = "-blendu";
@@ -178,10 +182,45 @@ void ObjFileMtlImporter::load() {
                     case 'e': // New material
                         createMaterial();
                         break;
+                    case 'o': // Norm texture
+                        --m_DataIt;
+                        getTexture();
+                        break;
                 }
                 m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
             } break;
 
+            case 'P':
+                {
+                    ++m_DataIt;
+                    switch(*m_DataIt)
+                    {
+                    case 'r':
+                        ++m_DataIt;
+                        getFloatValue(m_pModel->m_pCurrentMaterial->roughness);
+                        break;
+                    case 'm':
+                        ++m_DataIt;
+                        getFloatValue(m_pModel->m_pCurrentMaterial->metallic);
+                        break;
+                    case 's':
+                        ++m_DataIt;
+                        getColorRGBA(&m_pModel->m_pCurrentMaterial->sheen);
+                        break;
+                    case 'c':
+                        ++m_DataIt;
+                        if (*m_DataIt == 'r') {
+                            ++m_DataIt;
+                            getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_roughness);
+                        } else {
+                            getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_thickness);
+                        }
+                        break;
+                    }
+                    m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
+                }
+                break;
+
             case 'm': // Texture
             case 'b': // quick'n'dirty - for 'bump' sections
             case 'r': // quick'n'dirty - for 'refl' sections
@@ -197,6 +236,12 @@ void ObjFileMtlImporter::load() {
                 m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
             } break;
 
+            case 'a': // Anisotropy
+            {
+                getFloatValue(m_pModel->m_pCurrentMaterial->anisotropy);
+                m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
+            } break;
+
             default: {
                 m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
             } break;
@@ -334,6 +379,22 @@ void ObjFileMtlImporter::getTexture() {
         // Specularity scaling (glossiness)
         out = &m_pModel->m_pCurrentMaterial->textureSpecularity;
         clampIndex = ObjFile::Material::TextureSpecularityType;
+    } else if ( !ASSIMP_strincmp( pPtr, RoughnessTexture.c_str(), static_cast<unsigned int>(RoughnessTexture.size()))) {
+        // PBR Roughness texture
+        out = & m_pModel->m_pCurrentMaterial->textureRoughness;
+        clampIndex = ObjFile::Material::TextureRoughnessType;
+    } else if ( !ASSIMP_strincmp( pPtr, MetallicTexture.c_str(), static_cast<unsigned int>(MetallicTexture.size()))) {
+        // PBR Metallic texture
+        out = & m_pModel->m_pCurrentMaterial->textureMetallic;
+        clampIndex = ObjFile::Material::TextureMetallicType;
+    } else if (!ASSIMP_strincmp( pPtr, SheenTexture.c_str(), static_cast<unsigned int>(SheenTexture.size()))) {
+        // PBR Sheen (reflectance) texture
+        out = & m_pModel->m_pCurrentMaterial->textureSheen;
+        clampIndex = ObjFile::Material::TextureSheenType;
+    } else if (!ASSIMP_strincmp( pPtr, RMATexture.c_str(), static_cast<unsigned int>(RMATexture.size()))) {
+        // PBR Rough/Metal/AO texture
+        out = & m_pModel->m_pCurrentMaterial->textureRMA;
+        clampIndex = ObjFile::Material::TextureRMAType;
     } else {
         ASSIMP_LOG_ERROR("OBJ/MTL: Encountered unknown texture type");
         return;
diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
index 1af9407..08efd28 100644
--- a/code/CMakeLists.txt
+++ b/code/CMakeLists.txt
@@ -557,7 +557,7 @@ ADD_ASSIMP_IMPORTER( IFC
 if (ASSIMP_BUILD_IFC_IMPORTER)
   if (MSVC)
     set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
-  elseif(CMAKE_COMPILER_IS_MINGW)
+  elseif(MINGW)
     set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
   endif()
 endif ()
@@ -862,7 +862,7 @@ ADD_ASSIMP_IMPORTER( MMD
 # optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate
 # Also, I'm not positive if both link & compile flags are needed, but this hopefully ensures that the issue should not
 # recur for edge cases such as static builds.
-if ((CMAKE_COMPILER_IS_MINGW) AND (CMAKE_BUILD_TYPE MATCHES Debug))
+if ((MINGW) AND (CMAKE_BUILD_TYPE MATCHES Debug))
   message("-- Applying MinGW StepFileGen1.cpp Debug Workaround")
   SET_SOURCE_FILES_PROPERTIES(Importer/StepFile/StepFileGen1.cpp PROPERTIES COMPILE_FLAGS -Os )
   SET_SOURCE_FILES_PROPERTIES(Importer/StepFile/StepFileGen1.cpp PROPERTIES LINK_FLAGS -Os )
diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp
index d7e24af..82b8f12 100644
--- a/code/Common/BaseImporter.cpp
+++ b/code/Common/BaseImporter.cpp
@@ -65,6 +65,7 @@ using namespace Assimp;
 // Constructor to be privately used by Importer
 BaseImporter::BaseImporter() AI_NO_EXCEPT
         : m_progress() {
+    // empty
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -372,7 +373,10 @@ void BaseImporter::ConvertToUTF8(std::vector<char> &data) {
 
     // UTF 16 BE with BOM
     if (*((uint16_t *)&data.front()) == 0xFFFE) {
-
+        // Check to ensure no overflow can happen
+        if(data.size() % 2 != 0) {
+            return;
+        }
         // swap the endianness ..
         for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) {
             ByteSwap::Swap2(p);
diff --git a/code/Common/DefaultProgressHandler.h b/code/Common/DefaultProgressHandler.h
index 4626204..ebf4a0e 100644
--- a/code/Common/DefaultProgressHandler.h
+++ b/code/Common/DefaultProgressHandler.h
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2021, assimp team
 
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -48,18 +47,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assimp/ProgressHandler.hpp>
 
-namespace Assimp    {
+namespace Assimp {
 
 // ------------------------------------------------------------------------------------
-/** @brief Internal default implementation of the #ProgressHandler interface. */
+/**
+ *  @brief Internal default implementation of the #ProgressHandler interface.
+ */
 class DefaultProgressHandler : public ProgressHandler    {
-
-    virtual bool Update(float /*percentage*/) {
+public:
+    ///	@brief Ignores the update callback.
+    bool Update(float) override {
         return false;
     }
+};
 
-
-}; // !class DefaultProgressHandler
 } // Namespace Assimp
 
-#endif
+#endif // INCLUDED_AI_DEFAULTPROGRESSHANDLER_H
diff --git a/code/Common/Importer.cpp b/code/Common/Importer.cpp
index 41b73fd..2f9c23b 100644
--- a/code/Common/Importer.cpp
+++ b/code/Common/Importer.cpp
@@ -329,7 +329,7 @@ bool Importer::IsDefaultIOHandler() const {
 
 // ------------------------------------------------------------------------------------------------
 // Supplies a custom progress handler to get regular callbacks during importing
-void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
+void Importer::SetProgressHandler(ProgressHandler* pHandler) {
     ai_assert(nullptr != pimpl);
 
     ASSIMP_BEGIN_EXCEPTION_REGION();
diff --git a/contrib/android-cmake/android.toolchain.cmake b/contrib/android-cmake/android.toolchain.cmake
index ffa2612..c2b8a07 100644
--- a/contrib/android-cmake/android.toolchain.cmake
+++ b/contrib/android-cmake/android.toolchain.cmake
@@ -1616,6 +1616,7 @@ endif()
 if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
  # it is a bad hack after all
  # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW
+ set( MINGW TRUE ) # tell CMake that we are MinGW
  set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW
  set( CMAKE_CROSSCOMPILING TRUE )    # stop recursion
  enable_language( C )
diff --git a/include/assimp/ProgressHandler.hpp b/include/assimp/ProgressHandler.hpp
index a420154..40661fb 100644
--- a/include/assimp/ProgressHandler.hpp
+++ b/include/assimp/ProgressHandler.hpp
@@ -74,6 +74,7 @@ protected:
 public:
     /// @brief  Virtual destructor.
     virtual ~ProgressHandler () {
+        // empty
     }
 
     // -------------------------------------------------------------------
diff --git a/include/assimp/material.h b/include/assimp/material.h
index 4e55e48..4f98b46 100644
--- a/include/assimp/material.h
+++ b/include/assimp/material.h
@@ -989,6 +989,9 @@ extern "C" {
 // Roughness factor. 0.0 = Perfectly Smooth, 1.0 = Completely Rough
 #define AI_MATKEY_ROUGHNESS_FACTOR "$mat.roughnessFactor", 0, 0
 #define AI_MATKEY_ROUGHNESS_TEXTURE aiTextureType_DIFFUSE_ROUGHNESS, 0
+// Anisotropy factor. 0.0 = isotropic, 1.0 = anisotropy along tangent direction,
+// -1.0 = anisotropy along bitangent direction
+#define AI_MATKEY_ANISOTROPY_FACTOR "$mat.anisotropyFactor", 0, 0
 
 // Specular/Glossiness Workflow
 // ---------------------------
diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp
index 8d76e1f..8746757 100644
--- a/tools/assimp_cmd/Main.cpp
+++ b/tools/assimp_cmd/Main.cpp
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2021, assimp team
 
-
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -47,6 +45,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "Main.h"
 
+#include <assimp/ProgressHandler.hpp>
+#include <iostream>
+
+class ConsoleProgressHandler : public ProgressHandler {
+public:
+	ConsoleProgressHandler() :
+			ProgressHandler() {
+		// empty
+	}
+
+	~ConsoleProgressHandler() override {
+		// empty
+	}
+
+	bool Update(float percentage) override {
+        std::cout << percentage * 100.0f << " %\n";
+		return true;
+    }
+};
 const char* AICMD_MSG_ABOUT =
 "------------------------------------------------------ \n"
 "Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
@@ -73,10 +90,10 @@ const char* AICMD_MSG_HELP =
 "\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
 ;
 
-/*extern*/ Assimp::Importer* globalImporter = NULL;
+/*extern*/ Assimp::Importer* globalImporter = nullptr;
 
 #ifndef ASSIMP_BUILD_NO_EXPORT
-/*extern*/ Assimp::Exporter* globalExporter = NULL;
+/*extern*/ Assimp::Exporter* globalExporter = nullptr;
 #endif
 
 // ------------------------------------------------------------------------------
@@ -286,6 +303,9 @@ const aiScene* ImportModel(
 
 	// do the actual import, measure time
 	const clock_t first = clock();
+    ConsoleProgressHandler *ph = new ConsoleProgressHandler;
+    globalImporter->SetProgressHandler(ph);
+    
 	const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
 
 	if (imp.showLog) {
@@ -305,6 +325,9 @@ const aiScene* ImportModel(
 	if (imp.log) {
 		FreeLogStreams();
 	}
+    globalImporter->SetProgressHandler(nullptr);
+    delete ph;
+
 	return scene;
 }
 



More information about the Neon-commits mailing list