Compare commits

..
Author SHA1 Message Date
Kim Kulling fa65d538dd Update HMPLoader.cpp
- Fix possible division by zero
- closes https://github.com/assimp/assimp/issues/4235
2021-12-10 14:32:44 +01:00
38 changed files with 215 additions and 399 deletions
+5 -7
View File
@@ -56,7 +56,7 @@ IF(ASSIMP_HUNTER_ENABLED)
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF()
PROJECT(Assimp VERSION 5.1.6)
PROJECT(Assimp VERSION 5.1.3)
# All supported options ###############################################
@@ -183,9 +183,7 @@ SET (ASSIMP_SOVERSION 5)
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
if(NOT ASSIMP_HUNTER_ENABLED)
# Enable C++11 support globally
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
endif()
IF(NOT ASSIMP_IGNORE_GIT_HASH)
@@ -246,7 +244,7 @@ IF( UNIX )
ENDIF()
# Grouped compiler settings ########################################
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -283,7 +281,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( MINGW )
ELSEIF( CMAKE_COMPILER_IS_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)
@@ -764,7 +762,7 @@ if(WIN32)
IF(MSVC_TOOLSET_VERSION)
SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX})
SET(ASSIMP_MSVC_VERSION ${MCVS_PREFIX})
ELSE()
IF(MSVC12)
SET(ASSIMP_MSVC_VERSION "vc120")
+2 -5
View File
@@ -49,8 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderDNA.h"
#include "BlenderSceneGen.h"
namespace Assimp {
namespace Blender {
using namespace Assimp;
using namespace Assimp::Blender;
//--------------------------------------------------------------------------------
template <>
@@ -885,7 +885,4 @@ void DNA::RegisterConverters() {
converters["CollectionObject"] = DNA::FactoryPair(&Structure::Allocate<CollectionObject>, &Structure::Convert<CollectionObject>);
}
} // namespace Blender
} //namespace Assimp
#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER
+8 -9
View File
@@ -79,7 +79,7 @@ using namespace Util;
#define MAGIC_NODE_TAG "_$AssimpFbx$"
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
#define CONVERT_FBX_TIME(time) (static_cast<double>(time) * 1000.0 / 46186158000LL)
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
defaultMaterialIndex(),
@@ -2070,7 +2070,6 @@ 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,
@@ -2619,7 +2618,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights;
meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights];
meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights];
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps;
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first);
for (unsigned int k = 0; k < numValuesAndWeights; k++) {
meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k);
meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k);
@@ -2637,8 +2636,8 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
return;
}
double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time;
double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time;
double start_time_fps = has_local_startstop ? CONVERT_FBX_TIME(start_time) : min_time;
double stop_time_fps = has_local_startstop ? CONVERT_FBX_TIME(stop_time) : max_time;
// adjust relative timing for animation
for (unsigned int c = 0; c < anim->mNumChannels; c++) {
@@ -3163,7 +3162,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outTranslations[i].mValue = defTranslate;
}
}
@@ -3172,7 +3171,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outRotations[i].mValue = defQuat;
}
}
@@ -3181,7 +3180,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime);
} else {
for (size_t i = 0; i < keyCount; ++i) {
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
outScales[i].mValue = defScale;
}
}
@@ -3443,7 +3442,7 @@ void FBXConverter::InterpolateKeys(aiVectorKey *valOut, const KeyTimeList &keys,
}
// magic value to convert fbx times to seconds
valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps;
valOut->mTime = CONVERT_FBX_TIME(time);
min_time = std::min(min_time, valOut->mTime);
max_time = std::max(max_time, valOut->mTime);
+1 -1
View File
@@ -393,7 +393,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
// If a RGB color map is explicitly requested delete the
// alpha channel - it could theoretically be != 1.
if (_mSurfaces[j].mVCMapType == AI_LWO_RGB)
if (_mSurfaces[i].mVCMapType == AI_LWO_RGB)
pvVC[w]->a = 1.f;
pvVC[w]++;
-5
View File
@@ -537,11 +537,6 @@ 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.;
+2 -6
View File
@@ -463,12 +463,8 @@ 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");
}
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->mWidth = iWidth;
+1 -28
View File
@@ -133,10 +133,6 @@ struct Material {
aiString textureSpecularity;
aiString textureOpacity;
aiString textureDisp;
aiString textureRoughness;
aiString textureMetallic;
aiString textureSheen;
aiString textureRMA;
enum TextureType {
TextureDiffuseType = 0,
@@ -155,10 +151,6 @@ struct Material {
TextureSpecularityType,
TextureOpacityType,
TextureDispType,
TextureRoughnessType,
TextureMetallicType,
TextureSheenType,
TextureRMAType,
TextureTypeCount
};
bool clamp[TextureTypeCount];
@@ -182,19 +174,6 @@ 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)),
@@ -202,13 +181,7 @@ 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)),
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)) {
transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)) {
std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
}
-39
View File
@@ -618,12 +618,6 @@ 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);
@@ -715,39 +709,6 @@ 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++;
-61
View File
@@ -67,10 +67,6 @@ 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";
@@ -182,45 +178,10 @@ 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
@@ -236,12 +197,6 @@ 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;
@@ -379,22 +334,6 @@ 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;
+2 -5
View File
@@ -264,9 +264,6 @@ 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;
}
@@ -483,6 +480,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
}
}
} // namespace Assimp
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
} // namespace Assimp
+1 -1
View File
@@ -879,7 +879,7 @@ void X3DImporter::readSphere(XmlNode &node) {
X3DNodeElementBase *ne(nullptr);
MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
XmlParser::getRealAttribute(node, "radius", radius);
XmlParser::getFloatAttribute(node, "radius", radius);
XmlParser::getBoolAttribute(node, "solid", solid);
// if "USE" defined then find already defined element.
+2 -2
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 != -1) {
if (boneIndexFitted) {
vertexJointData[vertexId][boneIndexFitted] = static_cast<float>(jointNamesIndex);
}
}else {
@@ -1410,7 +1410,7 @@ void glTF2Exporter::ExportMetadata() {
}
}
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> &times) {
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> &times) {
return ExportData(asset, animId, buffer, (unsigned int)times.size(), &times[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
}
-3
View File
@@ -66,9 +66,7 @@ class Ref;
}
namespace glTF2 {
class Asset;
struct TexProperty;
struct TextureInfo;
struct NormalTextureInfo;
@@ -86,7 +84,6 @@ struct MaterialIOR;
typedef float(vec2)[2];
typedef float(vec3)[3];
typedef float(vec4)[4];
} // namespace glTF2
namespace Assimp {
+3 -3
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(MINGW)
elseif(CMAKE_COMPILER_IS_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 ((MINGW) AND (CMAKE_BUILD_TYPE MATCHES Debug))
if ((CMAKE_COMPILER_IS_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 )
@@ -1172,7 +1172,7 @@ ELSE()
ENDIF()
# adds C_FLAGS required to compile zip.c on old GCC 4.x compiler
TARGET_COMPILE_FEATURES(assimp PRIVATE c_std_99)
TARGET_COMPILE_FEATURES(assimp PUBLIC c_std_99)
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
+1 -5
View File
@@ -65,7 +65,6 @@ using namespace Assimp;
// Constructor to be privately used by Importer
BaseImporter::BaseImporter() AI_NO_EXCEPT
: m_progress() {
// empty
}
// ------------------------------------------------------------------------------------------------
@@ -373,10 +372,7 @@ 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);
+8 -9
View File
@@ -4,6 +4,7 @@ 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,20 +48,18 @@ 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 {
public:
/// @brief Ignores the update callback.
bool Update(float) override {
virtual bool Update(float /*percentage*/) {
return false;
}
};
}; // !class DefaultProgressHandler
} // Namespace Assimp
#endif // INCLUDED_AI_DEFAULTPROGRESSHANDLER_H
#endif
+1 -1
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();
-20
View File
@@ -1101,14 +1101,6 @@ void SceneCombiner::Copy(aiMesh **_dest, const aiMesh *src) {
// make a deep copy of all blend shapes
CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes);
// make a deep copy of all texture coordinate names
if (src->mTextureCoordsNames != nullptr) {
dest->mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {};
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
Copy(&dest->mTextureCoordsNames[i], src->mTextureCoordsNames[i]);
}
}
}
// ------------------------------------------------------------------------------------------------
@@ -1356,18 +1348,6 @@ void SceneCombiner::Copy(aiMetadata **_dest, const aiMetadata *src) {
}
}
// ------------------------------------------------------------------------------------------------
void SceneCombiner::Copy(aiString **_dest, const aiString *src) {
if (nullptr == _dest || nullptr == src) {
return;
}
aiString *dest = *_dest = new aiString();
// get a flat copy
*dest = *src;
}
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic pop
#endif
+31 -57
View File
@@ -59,38 +59,11 @@ 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);
@@ -119,28 +92,6 @@ 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;
@@ -196,7 +147,6 @@ 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;
@@ -209,6 +159,30 @@ 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 {
@@ -216,7 +190,7 @@ public:
explicit ZipFileInfo(unzFile zip_handle, size_t size);
// Allocate and Extract data from the ZIP
ZipFile *Extract(std::string &filename, unzFile zip_handle) const;
ZipFile *Extract(unzFile zip_handle) const;
private:
size_t m_Size = 0;
@@ -232,7 +206,7 @@ ZipFileInfo::ZipFileInfo(unzFile zip_handle, size_t size) :
unzGetFilePos(zip_handle, &(m_ZipFilePos));
}
ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
ZipFile *ZipFileInfo::Extract(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)
@@ -241,7 +215,7 @@ ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
if (unzOpenCurrentFile(zip_handle) != UNZ_OK)
return nullptr;
ZipFile *zip_file = new ZipFile(filename, m_Size);
ZipFile *zip_file = new ZipFile(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;
@@ -271,8 +245,8 @@ ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
return zip_file;
}
ZipFile::ZipFile(std::string &filename, size_t size) :
m_Filename(filename), m_Size(size) {
ZipFile::ZipFile(size_t size) :
m_Size(size) {
ai_assert(m_Size != 0);
m_Buffer = std::unique_ptr<uint8_t[]>(new uint8_t[m_Size]);
}
@@ -398,7 +372,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 && fileInfo.size_filename <= FileNameSize) {
if (fileInfo.uncompressed_size != 0) {
std::string filename_string(filename, fileInfo.size_filename);
SimplifyFilename(filename_string);
m_ArchiveMap.emplace(filename_string, ZipFileInfo(m_ZipFileHandle, fileInfo.uncompressed_size));
@@ -448,7 +422,7 @@ IOStream *ZipArchiveIOSystem::Implement::OpenFile(std::string &filename) {
return nullptr;
const ZipFileInfo &zip_file = (*zip_it).second;
return zip_file.Extract(filename, m_ZipFileHandle);
return zip_file.Extract(m_ZipFileHandle);
}
inline void ReplaceAll(std::string &data, const std::string &before, const std::string &after) {
@@ -50,7 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ParsingUtils.h>
#include "ProcessHelper.h"
#include "Material/MaterialSystem.h"
#include <assimp/Exceptional.h>
#include <stdio.h>
using namespace Assimp;
@@ -172,8 +171,6 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
}
// If the new material count differs from the original,
// we need to rebuild the material list and remap mesh material indexes.
if(iNewNum < 1)
throw DeadlyImportError("No materials remaining");
if (iNewNum != pScene->mNumMaterials) {
ai_assert(iNewNum > 0);
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
@@ -1616,7 +1616,6 @@ 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 )
-1
View File
@@ -74,7 +74,6 @@ protected:
public:
/// @brief Virtual destructor.
virtual ~ProgressHandler () {
// empty
}
// -------------------------------------------------------------------
-1
View File
@@ -361,7 +361,6 @@ public:
static void Copy(aiNodeAnim **dest, const aiNodeAnim *src);
static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src);
static void Copy(aiMetadata **dest, const aiMetadata *src);
static void Copy(aiString **dest, const aiString *src);
// recursive, of course
static void Copy(aiNode **dest, const aiNode *src);
+2 -1
View File
@@ -6,6 +6,7 @@ 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,
@@ -101,7 +102,7 @@ protected:
/** Creates a dummy material and returns it. */
aiMaterial *CreateMaterial();
private:
protected:
/** space to assemble the mesh data: points */
std::vector<aiVector3D> mVertices;
+2
View File
@@ -5,6 +5,8 @@ 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,
+1
View File
@@ -255,4 +255,5 @@ struct aiLight {
}
#endif
#endif // !! AI_LIGHT_H_INC
-3
View File
@@ -989,9 +989,6 @@ 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
// ---------------------------
+61 -29
View File
@@ -44,17 +44,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#ifndef AI_MATERIAL_INL_INC
#define AI_MATERIAL_INL_INC
#ifdef __GNUC__
# pragma GCC system_header
#endif
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(float) {
AI_FORCE_INLINE
aiPropertyTypeInfo ai_real_to_property_type_info(float) {
return aiPTI_Float;
}
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) {
AI_FORCE_INLINE
aiPropertyTypeInfo ai_real_to_property_type_info(double) {
return aiPTI_Double;
}
// ---------------------------------------------------------------------------
@@ -62,7 +66,8 @@ AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) {
//! @cond never
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
AI_FORCE_INLINE
aiReturn aiMaterial::GetTexture( aiTextureType type,
unsigned int index,
C_STRUCT aiString* path,
aiTextureMapping* mapping /*= NULL*/,
@@ -74,13 +79,15 @@ AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
AI_FORCE_INLINE
unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
return ::aiGetMaterialTextureCount(this,type);
}
// ---------------------------------------------------------------------------
template <typename Type>
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx, Type* pOut,
unsigned int* pMax) const {
unsigned int iNum = pMax ? *pMax : 1;
@@ -98,7 +105,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
return AI_FAILURE;
}
iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type)));
iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type));
::memcpy(pOut,prop->mData,iNum * sizeof(Type));
if (pMax) {
*pMax = iNum;
@@ -109,7 +116,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// ---------------------------------------------------------------------------
template <typename Type>
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,Type& pOut) const {
const aiMaterialProperty* prop;
const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
@@ -130,29 +138,34 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real* pOut,
unsigned int* pMax) const {
return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,int* pOut,
unsigned int* pMax) const {
return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real& pOut) const {
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,int& pOut) const {
return aiGetMaterialInteger(this,pKey,type,idx,&pOut);
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
AI_FORCE_INLINE
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,aiColor4D& pOut) const {
return aiGetMaterialColor(this,pKey,type,idx,&pOut);
}
@@ -177,10 +190,14 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// ---------------------------------------------------------------------------
template<class TYPE>
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues, const char* pKey, unsigned int type,
unsigned int index) {
return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE),
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
unsigned int index)
{
return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(TYPE),
pKey,type,index,aiPTI_Buffer);
}
@@ -196,7 +213,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const float* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -207,7 +225,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -218,7 +237,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -229,7 +249,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -240,7 +261,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -251,7 +273,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty(const int* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -270,7 +293,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<float>(const float* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -282,7 +306,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<double>(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -294,7 +319,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -306,7 +332,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransf
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -318,7 +345,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pIn
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -330,7 +358,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pIn
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -342,7 +371,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* p
// ---------------------------------------------------------------------------
template<>
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
AI_FORCE_INLINE
aiReturn aiMaterial::AddProperty<int>(const int* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
@@ -353,3 +383,5 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
}
//! @endcond
#endif //! AI_MATERIAL_INL_INC
-1
View File
@@ -740,7 +740,6 @@ struct aiMesh {
/**
* Method of morphing when anim-meshes are specified.
* @see aiMorphingMethod to learn more about the provided morphing targets.
*/
unsigned int mMethod;
+11 -8
View File
@@ -92,19 +92,22 @@ struct aiTexel {
#ifdef __cplusplus
//! Comparison operator
bool operator== (const aiTexel& other) const {
bool operator== (const aiTexel& other) const
{
return b == other.b && r == other.r &&
g == other.g && a == other.a;
}
//! Inverse comparison operator
bool operator!= (const aiTexel& other) const {
bool operator!= (const aiTexel& other) const
{
return b != other.b || r != other.r ||
g != other.g || a != other.a;
}
//! Conversion to a floating-point 4d color
operator aiColor4D() const {
operator aiColor4D() const
{
return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
}
#endif // __cplusplus
@@ -199,11 +202,11 @@ struct aiTexture {
}
// Construction
aiTexture() AI_NO_EXCEPT :
mWidth(0),
mHeight(0),
pcData(nullptr),
mFilename() {
aiTexture() AI_NO_EXCEPT
: mWidth(0)
, mHeight(0)
, pcData(nullptr)
, mFilename() {
memset(achFormatHint, 0, sizeof(achFormatHint));
}
+2
View File
@@ -5,6 +5,8 @@ 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,
+59 -33
View File
@@ -54,7 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 3x3 matrix */
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
AI_FORCE_INLINE
aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
@@ -65,7 +66,8 @@ AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 4x4 matrix */
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
AI_FORCE_INLINE
aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
@@ -80,35 +82,36 @@ aiVector3t<TReal>::operator aiVector3t<TOther> () const {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
AI_FORCE_INLINE
void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
x = pX;
y = pY;
z = pZ;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
AI_FORCE_INLINE
TReal aiVector3t<TReal>::SquareLength() const {
return x*x + y*y + z*z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
AI_FORCE_INLINE
TReal aiVector3t<TReal>::Length() const {
return std::sqrt( SquareLength());
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
const TReal l = Length();
if (l == 0) {
return *this;
}
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
*this /= Length();
return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
TReal len = Length();
if ( len > static_cast< TReal >( 0 ) ) {
*this /= len;
@@ -117,7 +120,8 @@ AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
x += o.x;
y += o.y;
z += o.z;
@@ -126,7 +130,8 @@ AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const a
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
x -= o.x;
y -= o.y;
z -= o.z;
@@ -135,7 +140,8 @@ AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const a
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
x *= f;
y *= f;
z *= f;
@@ -144,7 +150,8 @@ AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
AI_FORCE_INLINE
const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
if ( f == static_cast<TReal>(0.0)) {
return *this;
}
@@ -157,17 +164,20 @@ AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
return (*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
AI_FORCE_INLINE
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
return (*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
AI_FORCE_INLINE
TReal aiVector3t<TReal>::operator[](unsigned int i) const {
switch (i) {
case 0:
return x;
@@ -182,7 +192,9 @@ AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
AI_FORCE_INLINE
TReal& aiVector3t<TReal>::operator[](unsigned int i) {
// return *(&x + i);
switch (i) {
case 0:
return x;
@@ -197,17 +209,20 @@ AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
return x == other.x && y == other.y && z == other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
return x != other.x || y != other.y || z != other.z;
}
// ---------------------------------------------------------------------------
template<typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
AI_FORCE_INLINE
bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
return
std::abs(x - other.x) <= epsilon &&
std::abs(y - other.y) <= epsilon &&
@@ -215,66 +230,77 @@ AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TR
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
AI_FORCE_INLINE
bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
AI_FORCE_INLINE
const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric addition
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE
aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric subtraction
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE
aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
// ------------------------------------------------------------------------------------------------
// scalar product
template <typename TReal>
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE
TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
// ------------------------------------------------------------------------------------------------
// scalar multiplication
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
AI_FORCE_INLINE
aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// and the other way around
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
AI_FORCE_INLINE
aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// scalar division
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
AI_FORCE_INLINE
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
return v * (1/f);
}
// ------------------------------------------------------------------------------------------------
// vector division
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
}
// ------------------------------------------------------------------------------------------------
// cross product
template<typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
AI_FORCE_INLINE
aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
}
// ------------------------------------------------------------------------------------------------
// vector negation
template<typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
AI_FORCE_INLINE
aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
}

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.
-17
View File
@@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/SceneCombiner.h>
using namespace Assimp;
@@ -89,21 +88,5 @@ TEST_F(utScene, getShortFilenameTest) {
EXPECT_NE(nullptr, name2);
}
TEST_F(utScene, deepCopyTest) {
scene->mRootNode = new aiNode();
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh *[scene->mNumMeshes] ();
scene->mMeshes[0] = new aiMesh ();
scene->mMeshes[0]->SetTextureCoordsName (0, aiString ("test"));
{
aiScene* copied = nullptr;
SceneCombiner::CopyScene(&copied,scene);
delete copied;
}
}
TEST_F(utScene, getEmbeddedTextureTest) {
}
+1 -1
View File
@@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) {
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax));
EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast<size_t>(pMax));
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]);
}
+4 -6
View File
@@ -49,21 +49,17 @@ 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 );
}
@@ -75,3 +71,5 @@ TEST_F( utVersion, aiGetVersionRevisionTest ) {
TEST_F( utVersion, aiGetBranchNameTest ) {
EXPECT_NE( nullptr, aiGetBranchName() );
}
+4 -27
View File
@@ -5,6 +5,8 @@ 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,
@@ -45,25 +47,6 @@ 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"
@@ -90,10 +73,10 @@ const char* AICMD_MSG_HELP =
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
;
/*extern*/ Assimp::Importer* globalImporter = nullptr;
/*extern*/ Assimp::Importer* globalImporter = NULL;
#ifndef ASSIMP_BUILD_NO_EXPORT
/*extern*/ Assimp::Exporter* globalExporter = nullptr;
/*extern*/ Assimp::Exporter* globalExporter = NULL;
#endif
// ------------------------------------------------------------------------------
@@ -303,9 +286,6 @@ 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) {
@@ -325,9 +305,6 @@ const aiScene* ImportModel(
if (imp.log) {
FreeLogStreams();
}
globalImporter->SetProgressHandler(nullptr);
delete ph;
return scene;
}