Compare commits

..

1 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
22 changed files with 156 additions and 135 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.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)
@@ -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")

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(),
@@ -2618,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);
@@ -2636,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++) {
@@ -3162,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;
}
}
@@ -3171,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;
}
}
@@ -3180,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;
}
}
@@ -3442,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);

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

View File

@@ -480,6 +480,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
}
}
} // namespace Assimp
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
} // namespace Assimp

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.

View File

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

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 {

View File

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

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

View File

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

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

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;

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,

View File

@@ -255,4 +255,5 @@ struct aiLight {
}
#endif
#endif // !! AI_LIGHT_H_INC

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

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

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,

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

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

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) {
}

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