update assimp lib

This commit is contained in:
marauder2k7 2024-12-09 20:22:47 +00:00
parent 03a348deb7
commit d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions

View file

@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -51,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h>
#include <assimp/types.h>
#include <assimp/DefaultLogger.hpp>
#include <memory>
using namespace Assimp;
@ -73,7 +73,7 @@ aiReturn aiGetMaterialProperty(const aiMaterial *pMat,
aiMaterialProperty *prop = pMat->mProperties[i];
if (prop /* just for safety ... */
&& 0 == strcmp(prop->mKey.data, pKey) && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */
&& 0 == strncmp(prop->mKey.data, pKey, strlen(pKey)) && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */
&& (UINT_MAX == index || prop->mIndex == index)) {
*pPropOut = pMat->mProperties[i];
return AI_SUCCESS;
@ -173,6 +173,95 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
return AI_SUCCESS;
}
// ------------------------------------------------------------------------------------------------
// Get an array of floating-point values from the material.
aiReturn aiGetMaterialDoubleArray(const aiMaterial *pMat,
const char *pKey,
unsigned int type,
unsigned int index,
double *pOut,
unsigned int *pMax) {
ai_assert(pOut != nullptr);
ai_assert(pMat != nullptr);
const aiMaterialProperty *prop;
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
if (nullptr == prop) {
return AI_FAILURE;
}
// 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 if integers from the material
aiReturn aiGetMaterialIntegerArray(const aiMaterial *pMat,
@ -473,7 +562,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
}
// Allocate a new material property
aiMaterialProperty *pcNew = new aiMaterialProperty();
std::unique_ptr<aiMaterialProperty> pcNew(new aiMaterialProperty());
// .. and fill it
pcNew->mType = pType;
@ -485,11 +574,11 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
memcpy(pcNew->mData, pInput, pSizeInBytes);
pcNew->mKey.length = static_cast<ai_uint32>(::strlen(pKey));
ai_assert(MAXLEN > pcNew->mKey.length);
ai_assert(AI_MAXLEN > pcNew->mKey.length);
strcpy(pcNew->mKey.data, pKey);
if (UINT_MAX != iOutIndex) {
mProperties[iOutIndex] = pcNew;
mProperties[iOutIndex] = pcNew.release();
return AI_SUCCESS;
}
@ -502,7 +591,6 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
try {
ppTemp = new aiMaterialProperty *[mNumAllocated];
} catch (std::bad_alloc &) {
delete pcNew;
return AI_OUTOFMEMORY;
}
@ -513,7 +601,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
mProperties = ppTemp;
}
// push back ...
mProperties[mNumProperties++] = pcNew;
mProperties[mNumProperties++] = pcNew.release();
return AI_SUCCESS;
}