Updated assimp to latest

This commit is contained in:
Areloch 2019-03-05 14:39:38 -06:00
parent e9ea38eda3
commit 8b40aa8c26
461 changed files with 34662 additions and 30165 deletions

View file

@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2019, assimp team
All rights reserved.
@ -43,14 +44,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the material system of the library
*/
#include "Hash.h"
#include "fast_atof.h"
#include "ParsingUtils.h"
#include <assimp/Hash.h>
#include <assimp/fast_atof.h>
#include <assimp/ParsingUtils.h>
#include "MaterialSystem.h"
#include <assimp/types.h>
#include <assimp/material.h>
#include <assimp/DefaultLogger.hpp>
#include "Macros.h"
#include <assimp/Macros.h>
using namespace Assimp;
@ -62,9 +63,9 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
unsigned int index,
const aiMaterialProperty** pPropOut)
{
ai_assert (pMat != NULL);
ai_assert (pKey != NULL);
ai_assert (pPropOut != NULL);
ai_assert( pMat != NULL );
ai_assert( pKey != NULL );
ai_assert( pPropOut != NULL );
/* Just search for a property with exactly this name ..
* could be improved by hashing, but it's possibly
@ -75,7 +76,7 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
if (prop /* just for safety ... */
&& 0 == strcmp( prop->mKey.data, pKey )
&& (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wildcard, but this is undocumented :-) */
&& (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];
@ -95,8 +96,8 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
ai_real* pOut,
unsigned int* pMax)
{
ai_assert (pOut != NULL);
ai_assert (pMat != NULL);
ai_assert( pOut != NULL );
ai_assert( pMat != NULL );
const aiMaterialProperty* prop;
aiGetMaterialProperty(pMat,pKey,type,index, (const aiMaterialProperty**) &prop);
@ -159,7 +160,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
break;
}
if ( !IsSpace(*cur) ) {
DefaultLogger::get()->error("Material property" + std::string(pKey) +
ASSIMP_LOG_ERROR("Material property" + std::string(pKey) +
" is a string; failed to parse a float array out of it.");
return AI_FAILURE;
}
@ -181,8 +182,8 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
int* pOut,
unsigned int* pMax)
{
ai_assert (pOut != NULL);
ai_assert (pMat != NULL);
ai_assert( pOut != NULL );
ai_assert( pMat != NULL );
const aiMaterialProperty* prop;
aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**) &prop);
@ -193,12 +194,18 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
// data is given in ints, simply copy it
unsigned int iWrite = 0;
if( aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) {
iWrite = prop->mDataLength / sizeof(int32_t);
iWrite = std::max(static_cast<unsigned int>(prop->mDataLength / sizeof(int32_t)), 1u);
if (pMax) {
iWrite = std::min(*pMax,iWrite); ;
iWrite = std::min(*pMax,iWrite);
}
for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<int>(reinterpret_cast<int32_t*>(prop->mData)[a]);
if (1 == prop->mDataLength) {
// bool type, 1 byte
*pOut = static_cast<int>(*prop->mData);
}
else {
for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<int>(reinterpret_cast<int32_t*>(prop->mData)[a]);
}
}
if (pMax) {
*pMax = iWrite;
@ -232,7 +239,7 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
break;
}
if(!IsSpace(*cur)) {
DefaultLogger::get()->error("Material property" + std::string(pKey) +
ASSIMP_LOG_ERROR("Material property" + std::string(pKey) +
" is a string; failed to parse an integer array out of it.");
return AI_FAILURE;
}
@ -273,7 +280,7 @@ aiReturn aiGetMaterialUVTransform(const aiMaterial* pMat,
aiUVTransform* pOut)
{
unsigned int iMax = 4;
return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax);
return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax);
}
// ------------------------------------------------------------------------------------------------
@ -304,7 +311,7 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat,
}
else {
// TODO - implement lexical cast as well
DefaultLogger::get()->error("Material property" + std::string(pKey) +
ASSIMP_LOG_ERROR("Material property" + std::string(pKey) +
" was found, but is no string" );
return AI_FAILURE;
}
@ -313,7 +320,7 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat,
// ------------------------------------------------------------------------------------------------
// Get the number of textures on a particular texture stack
ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
C_ENUM aiTextureType type)
{
ai_assert (pMat != NULL);
@ -346,15 +353,18 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
unsigned int* flags /*= NULL*/
)
{
ai_assert(NULL != mat && NULL != path);
ai_assert( NULL != mat );
ai_assert( NULL != path );
// Get the path to the texture
if (AI_SUCCESS != aiGetMaterialString(mat,AI_MATKEY_TEXTURE(type,index),path)) {
return AI_FAILURE;
}
// Determine mapping type
aiTextureMapping mapping = aiTextureMapping_UV;
aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index),(int*)&mapping);
int mapping_ = static_cast<int>(aiTextureMapping_UV);
aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index), &mapping_);
aiTextureMapping mapping = static_cast<aiTextureMapping>(mapping_);
if (_mapping)
*_mapping = mapping;
@ -379,15 +389,17 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
if (flags){
aiGetMaterialInteger(mat,AI_MATKEY_TEXFLAGS(type,index),(int*)flags);
}
return AI_SUCCESS;
}
static const unsigned int DefaultNumAllocated = 5;
// ------------------------------------------------------------------------------------------------
// Construction. Actually the one and only way to get an aiMaterial instance
aiMaterial::aiMaterial()
: mProperties( NULL )
: mProperties( nullptr )
, mNumProperties( 0 )
, mNumAllocated( DefaultNumAllocated ) {
// Allocate 5 entries by default
@ -402,12 +414,20 @@ aiMaterial::~aiMaterial()
delete[] mProperties;
}
// ------------------------------------------------------------------------------------------------
aiString aiMaterial::GetName() {
aiString name;
Get(AI_MATKEY_NAME, name);
return name;
}
// ------------------------------------------------------------------------------------------------
void aiMaterial::Clear()
{
for (unsigned int i = 0; i < mNumProperties;++i) {
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
// delete this entry
delete mProperties[i];
delete mProperties[ i ];
AI_DEBUG_INVALIDATE_PTR(mProperties[i]);
}
mNumProperties = 0;
@ -416,11 +436,9 @@ void aiMaterial::Clear()
}
// ------------------------------------------------------------------------------------------------
aiReturn aiMaterial::RemoveProperty (const char* pKey,unsigned int type,
unsigned int index
)
aiReturn aiMaterial::RemoveProperty ( const char* pKey,unsigned int type, unsigned int index )
{
ai_assert(NULL != pKey);
ai_assert( nullptr != pKey );
for (unsigned int i = 0; i < mNumProperties;++i) {
aiMaterialProperty* prop = mProperties[i];
@ -452,17 +470,18 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput,
aiPropertyTypeInfo pType
)
{
ai_assert (pInput != NULL);
ai_assert (pKey != NULL);
ai_assert (0 != pSizeInBytes);
ai_assert( pInput != NULL );
ai_assert( pKey != NULL );
ai_assert( 0 != pSizeInBytes );
if ( 0 == pSizeInBytes ) {
}
// first search the list whether there is already an entry with this key
unsigned int iOutIndex = UINT_MAX;
for (unsigned int i = 0; i < mNumProperties;++i) {
aiMaterialProperty* prop = mProperties[i];
unsigned int iOutIndex( UINT_MAX );
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
aiMaterialProperty *prop( mProperties[ i ] );
if (prop /* just for safety */ && !strcmp( prop->mKey.data, pKey ) &&
prop->mSemantic == type && prop->mIndex == index){
@ -514,6 +533,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput,
}
// push back ...
mProperties[mNumProperties++] = pcNew;
return AI_SUCCESS;
}