Merge branch 'master' into ps-devel-fix-namespace-001

pull/4314/head
Kim Kulling 2021-12-31 08:20:24 +01:00 committed by GitHub
commit a86ab45161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 60 additions and 20 deletions

View File

@ -246,7 +246,7 @@ IF( UNIX )
ENDIF() ENDIF()
# Grouped compiler settings ######################################## # 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) IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -283,7 +283,7 @@ ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
ENDIF() ENDIF()
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" ) 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}") 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) 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.") 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) ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)

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, "ShininessExponent", aiTextureType_SHININESS, mesh);
TrySetTextureProperties(out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh); TrySetTextureProperties(out_mat, layeredTextures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh);
TrySetTextureProperties(out_mat, layeredTextures, "TransparencyFactor", aiTextureType_OPACITY, 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, 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 // get file format version and print to log
++it; ++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()); unsigned int version = strtoul10((*it).tokens[0].c_str());
ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]); ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]);
first = 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, " 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"); "but texture height is not equal to 1, which is not supported by MED");
} }
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.reset(new aiTexture);
pcNew->mHeight = 0; pcNew->mHeight = 0;
pcNew->mWidth = iWidth; pcNew->mWidth = iWidth;

View File

@ -557,7 +557,7 @@ ADD_ASSIMP_IMPORTER( IFC
if (ASSIMP_BUILD_IFC_IMPORTER) if (ASSIMP_BUILD_IFC_IMPORTER)
if (MSVC) if (MSVC)
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "/bigobj") 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") set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "-O2 -Wa,-mbig-obj")
endif() endif()
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 # 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 # 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. # 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") 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 COMPILE_FLAGS -Os )
SET_SOURCE_FILES_PROPERTIES(Importer/StepFile/StepFileGen1.cpp PROPERTIES LINK_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 // Constructor to be privately used by Importer
BaseImporter::BaseImporter() AI_NO_EXCEPT BaseImporter::BaseImporter() AI_NO_EXCEPT
: m_progress() { : m_progress() {
// empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -372,7 +373,10 @@ void BaseImporter::ConvertToUTF8(std::vector<char> &data) {
// UTF 16 BE with BOM // UTF 16 BE with BOM
if (*((uint16_t *)&data.front()) == 0xFFFE) { if (*((uint16_t *)&data.front()) == 0xFFFE) {
// Check to ensure no overflow can happen
if(data.size() % 2 != 0) {
return;
}
// swap the endianness .. // swap the endianness ..
for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) { for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) {
ByteSwap::Swap2(p); ByteSwap::Swap2(p);

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team Copyright (c) 2006-2021, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, 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> #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 { class DefaultProgressHandler : public ProgressHandler {
public:
virtual bool Update(float /*percentage*/) { /// @brief Ignores the update callback.
bool Update(float) override {
return false; return false;
} }
};
}; // !class DefaultProgressHandler
} // Namespace Assimp } // 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 // 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); ai_assert(nullptr != pimpl);
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();

View File

@ -1616,6 +1616,7 @@ endif()
if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 ) if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
# it is a bad hack after all # 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 # 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_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW
set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion
enable_language( C ) enable_language( C )

View File

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

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team Copyright (c) 2006-2021, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, 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 "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 = const char* AICMD_MSG_ABOUT =
"------------------------------------------------------ \n" "------------------------------------------------------ \n"
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \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" "\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 #ifndef ASSIMP_BUILD_NO_EXPORT
/*extern*/ Assimp::Exporter* globalExporter = NULL; /*extern*/ Assimp::Exporter* globalExporter = nullptr;
#endif #endif
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@ -286,6 +303,9 @@ const aiScene* ImportModel(
// do the actual import, measure time // do the actual import, measure time
const clock_t first = clock(); const clock_t first = clock();
ConsoleProgressHandler *ph = new ConsoleProgressHandler;
globalImporter->SetProgressHandler(ph);
const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags); const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
if (imp.showLog) { if (imp.showLog) {
@ -305,6 +325,9 @@ const aiScene* ImportModel(
if (imp.log) { if (imp.log) {
FreeLogStreams(); FreeLogStreams();
} }
globalImporter->SetProgressHandler(nullptr);
delete ph;
return scene; return scene;
} }