Just the functional assimp lib rather than the entire assimp repository unnecessarily.

This commit is contained in:
Areloch 2019-02-28 16:37:15 -06:00
parent 0f7641a282
commit e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions

View file

@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2018, assimp team
Copyright (c) 2006-2017, assimp team
All rights reserved.
@ -51,8 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h"
#include <assimp/defs.h>
#include <stdint.h>
#include <assimp/Exceptional.h>
#include <assimp/ByteSwapper.h>
#include "Exceptional.h"
#include "ByteSwapper.h"
namespace Assimp {
namespace FBX {
@ -130,26 +129,30 @@ 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;
@ -164,8 +167,7 @@ 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)*/;
::memcpy( &dword, cursor, sizeof( uint64_t ) );
uint64_t dword = *reinterpret_cast<const uint64_t*>(cursor);
AI_SWAP8(dword);
cursor += k_to_read;
@ -174,21 +176,24 @@ 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 )*/
::memcpy( &word, cursor, sizeof( uint8_t ) );
uint8_t word = *reinterpret_cast<const uint8_t*>(cursor);
++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);
@ -217,7 +222,8 @@ 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);
}
@ -416,7 +422,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
@ -428,14 +434,6 @@ 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);
}
@ -448,8 +446,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;
const char *end = input + length;
while (cursor < end ) {
while (cursor < input + length)
{
if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
break;
}