Compare commits

..

37 Commits

Author SHA1 Message Date
Kim Kulling
8134cae998 Merge pull request #4333 from assimp/kimkulling-prepare_v5.1.6
Update to 5.1.6
2022-01-09 23:45:44 +01:00
Kim Kulling
30f1583dde Update utVersion.cpp 2022-01-09 21:06:05 +01:00
Kim Kulling
1d8667bfdc Update to 5.1.6 2022-01-09 18:06:33 +01:00
Kim Kulling
cb3e846a19 Merge pull request #4318 from vpzomtrrfrt/fix-bone-fit-check
Fix bone fitted check in gltf2 exporter
2022-01-08 12:59:21 +01:00
Kim Kulling
8cb5ab69b0 Merge branch 'master' into fix-bone-fit-check 2022-01-08 11:35:59 +01:00
Kim Kulling
b40d9abdb9 Merge pull request #4328 from assimp/kimkulling-x3d_fix_nullptr_exception
Fix nullptr-dereferencing
2022-01-08 11:35:45 +01:00
Kim Kulling
776130534b Fix nullptr-dereferencing
- Fix a possible nullptr-exception.
2022-01-06 22:35:32 +01:00
Kim Kulling
6a1f720f68 Merge pull request #4324 from alpire/master
Fix fuzzer crashes
2022-01-06 20:43:38 +01:00
Alex Rebert
b14b34d2b8 LWSLoader: Fix out of bounds iterator access
Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38947
Fix #4222
2022-01-05 15:43:16 -05:00
Alex Rebert
310c81aaa2 Add support for spanned archives
Without it, assimp would crash on some inputs by jumping to a NULL
opendisk function. This commit adds an opendisk implementation, which
required adding a filename member to ZipFile.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38873
Fix #4229
2022-01-05 15:43:10 -05:00
Alex Rebert
34d8fba100 Fix stack overflow in ZipArchiveIOSystem::MapArchive
The function allocates a filename buffer of 256, and copies the filename
extracted from the zip file into it. However, a filename might be larger
than 256 characters, in which case the function would write out of bounds.

This commit skips any file whose name is larger than 256 to avoid the
overflow.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38870
Fix #4228
2022-01-05 10:01:46 -05:00
Kim Kulling
1d815fc23e Merge pull request #4321 from assimp/kimkulling_update_morphing_method_doc_issue4320
Add link to used enum for a better understandability
2022-01-04 17:46:37 +01:00
Kim Kulling
a591944c04 Add link to used enum for a better understandability for the mesh morphing method. 2022-01-04 17:32:18 +01:00
Colin Reeder
87e9dbac40 Fix bone fitted check in gltf2 exporter 2022-01-03 16:32:34 -07:00
Kim Kulling
c2375a4ff0 Merge pull request #4272 from errissa/pbr-obj
Support PBR properties/maps in Obj importer
2021-12-31 10:38:50 +01:00
Kim Kulling
ab19cff328 Merge branch 'master' into pbr-obj 2021-12-31 08:33:30 +01:00
Kim Kulling
049a241855 Merge pull request #4314 from pseiderer/ps-devel-fix-namespace-001
RFC: BlenderScene: use explicit namespace instead of using namespace
2021-12-31 08:32:54 +01:00
Kim Kulling
a86ab45161 Merge branch 'master' into ps-devel-fix-namespace-001 2021-12-31 08:20:24 +01:00
Peter Seiderer
a099fe7cd3 BlenderScene: use explicit namespace instead of using namespace
Fixes (using g++ Sourcery CodeBench Lite 2014.05-29 - 4.8.3 20140320):

  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:101:33: error: specialization of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' in different namespace [-fpermissive]
           const FileDatabase &db) const {
                                   ^
 In file included from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.h:49:0,
                   from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:47:
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderDNA.h:266:10: error:   from definition of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' [-fpermissive]
       void Convert(T &dest, const FileDatabase &db) const;
            ^
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:121:33: error: specialization of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' in different namespace [-fpermissive]
           const FileDatabase &db) const {
                                   ^
  In file included from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.h:49:0,
                   from .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderScene.cpp:47:
  .../build/assimp-5.1.4/code/AssetLib/Blender/BlenderDNA.h:266:10: error:   from definition of 'template<class T> void Assimp::Blender::Structure::Convert(T&, const Assimp::Blender::FileDatabase&) const' [-fpermissive]
       void Convert(T &dest, const FileDatabase &db) const;
            ^

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2021-12-30 18:01:54 +01:00
Kim Kulling
85dd84cc78 Merge pull request #4259 from VyacheslavVanin/fix-fbx-metalness-import
fix fbx import metalness
2021-12-29 20:35:46 +01:00
Kim Kulling
0a5bd792de Merge branch 'master' into fix-fbx-metalness-import 2021-12-29 19:08:16 +01:00
Kim Kulling
c882731688 Merge pull request #4311 from SirLynix/fix-mingw
CMake: Replace CMAKE_COMPILER_IS_MINGW by MINGW
2021-12-29 17:31:12 +01:00
Jérôme Leclercq
81fc50f612 CMake: Replace CMAKE_COMPILER_IS_MINGW by MINGW
See https://discourse.cmake.org/t/cmake-compiler-is-mingw-removed/4539 and https://cmake.org/cmake/help/latest/variable/MINGW.html
2021-12-28 15:58:37 +01:00
Vyacheslav Vanin
2da06dd41a Merge branch 'master' into fix-fbx-metalness-import 2021-12-26 17:31:33 +03:00
Kim Kulling
54a8da1d55 Merge pull request #4293 from assimp/add_colsole_progresshandler_issue_963
Add console progresshandler
2021-12-26 11:38:24 +01:00
Kim Kulling
d44641398f Add console progresshandler 2021-12-26 11:16:02 +01:00
Kim Kulling
4d7e817bd8 Merge pull request #4284 from assimp/kimkulling-skip_empty_embedded_textures_issue4238
MDL: Do not try to copy empty embedded texture
2021-12-23 13:03:43 +01:00
Kim Kulling
db2500c393 MDL: Do not try to copy empty embedded texture
- When an embedded texture is empty, skip it instead of trying to copy it. This must fail.
- closes https://github.com/assimp/assimp/issues/4238
- Found from the Google fuzzer.
2021-12-23 12:28:43 +01:00
Kim Kulling
64af16c427 Merge pull request #4283 from assimp/kimkulling-avoid_invalid_string_access_issue4222
LWS-Import: Avoid access to empty string token
2021-12-22 21:28:42 +01:00
Kim Kulling
635153b3a4 LWS-Import: Avoid access to empty string token
- Fix invalid access to string pointer when string token is empty
- closes https://github.com/assimp/assimp/issues/4222
2021-12-22 21:08:28 +01:00
Kim Kulling
7ec52e9e02 Merge pull request #4282 from assimp/kimkulling-fix_heap_overflow_during_utf8_issue4230
Make sure no overflow can happen
2021-12-22 20:56:39 +01:00
Kim Kulling
2c66d4d3a2 Optimize the check 2021-12-22 20:43:44 +01:00
Kim Kulling
215f4e1f4d Fix typo 2021-12-22 20:02:29 +01:00
Kim Kulling
2eb86d75b8 Make sure no overflow can happen
- During UTF32 LE with BOM make sure that the byteswap operation will have enough space when iterating through the text buffer, which shall get encoded.
- closes https://github.com/assimp/assimp/issues/4230
2021-12-22 19:45:19 +01:00
Rene Sepulveda
19371af6e6 Support PBR properties/maps in Obj importer 2021-12-20 13:43:46 -05:00
Vyacheslav Vanin
53968550e4 Merge branch 'master' into fix-fbx-metalness-import 2021-12-17 12:08:55 +03:00
Vyacheslav.Vanin
1afe7e6255 fix fbx import metalness
Can't import metalness textures in fbx importer
2021-12-16 12:09:06 +03:00
21 changed files with 265 additions and 60 deletions

View File

@@ -56,7 +56,7 @@ IF(ASSIMP_HUNTER_ENABLED)
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF()
PROJECT(Assimp VERSION 5.1.4)
PROJECT(Assimp VERSION 5.1.6)
# All supported options ###############################################
@@ -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)

View File

@@ -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

View File

@@ -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,

View File

@@ -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 == root.children.end() || (*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.;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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++;

View File

@@ -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;

View File

@@ -264,6 +264,9 @@ void X3DImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
//search for root node element
mNodeElementCur = NodeElement_List.front();
if (mNodeElementCur == nullptr) {
return;
}
while (mNodeElementCur->Parent != nullptr) {
mNodeElementCur = mNodeElementCur->Parent;
}

View File

@@ -972,7 +972,7 @@ void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buf
}
if (jointsPerVertex[vertexId] > 3) {
int boneIndexFitted = FitBoneWeight(vertexWeightData[vertexId], vertWeight);
if (boneIndexFitted) {
if (boneIndexFitted != -1) {
vertexJointData[vertexId][boneIndexFitted] = static_cast<float>(jointNamesIndex);
}
}else {

View File

@@ -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 )

View File

@@ -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);

View File

@@ -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

View File

@@ -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();

View File

@@ -59,11 +59,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
// ----------------------------------------------------------------
// A read-only file inside a ZIP
class ZipFile : public IOStream {
friend class ZipFileInfo;
explicit ZipFile(std::string &filename, size_t size);
public:
std::string m_Filename;
virtual ~ZipFile();
// IOStream interface
size_t Read(void *pvBuffer, size_t pSize, size_t pCount) override;
size_t Write(const void * /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) override { return 0; }
size_t FileSize() const override;
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override;
size_t Tell() const override;
void Flush() override {}
private:
size_t m_Size = 0;
size_t m_SeekPtr = 0;
std::unique_ptr<uint8_t[]> m_Buffer;
};
// ----------------------------------------------------------------
// Wraps an existing Assimp::IOSystem for unzip
class IOSystem2Unzip {
public:
static voidpf open(voidpf opaque, const char *filename, int mode);
static voidpf opendisk(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
static uLong read(voidpf opaque, voidpf stream, void *buf, uLong size);
static uLong write(voidpf opaque, voidpf stream, const void *buf, uLong size);
static long tell(voidpf opaque, voidpf stream);
@@ -92,6 +119,28 @@ voidpf IOSystem2Unzip::open(voidpf opaque, const char *filename, int mode) {
return (voidpf)io_system->Open(filename, mode_fopen);
}
voidpf IOSystem2Unzip::opendisk(voidpf opaque, voidpf stream, uint32_t number_disk, int mode) {
ZipFile *io_stream = (ZipFile *)stream;
voidpf ret = NULL;
size_t i;
char *disk_filename = (char*)malloc(io_stream->m_Filename.length() + 1);
strncpy(disk_filename, io_stream->m_Filename.c_str(), io_stream->m_Filename.length() + 1);
for (i = io_stream->m_Filename.length() - 1; i >= 0; i -= 1)
{
if (disk_filename[i] != '.')
continue;
snprintf(&disk_filename[i], io_stream->m_Filename.length() - i, ".z%02u", number_disk + 1);
break;
}
if (i >= 0)
ret = open(opaque, disk_filename, mode);
free(disk_filename);
return ret;
}
uLong IOSystem2Unzip::read(voidpf /*opaque*/, voidpf stream, void *buf, uLong size) {
IOStream *io_stream = (IOStream *)stream;
@@ -147,6 +196,7 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
zlib_filefunc_def mapping;
mapping.zopen_file = (open_file_func)open;
mapping.zopendisk_file = (opendisk_file_func)opendisk;
mapping.zread_file = (read_file_func)read;
mapping.zwrite_file = (write_file_func)write;
mapping.ztell_file = (tell_file_func)tell;
@@ -159,30 +209,6 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
return mapping;
}
// ----------------------------------------------------------------
// A read-only file inside a ZIP
class ZipFile : public IOStream {
friend class ZipFileInfo;
explicit ZipFile(size_t size);
public:
virtual ~ZipFile();
// IOStream interface
size_t Read(void *pvBuffer, size_t pSize, size_t pCount) override;
size_t Write(const void * /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) override { return 0; }
size_t FileSize() const override;
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override;
size_t Tell() const override;
void Flush() override {}
private:
size_t m_Size = 0;
size_t m_SeekPtr = 0;
std::unique_ptr<uint8_t[]> m_Buffer;
};
// ----------------------------------------------------------------
// Info about a read-only file inside a ZIP
class ZipFileInfo {
@@ -190,7 +216,7 @@ public:
explicit ZipFileInfo(unzFile zip_handle, size_t size);
// Allocate and Extract data from the ZIP
ZipFile *Extract(unzFile zip_handle) const;
ZipFile *Extract(std::string &filename, unzFile zip_handle) const;
private:
size_t m_Size = 0;
@@ -206,7 +232,7 @@ ZipFileInfo::ZipFileInfo(unzFile zip_handle, size_t size) :
unzGetFilePos(zip_handle, &(m_ZipFilePos));
}
ZipFile *ZipFileInfo::Extract(unzFile zip_handle) const {
ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
// Find in the ZIP. This cannot fail
unz_file_pos_s *filepos = const_cast<unz_file_pos_s *>(&(m_ZipFilePos));
if (unzGoToFilePos(zip_handle, filepos) != UNZ_OK)
@@ -215,7 +241,7 @@ ZipFile *ZipFileInfo::Extract(unzFile zip_handle) const {
if (unzOpenCurrentFile(zip_handle) != UNZ_OK)
return nullptr;
ZipFile *zip_file = new ZipFile(m_Size);
ZipFile *zip_file = new ZipFile(filename, m_Size);
// Unzip has a limit of UINT16_MAX bytes buffer
uint16_t unzipBufferSize = zip_file->m_Size <= UINT16_MAX ? static_cast<uint16_t>(zip_file->m_Size) : UINT16_MAX;
@@ -245,8 +271,8 @@ ZipFile *ZipFileInfo::Extract(unzFile zip_handle) const {
return zip_file;
}
ZipFile::ZipFile(size_t size) :
m_Size(size) {
ZipFile::ZipFile(std::string &filename, size_t size) :
m_Filename(filename), m_Size(size) {
ai_assert(m_Size != 0);
m_Buffer = std::unique_ptr<uint8_t[]>(new uint8_t[m_Size]);
}
@@ -372,7 +398,7 @@ void ZipArchiveIOSystem::Implement::MapArchive() {
unz_file_info fileInfo;
if (unzGetCurrentFileInfo(m_ZipFileHandle, &fileInfo, filename, FileNameSize, nullptr, 0, nullptr, 0) == UNZ_OK) {
if (fileInfo.uncompressed_size != 0) {
if (fileInfo.uncompressed_size != 0 && fileInfo.size_filename <= FileNameSize) {
std::string filename_string(filename, fileInfo.size_filename);
SimplifyFilename(filename_string);
m_ArchiveMap.emplace(filename_string, ZipFileInfo(m_ZipFileHandle, fileInfo.uncompressed_size));
@@ -422,7 +448,7 @@ IOStream *ZipArchiveIOSystem::Implement::OpenFile(std::string &filename) {
return nullptr;
const ZipFileInfo &zip_file = (*zip_it).second;
return zip_file.Extract(m_ZipFileHandle);
return zip_file.Extract(filename, m_ZipFileHandle);
}
inline void ReplaceAll(std::string &data, const std::string &before, const std::string &after) {

View File

@@ -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 )

View File

@@ -74,6 +74,7 @@ protected:
public:
/// @brief Virtual destructor.
virtual ~ProgressHandler () {
// empty
}
// -------------------------------------------------------------------

View File

@@ -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
// ---------------------------

View File

@@ -740,6 +740,7 @@ struct aiMesh {
/**
* Method of morphing when anim-meshes are specified.
* @see aiMorphingMethod to learn more about the provided morphing targets.
*/
unsigned int mMethod;

View File

@@ -49,17 +49,21 @@ TEST_F( utVersion, aiGetLegalStringTest ) {
std::string text( lv );
size_t pos = text.find(std::string("2021"));
EXPECT_NE( pos, std::string::npos );
EXPECT_NE(pos, std::string::npos);
}
TEST_F( utVersion, aiGetVersionMinorTest ) {
EXPECT_EQ( aiGetVersionMinor(), 1U );
EXPECT_EQ(aiGetVersionMinor(), 1U);
}
TEST_F( utVersion, aiGetVersionMajorTest ) {
EXPECT_EQ( aiGetVersionMajor(), 5U );
}
TEST_F( utVersion, aiGetVersionPatchTest ) {
EXPECT_EQ(aiGetVersionPatch(), 6U );
}
TEST_F( utVersion, aiGetCompileFlagsTest ) {
EXPECT_NE( aiGetCompileFlags(), 0U );
}
@@ -71,5 +75,3 @@ TEST_F( utVersion, aiGetVersionRevisionTest ) {
TEST_F( utVersion, aiGetBranchNameTest ) {
EXPECT_NE( nullptr, aiGetBranchName() );
}

View File

@@ -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;
}