mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-06-12 00:13:58 +00:00
update assimp to 6.0.5
This commit is contained in:
parent
2d2eb57e2e
commit
f5cf21cfeb
941 changed files with 22718 additions and 12240 deletions
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2026, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -80,73 +80,70 @@ aiReturn aiGetMaterialProperty(const aiMaterial *pMat,
|
|||
}
|
||||
}
|
||||
*pPropOut = nullptr;
|
||||
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get an array of floating-point values from the material.
|
||||
aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
|
||||
// Implementation of functions "aiGetMaterialFloatArray" and "aiGetMaterialFloatFloatArray".
|
||||
template <class TReal>
|
||||
aiReturn GetMaterialFloatArray(const aiMaterial *pMat,
|
||||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut,
|
||||
TReal *pOut,
|
||||
unsigned int *pMax) {
|
||||
ai_assert(pOut != nullptr);
|
||||
ai_assert(pMat != nullptr);
|
||||
|
||||
const aiMaterialProperty *prop;
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
|
||||
const aiMaterialProperty *prop{nullptr};
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, &prop);
|
||||
if (nullptr == prop) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
// data is given in floats, convert to ai_real
|
||||
// data is given in floats, convert to TReal
|
||||
unsigned int iWrite = 0;
|
||||
if (aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(float);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<float *>(prop->mData)[a]);
|
||||
pOut[a] = static_cast<TReal>(reinterpret_cast<float *>(prop->mData)[a]);
|
||||
}
|
||||
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in doubles, convert to float
|
||||
else if (aiPTI_Double == prop->mType) {
|
||||
} else if (aiPTI_Double == prop->mType) { // data is given in doubles, convert to TReal
|
||||
iWrite = prop->mDataLength / sizeof(double);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<double *>(prop->mData)[a]);
|
||||
pOut[a] = static_cast<TReal>(reinterpret_cast<double *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in ints, convert to float
|
||||
else if (aiPTI_Integer == prop->mType) {
|
||||
} else if (aiPTI_Integer == prop->mType) { // data is given in ints, convert to TReal
|
||||
iWrite = prop->mDataLength / sizeof(int32_t);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<int32_t *>(prop->mData)[a]);
|
||||
pOut[a] = static_cast<TReal>(reinterpret_cast<int32_t *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// a string ... read floats separated by spaces
|
||||
else {
|
||||
} else { // a string ... read floats separated by spaces
|
||||
if (pMax) {
|
||||
iWrite = *pMax;
|
||||
}
|
||||
|
|
@ -155,7 +152,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
|
|||
ai_assert(prop->mDataLength >= 5);
|
||||
ai_assert(!prop->mData[prop->mDataLength - 1]);
|
||||
for (unsigned int a = 0;; ++a) {
|
||||
cur = fast_atoreal_move<ai_real>(cur, pOut[a]);
|
||||
cur = fast_atoreal_move(cur, pOut[a]);
|
||||
if (a == iWrite - 1) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -170,96 +167,32 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
|
|||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get an array of floating-point values from the material.
|
||||
aiReturn aiGetMaterialDoubleArray(const aiMaterial *pMat,
|
||||
// Get an array of float typed float values from the material.
|
||||
aiReturn aiGetMaterialFloatFloatArray(const aiMaterial *pMat,
|
||||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
double *pOut,
|
||||
float *pOut,
|
||||
unsigned int *pMax) {
|
||||
ai_assert(pOut != nullptr);
|
||||
ai_assert(pMat != nullptr);
|
||||
return GetMaterialFloatArray(pMat, pKey, type, index, pOut, pMax);
|
||||
}
|
||||
|
||||
const aiMaterialProperty *prop;
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
|
||||
if (nullptr == prop) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// data is given in floats, convert to ai_real
|
||||
unsigned int iWrite = 0;
|
||||
if (aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(float);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<float *>(prop->mData)[a]);
|
||||
}
|
||||
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in doubles, convert to float
|
||||
else if (aiPTI_Double == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(double);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<double *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in ints, convert to float
|
||||
else if (aiPTI_Integer == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(int32_t);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<int32_t *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// a string ... read floats separated by spaces
|
||||
else {
|
||||
if (pMax) {
|
||||
iWrite = *pMax;
|
||||
}
|
||||
// strings are zero-terminated with a 32 bit length prefix, so this is safe
|
||||
const char *cur = prop->mData + 4;
|
||||
ai_assert(prop->mDataLength >= 5);
|
||||
ai_assert(!prop->mData[prop->mDataLength - 1]);
|
||||
for (unsigned int a = 0;; ++a) {
|
||||
cur = fast_atoreal_move<double>(cur, pOut[a]);
|
||||
if (a == iWrite - 1) {
|
||||
break;
|
||||
}
|
||||
if (!IsSpace(*cur)) {
|
||||
ASSIMP_LOG_ERROR("Material property", pKey,
|
||||
" is a string; failed to parse a float array out of it.");
|
||||
return AI_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
return AI_SUCCESS;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get an array of floating-point values from the material.
|
||||
aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
|
||||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut,
|
||||
unsigned int *pMax) {
|
||||
return GetMaterialFloatArray(pMat, pKey, type, index, pOut, pMax);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -274,7 +207,7 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial *pMat,
|
|||
ai_assert(pMat != nullptr);
|
||||
|
||||
const aiMaterialProperty *prop;
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, &prop);
|
||||
if (!prop) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
|
@ -348,7 +281,7 @@ aiReturn aiGetMaterialColor(const aiMaterial *pMat,
|
|||
unsigned int index,
|
||||
aiColor4D *pOut) {
|
||||
unsigned int iMax = 4;
|
||||
const aiReturn eRet = aiGetMaterialFloatArray(pMat, pKey, type, index, (ai_real *)pOut, &iMax);
|
||||
const aiReturn eRet = aiGetMaterialFloatFloatArray(pMat, pKey, type, index, (float *)pOut, &iMax);
|
||||
|
||||
// if no alpha channel is defined: set it to 1.0
|
||||
if (3 == iMax) {
|
||||
|
|
@ -366,7 +299,7 @@ aiReturn aiGetMaterialUVTransform(const aiMaterial *pMat,
|
|||
unsigned int index,
|
||||
aiUVTransform *pOut) {
|
||||
unsigned int iMax = 5;
|
||||
return aiGetMaterialFloatArray(pMat, pKey, type, index, (ai_real *)pOut, &iMax);
|
||||
return aiGetMaterialFloatArray(pMat, pKey, type, index, reinterpret_cast<ai_real *>(pOut), &iMax);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -378,8 +311,8 @@ aiReturn aiGetMaterialString(const aiMaterial *pMat,
|
|||
aiString *pOut) {
|
||||
ai_assert(pOut != nullptr);
|
||||
|
||||
const aiMaterialProperty *prop;
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
|
||||
const aiMaterialProperty *prop{nullptr};
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, &prop);
|
||||
if (!prop) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
|
@ -401,6 +334,12 @@ aiReturn aiGetMaterialString(const aiMaterial *pMat,
|
|||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a c-like string fron an aiString
|
||||
const char *aiGetStringC_Str(const aiString *str) {
|
||||
return str->data;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get the number of textures on a particular texture stack
|
||||
unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial *pMat, C_ENUM aiTextureType type) {
|
||||
|
|
@ -441,7 +380,7 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial *mat,
|
|||
}
|
||||
|
||||
// Determine mapping type
|
||||
int mapping_ = static_cast<int>(aiTextureMapping_UV);
|
||||
int mapping_ = aiTextureMapping_UV;
|
||||
aiGetMaterialInteger(mat, AI_MATKEY_MAPPING(type, index), &mapping_);
|
||||
aiTextureMapping mapping = static_cast<aiTextureMapping>(mapping_);
|
||||
if (_mapping)
|
||||
|
|
@ -472,12 +411,11 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial *mat,
|
|||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
static const unsigned int DefaultNumAllocated = 5;
|
||||
static constexpr unsigned int DefaultNumAllocated = 5;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Construction. Actually the one and only way to get an aiMaterial instance
|
||||
aiMaterial::aiMaterial() :
|
||||
mProperties(nullptr), mNumProperties(0), mNumAllocated(DefaultNumAllocated) {
|
||||
aiMaterial::aiMaterial() : mProperties(nullptr), mNumProperties(0), mNumAllocated(DefaultNumAllocated) {
|
||||
// Allocate 5 entries by default
|
||||
mProperties = new aiMaterialProperty *[DefaultNumAllocated];
|
||||
}
|
||||
|
|
@ -491,7 +429,7 @@ aiMaterial::~aiMaterial() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiString aiMaterial::GetName() const {
|
||||
aiString name;
|
||||
aiString name{};
|
||||
Get(AI_MATKEY_NAME, name);
|
||||
|
||||
return name;
|
||||
|
|
@ -562,7 +500,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
|||
}
|
||||
|
||||
// Allocate a new material property
|
||||
std::unique_ptr<aiMaterialProperty> pcNew(new aiMaterialProperty());
|
||||
auto pcNew = std::make_unique<aiMaterialProperty>();
|
||||
|
||||
// .. and fill it
|
||||
pcNew->mType = pType;
|
||||
|
|
@ -624,11 +562,9 @@ aiReturn aiMaterial::AddProperty(const aiString *pInput,
|
|||
uint32_t Assimp::ComputeMaterialHash(const aiMaterial *mat, bool includeMatName /*= false*/) {
|
||||
uint32_t hash = 1503; // magic start value, chosen to be my birthday :-)
|
||||
for (unsigned int i = 0; i < mat->mNumProperties; ++i) {
|
||||
aiMaterialProperty *prop;
|
||||
|
||||
// Exclude all properties whose first character is '?' from the hash
|
||||
// See doc for aiMaterialProperty.
|
||||
prop = mat->mProperties[i];
|
||||
const aiMaterialProperty *prop = mat->mProperties[i];
|
||||
if (nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) {
|
||||
|
||||
hash = SuperFastHash(prop->mKey.data, (unsigned int)prop->mKey.length, hash);
|
||||
|
|
@ -672,7 +608,7 @@ void aiMaterial::CopyPropertyList(aiMaterial *const pcDest,
|
|||
}
|
||||
|
||||
for (unsigned int i = iOldNum; i < pcDest->mNumProperties; ++i) {
|
||||
aiMaterialProperty *propSrc = pcSrc->mProperties[i];
|
||||
const aiMaterialProperty *propSrc = pcSrc->mProperties[i];
|
||||
|
||||
// search whether we have already a property with this name -> if yes, overwrite it
|
||||
aiMaterialProperty *prop;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue