Updated assimp to latest

This commit is contained in:
Areloch 2019-03-05 14:39:38 -06:00
parent 25ce4477ce
commit 161bf7f83b
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.
@ -50,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h"
#include <assimp/defs.h>
#include <stdint.h>
#include "Exceptional.h"
#include "ByteSwapper.h"
#include <assimp/Exceptional.h>
#include <assimp/ByteSwapper.h>
namespace Assimp {
namespace FBX {
@ -82,7 +83,7 @@ namespace FBX {
// e_unknown_21 = 1 << 21,
// e_unknown_22 = 1 << 22,
// e_unknown_23 = 1 << 23,
// e_flag_field_size_64_bit = 1 << 24, // Not sure what is
// e_flag_field_size_64_bit = 1 << 24, // Not sure what is
// e_unknown_25 = 1 << 25,
// e_unknown_26 = 1 << 26,
// e_unknown_27 = 1 << 27,
@ -129,30 +130,26 @@ AI_WONT_RETURN void TokenizeError(const std::string& message, unsigned int offse
// ------------------------------------------------------------------------------------------------
uint32_t Offset(const char* begin, const char* cursor)
{
uint32_t Offset(const char* begin, const char* cursor) {
ai_assert(begin <= cursor);
return static_cast<unsigned int>(cursor - begin);
}
// ------------------------------------------------------------------------------------------------
void TokenizeError(const std::string& message, const char* begin, const char* cursor)
{
void TokenizeError(const std::string& message, const char* begin, const char* cursor) {
TokenizeError(message, Offset(begin, cursor));
}
// ------------------------------------------------------------------------------------------------
uint32_t ReadWord(const char* input, const char*& cursor, const char* end)
{
uint32_t ReadWord(const char* input, const char*& cursor, const char* end) {
const size_t k_to_read = sizeof( uint32_t );
if(Offset(cursor, end) < k_to_read ) {
TokenizeError("cannot ReadWord, out of bounds",input, cursor);
}
uint32_t word;
memcpy(&word, cursor, 4);
::memcpy(&word, cursor, 4);
AI_SWAP4(word);
cursor += k_to_read;
@ -167,7 +164,8 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor);
}
uint64_t dword = *reinterpret_cast<const uint64_t*>(cursor);
uint64_t dword /*= *reinterpret_cast<const uint64_t*>(cursor)*/;
::memcpy( &dword, cursor, sizeof( uint64_t ) );
AI_SWAP8(dword);
cursor += k_to_read;
@ -176,24 +174,21 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
}
// ------------------------------------------------------------------------------------------------
uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
{
uint8_t ReadByte(const char* input, const char*& cursor, const char* end) {
if(Offset(cursor, end) < sizeof( uint8_t ) ) {
TokenizeError("cannot ReadByte, out of bounds",input, cursor);
}
uint8_t word = *reinterpret_cast<const uint8_t*>(cursor);
uint8_t word;/* = *reinterpret_cast< const uint8_t* >( cursor )*/
::memcpy( &word, cursor, sizeof( uint8_t ) );
++cursor;
return word;
}
// ------------------------------------------------------------------------------------------------
unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end,
bool long_length = false,
bool allow_null = false)
{
unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input,
const char*& cursor, const char* end, bool long_length = false, bool allow_null = false) {
const uint32_t len_len = long_length ? 4 : 1;
if(Offset(cursor, end) < len_len) {
TokenizeError("cannot ReadString, out of bounds reading length",input, cursor);
@ -222,8 +217,7 @@ unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const ch
}
// ------------------------------------------------------------------------------------------------
void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end)
{
void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) {
if(Offset(cursor, end) < 1) {
TokenizeError("cannot ReadData, out of bounds reading length",input, cursor);
}
@ -282,8 +276,8 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
case 'f':
case 'd':
case 'l':
case 'i': {
case 'i':
case 'c': {
const uint32_t length = ReadWord(input, cursor, end);
const uint32_t encoding = ReadWord(input, cursor, end);
@ -304,6 +298,10 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
stride = 8;
break;
case 'c':
stride = 1;
break;
default:
ai_assert(false);
};
@ -422,7 +420,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
return true;
}
}
} // anonymous namespace
// ------------------------------------------------------------------------------------------------
// TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent
@ -434,6 +432,14 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
TokenizeError("file is too short",0);
}
//uint32_t offset = 0x15;
/* const char* cursor = input + 0x15;
const uint32_t flags = ReadWord(input, cursor, input + length);
const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused*/
if (strncmp(input,"Kaydara FBX Binary",18)) {
TokenizeError("magic bytes not found",0);
}
@ -446,8 +452,8 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
/*Result ignored*/ ReadByte(input, cursor, input + length);
const uint32_t version = ReadWord(input, cursor, input + length);
const bool is64bits = version >= 7500;
while (cursor < input + length)
{
const char *end = input + length;
while (cursor < end ) {
if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
break;
}