mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2016, assimp team
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -40,7 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Defines the StreamReader class which reads data from
|
||||
* a binary stream with a well-defined endianness. */
|
||||
* a binary stream with a well-defined endianness.
|
||||
*/
|
||||
|
||||
#ifndef AI_STREAMREADER_H_INCLUDED
|
||||
#define AI_STREAMREADER_H_INCLUDED
|
||||
|
|
@ -49,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "Exceptional.h"
|
||||
#include <memory>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include "Defines.h"
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
@ -66,9 +68,7 @@ namespace Assimp {
|
|||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||
class StreamReader
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// FIXME: use these data types throughout the whole library,
|
||||
// then change them to 64 bit values :-)
|
||||
|
||||
|
|
@ -76,8 +76,6 @@ public:
|
|||
typedef unsigned int pos;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Construction from a given stream with a well-defined endianness.
|
||||
*
|
||||
|
|
@ -178,14 +176,12 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the end of the srream) */
|
||||
/** Get the remaining stream size (to the end of the stream) */
|
||||
unsigned int GetRemainingSize() const {
|
||||
return (unsigned int)(end - current);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the current read limit). The
|
||||
* return value is the remaining size of the stream if no custom
|
||||
|
|
@ -194,7 +190,6 @@ public:
|
|||
return (unsigned int)(limit - current);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Increase the file pointer (relative seeking) */
|
||||
void IncPtr(size_t plus) {
|
||||
|
|
@ -210,7 +205,6 @@ public:
|
|||
return current;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Set current file pointer (Get it from #GetPtr). This is if you
|
||||
* prefer to do pointer arithmetics on your own or want to copy
|
||||
|
|
@ -218,7 +212,6 @@ public:
|
|||
* @param p The new pointer, which is validated against the size
|
||||
* limit and buffer boundaries. */
|
||||
void SetPtr(int8_t* p) {
|
||||
|
||||
current = p;
|
||||
if (current > limit || current < buffer) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
|
|
@ -230,14 +223,12 @@ public:
|
|||
* @param out Destination for copying
|
||||
* @param bytes Number of bytes to copy */
|
||||
void CopyAndAdvance(void* out, size_t bytes) {
|
||||
|
||||
int8_t* ur = GetPtr();
|
||||
SetPtr(ur+bytes); // fire exception if eof
|
||||
|
||||
memcpy(out,ur,bytes);
|
||||
::memcpy(out,ur,bytes);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current offset from the beginning of the file */
|
||||
int GetCurrentPos() const {
|
||||
|
|
@ -253,7 +244,7 @@ public:
|
|||
*
|
||||
* @param limit Maximum number of bytes to be read from
|
||||
* the beginning of the file. Specifying UINT_MAX
|
||||
* resets the limit to the original end of the stream.
|
||||
* resets the limit to the original end of the stream.
|
||||
* Returns the previously set limit. */
|
||||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int prev = GetReadLimit();
|
||||
|
|
@ -271,14 +262,14 @@ public:
|
|||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current read limit in bytes. Reading over this limit
|
||||
* accidentially raises an exception. */
|
||||
* accidentally raises an exception. */
|
||||
unsigned int GetReadLimit() const {
|
||||
return (unsigned int)(limit - buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Skip to the read limit in bytes. Reading over this limit
|
||||
* accidentially raises an exception. */
|
||||
* accidentally raises an exception. */
|
||||
void SkipToReadLimit() {
|
||||
current = limit;
|
||||
}
|
||||
|
|
@ -292,31 +283,26 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||
template <typename T>
|
||||
T Get() {
|
||||
if (current + sizeof(T) > limit) {
|
||||
if ( current + sizeof(T) > limit) {
|
||||
throw DeadlyImportError("End of file or stream limit was reached");
|
||||
}
|
||||
|
||||
#ifdef __arm__
|
||||
T f;
|
||||
memcpy (&f, current, sizeof(T));
|
||||
#else
|
||||
T f = *((const T*)current);
|
||||
#endif
|
||||
Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
||||
|
||||
::memcpy (&f, current, sizeof(T));
|
||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
||||
current += sizeof(T);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
void InternBegin() {
|
||||
if (!stream) {
|
||||
// incase someone wonders: StreamReader is frequently invoked with
|
||||
// in case someone wonders: StreamReader is frequently invoked with
|
||||
// no prior validation whether the input stream is valid. Since
|
||||
// no one bothers changing the error message, this message here
|
||||
// is passed down to the caller and 'unable to open file'
|
||||
|
|
@ -337,14 +323,11 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
std::shared_ptr<IOStream> stream;
|
||||
int8_t *buffer, *current, *end, *limit;
|
||||
bool le;
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue