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

@ -0,0 +1,79 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file Provides facilities to replace the default assert handler. */
#ifndef INCLUDED_AI_ASSERTHANDLER_H
#define INCLUDED_AI_ASSERTHANDLER_H
#include <assimp/ai_assert.h>
#include <assimp/defs.h>
namespace Assimp {
// ---------------------------------------------------------------------------
/**
* @brief Signature of functions which handle assert violations.
*/
using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line);
// ---------------------------------------------------------------------------
/**
* @brief Set the assert handler.
*/
ASSIMP_API void setAiAssertHandler(AiAssertHandler handler);
// ---------------------------------------------------------------------------
/** The assert handler which is set by default.
*
* @brief This issues a message to stderr and calls abort.
*/
AI_WONT_RETURN ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line) AI_WONT_RETURN_SUFFIX;
// ---------------------------------------------------------------------------
/**
* @brief Dispatches an assert violation to the assert handler.
*/
ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line);
} // end of namespace Assimp
#endif // INCLUDED_AI_ASSERTHANDLER_H

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -43,6 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_BASE64_HPP_INC
#define AI_BASE64_HPP_INC
#include <assimp/defs.h>
#include <stdint.h>
#include <vector>
#include <string>
@ -54,35 +56,35 @@ namespace Base64 {
/// @param in The UTF-64 buffer.
/// @param inLength The size of the buffer
/// @param out The encoded ASCII string.
void Encode(const uint8_t *in, size_t inLength, std::string &out);
ASSIMP_API void Encode(const uint8_t *in, size_t inLength, std::string &out);
/// @brief Will encode the given character buffer from UTF64 to ASCII.
/// @param in A vector, which contains the buffer for encoding.
/// @param out The encoded ASCII string.
void Encode(const std::vector<uint8_t>& in, std::string &out);
ASSIMP_API void Encode(const std::vector<uint8_t> &in, std::string &out);
/// @brief Will encode the given character buffer from UTF64 to ASCII.
/// @param in A vector, which contains the buffer for encoding.
/// @return The encoded ASCII string.
std::string Encode(const std::vector<uint8_t>& in);
ASSIMP_API std::string Encode(const std::vector<uint8_t> &in);
/// @brief Will decode the given character buffer from ASCII to UTF64.
/// @param in The ASCII buffer to decode.
/// @param inLength The size of the buffer.
/// @param out The decoded buffer.
/// @return The new buffer size.
size_t Decode(const char *in, size_t inLength, uint8_t *&out);
ASSIMP_API size_t Decode(const char *in, size_t inLength, uint8_t *&out);
/// @brief Will decode the given character buffer from ASCII to UTF64.
/// @param in The ASCII buffer to decode as a std::string.
/// @param out The decoded buffer.
/// @return The new buffer size.
size_t Decode(const std::string& in, std::vector<uint8_t>& out);
ASSIMP_API size_t Decode(const std::string &in, std::vector<uint8_t> &out);
/// @brief Will decode the given character buffer from ASCII to UTF64.
/// @param in The ASCII string.
/// @return The decoded buffer in a vector.
std::vector<uint8_t> Decode(const std::string& in);
ASSIMP_API std::vector<uint8_t> Decode(const std::string &in);
} // namespace Base64
} // namespace Assimp

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/types.h>
#include <assimp/ProgressHandler.hpp>
#include <exception>
#include <set>
#include <vector>
#include <memory>
@ -62,6 +63,7 @@ struct aiImporterDesc;
namespace Assimp {
// Forward declarations
class Importer;
class IOSystem;
class BaseProcess;
@ -72,6 +74,9 @@ class IOStream;
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
(string[1] << 16) + (string[2] << 8) + string[3]))
using UByteBuffer = std::vector<uint8_t>;
using ByteBuffer = std::vector<int8_t>;
// ---------------------------------------------------------------------------
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
* for all importer worker classes.
@ -90,7 +95,7 @@ public:
BaseImporter() AI_NO_EXCEPT;
/** Destructor, private as well */
virtual ~BaseImporter();
virtual ~BaseImporter() = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
@ -258,7 +263,7 @@ public: // static utilities
std::size_t numTokens,
unsigned int searchBytes = 200,
bool tokensSol = false,
bool noAlphaBeforeTokens = false);
bool noGraphBeforeTokens = false);
// -------------------------------------------------------------------
/** @brief Check whether a file has a specific file extension
@ -272,7 +277,18 @@ public: // static utilities
const std::string &pFile,
const char *ext0,
const char *ext1 = nullptr,
const char *ext2 = nullptr);
const char *ext2 = nullptr,
const char *ext3 = nullptr);
// -------------------------------------------------------------------
/** @brief Check whether a file has one of the passed file extensions
* @param pFile Input file
* @param extensions Extensions to check for. Lowercase characters only, no dot!
* @note Case-insensitive
*/
static bool HasExtension(
const std::string &pFile,
const std::set<std::string> &extensions);
// -------------------------------------------------------------------
/** @brief Extract file extension from a string

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -63,7 +63,7 @@ namespace Assimp {
class IOStream;
// ---------------------------------------------------------------------------
/**
/**
* This class is used to store and write bitmap information.
*/
class ASSIMP_API Bitmap {

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

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.
@ -66,10 +65,10 @@ namespace Assimp {
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
// --------------------------------------------------------------------------------------
class ByteSwap {
ByteSwap() AI_NO_EXCEPT {}
ByteSwap() AI_NO_EXCEPT = default;
~ByteSwap() = default;
public:
// ----------------------------------------------------------------------
/** Swap two bytes of data
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
@ -89,8 +88,7 @@ public:
// ----------------------------------------------------------------------
/** Swap four bytes of data
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
static inline void Swap4(void* _szOut)
{
static inline void Swap4(void* _szOut) {
ai_assert(_szOut);
#if _MSC_VER >= 1400
@ -263,7 +261,7 @@ struct ByteSwapper<T,false> {
};
// --------------------------------------------------------------------------------------------
template <bool SwapEndianess, typename T, bool RuntimeSwitch>
template <bool SwapEndianness, typename T, bool RuntimeSwitch>
struct Getter {
void operator() (T* inout, bool le) {
#ifdef AI_BUILD_BIG_ENDIAN
@ -278,12 +276,12 @@ struct Getter {
}
};
template <bool SwapEndianess, typename T>
struct Getter<SwapEndianess,T,false> {
template <bool SwapEndianness, typename T>
struct Getter<SwapEndianness,T,false> {
void operator() (T* inout, bool /*le*/) {
// static branch
ByteSwapper<T,(SwapEndianess && sizeof(T)>1)> () (inout);
ByteSwapper<T,(SwapEndianness && sizeof(T)>1)> () (inout);
}
};
} // end Intern

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -74,7 +74,7 @@ class ASSIMP_API DefaultIOStream : public IOStream {
#endif // __ANDROID__
protected:
/// @brief
/// @brief
DefaultIOStream() AI_NO_EXCEPT;
/// @brief The class constructor with the file name and the stream.
@ -84,7 +84,7 @@ protected:
public:
/** Destructor public to allow simple deletion to close the file. */
~DefaultIOStream ();
~DefaultIOStream () override;
// -------------------------------------------------------------------
/// Read from stream

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -56,6 +56,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "NullLogger.hpp"
#include <vector>
#ifndef ASSIMP_BUILD_SINGLETHREADED
#include <mutex>
#include <thread>
#endif
namespace Assimp {
// ------------------------------------------------------------------------------------
class IOStream;
@ -103,6 +108,9 @@ public:
* your needs. If the provided message formatting is OK for you,
* it's much easier to use #create() and to attach your own custom
* output streams to it.
* Since set is intended to be used for custom loggers, the user is
* responsible for instantiation and destruction (new / delete).
* Before deletion of the custom logger, set(nullptr); must be called.
* @param logger Pass NULL to setup a default NullLogger*/
static void set(Logger *logger);
@ -120,8 +128,8 @@ public:
static bool isNullLogger();
// ----------------------------------------------------------------------
/** @brief Kills the current singleton logger and replaces it with a
* #NullLogger instance. */
/** @brief Kills and deletes the current singleton logger and replaces
* it with a #NullLogger instance. */
static void kill();
// ----------------------------------------------------------------------
@ -181,6 +189,10 @@ private:
//! Attached streams
StreamArray m_StreamArray;
#ifndef ASSIMP_BUILD_SINGLETHREADED
std::mutex m_arrayMutex;
#endif
bool noRepeatMsg;
char lastMsg[MAX_LOG_MESSAGE_LENGTH * 2];
size_t lastLen;

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
@ -64,11 +65,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
#define get16bits(d) (*((const uint16_t *) (d)))
# define get16bits(d) (*((const uint16_t *) (d)))
#endif
#if !defined (get16bits)
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
+(uint32_t)(((const uint8_t *)(d))[0]) )
#endif
@ -76,9 +77,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
inline uint32_t SuperFastHash (const char * data, uint32_t len = 0, uint32_t hash = 0) {
uint32_t tmp;
int rem;
if (!data) return 0;
if (!len)len = (uint32_t)::strlen(data);
if (data == NULL) return 0;
if (len == 0)len = (uint32_t)::strlen(data);
rem = len & 3;
len >>= 2;

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -73,14 +73,14 @@ class ASSIMP_API IOStream
{
protected:
/** Constructor protected, use IOSystem::Open() to create an instance. */
IOStream() AI_NO_EXCEPT;
IOStream() AI_NO_EXCEPT = default;
public:
// -------------------------------------------------------------------
/** @brief Destructor. Deleting the object closes the underlying file,
* alternatively you may use IOSystem::Close() to release the file.
*/
virtual ~IOStream();
virtual ~IOStream() = default;
// -------------------------------------------------------------------
/** @brief Read from the file
@ -126,17 +126,6 @@ public:
virtual void Flush() = 0;
}; //! class IOStream
// ----------------------------------------------------------------------------------
AI_FORCE_INLINE
IOStream::IOStream() AI_NO_EXCEPT {
// empty
}
// ----------------------------------------------------------------------------------
AI_FORCE_INLINE
IOStream::~IOStream() = default;
// ----------------------------------------------------------------------------------
} //!namespace Assimp
#endif //!!AI_IOSTREAM_H_INC

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -66,7 +66,7 @@ public:
IOStreamBuffer(size_t cache = 4096 * 4096);
/// @brief The class destructor.
~IOStreamBuffer();
~IOStreamBuffer() = default;
/// @brief Will open the cached access for a given stream.
/// @param stream The stream to cache.
@ -140,11 +140,6 @@ AI_FORCE_INLINE IOStreamBuffer<T>::IOStreamBuffer(size_t cache) :
std::fill(m_cache.begin(), m_cache.end(), '\n');
}
template <class T>
AI_FORCE_INLINE IOStreamBuffer<T>::~IOStreamBuffer() {
// empty
}
template <class T>
AI_FORCE_INLINE bool IOStreamBuffer<T>::open(IOStream *stream) {
// file still opened!
@ -289,7 +284,7 @@ static AI_FORCE_INLINE bool isEndOfCache(size_t pos, size_t cacheSize) {
template <class T>
AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
buffer.resize(m_cacheSize);
if (isEndOfCache(m_cachePos, m_cacheSize) || 0 == m_filePos) {
if (m_cachePos >= m_cacheSize || 0 == m_filePos) {
if (!readNextBlock()) {
return false;
}
@ -325,7 +320,9 @@ AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
}
}
buffer[i] = '\n';
++m_cachePos;
while (m_cachePos < m_cacheSize && (m_cache[m_cachePos] == '\r' || m_cache[m_cachePos] == '\n')) {
++m_cachePos;
}
return true;
}

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -97,7 +97,7 @@ public:
* Create an instance of your derived class and assign it to an
* #Assimp::Importer instance by calling Importer::SetIOHandler().
*/
IOSystem() AI_NO_EXCEPT;
IOSystem() AI_NO_EXCEPT = default;
// -------------------------------------------------------------------
/** @brief Virtual destructor.
@ -105,7 +105,7 @@ public:
* It is safe to be called from within DLL Assimp, we're constructed
* on Assimp's heap.
*/
virtual ~IOSystem();
virtual ~IOSystem() = default;
// -------------------------------------------------------------------
/** @brief For backward compatibility
@ -236,15 +236,6 @@ private:
std::vector<std::string> m_pathStack;
};
// ----------------------------------------------------------------------------
AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT :
m_pathStack() {
// empty
}
// ----------------------------------------------------------------------------
AI_FORCE_INLINE IOSystem::~IOSystem() = default;
// ----------------------------------------------------------------------------
// For compatibility, the interface of some functions taking a std::string was
// changed to const char* to avoid crashes between binary incompatible STL

View file

@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -113,7 +111,7 @@ namespace Assimp {
* If you need the Importer to do custom file handling to access the files,
* implement IOSystem and IOStream and supply an instance of your custom
* IOSystem implementation by calling SetIOHandler() before calling ReadFile().
* If you do not assign a custion IO handler, a default handler using the
* If you do not assign a custom IO handler, a default handler using the
* standard C++ IO logic will be used.
*
* @note One Importer instance is not thread-safe. If you use multiple

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -86,7 +86,7 @@ public:
*/
LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true);
~LineSplitter();
~LineSplitter() = default;
// -----------------------------------------
/** pseudo-iterator increment */
@ -110,6 +110,8 @@ public:
std::string operator* () const;
const char *getEnd() const;
// -----------------------------------------
/** boolean context */
operator bool() const;
@ -139,6 +141,7 @@ public:
private:
line_idx mIdx;
std::string mCur;
const char *mEnd;
StreamReaderLE& mStream;
bool mSwallow, mSkip_empty_lines, mTrim;
};
@ -146,19 +149,17 @@ private:
AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) :
mIdx(0),
mCur(),
mEnd(nullptr),
mStream(stream),
mSwallow(),
mSkip_empty_lines(skip_empty_lines),
mTrim(trim) {
mCur.reserve(1024);
mEnd = mCur.c_str() + 1024;
operator++();
mIdx = 0;
}
AI_FORCE_INLINE LineSplitter::~LineSplitter() {
// empty
}
AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() {
if (mSwallow) {
mSwallow = false;
@ -206,14 +207,14 @@ AI_FORCE_INLINE LineSplitter &LineSplitter::operator++(int) {
AI_FORCE_INLINE const char *LineSplitter::operator[] (size_t idx) const {
const char* s = operator->()->c_str();
SkipSpaces(&s);
SkipSpaces(&s, mEnd);
for (size_t i = 0; i < idx; ++i) {
for (; !IsSpace(*s); ++s) {
if (IsLineEnd(*s)) {
throw std::range_error("Token index out of range, EOL reached");
}
}
SkipSpaces(&s);
SkipSpaces(&s, mEnd);
}
return s;
}
@ -222,7 +223,7 @@ template <size_t N>
AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const {
const char* s = operator->()->c_str();
SkipSpaces(&s);
SkipSpaces(&s, mEnd);
for (size_t i = 0; i < N; ++i) {
if (IsLineEnd(*s)) {
throw std::range_error("Token count out of range, EOL reached");
@ -230,7 +231,7 @@ AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const {
tokens[i] = s;
for (; *s && !IsSpace(*s); ++s);
SkipSpaces(&s);
SkipSpaces(&s, mEnd);
}
}
@ -242,6 +243,10 @@ AI_FORCE_INLINE std::string LineSplitter::operator* () const {
return mCur;
}
AI_FORCE_INLINE const char* LineSplitter::getEnd() const {
return mEnd;
}
AI_FORCE_INLINE LineSplitter::operator bool() const {
return mStream.GetRemainingSize() > 0;
}

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
/// @brief Logger class, which will extend the class by log-functions.
/// @tparam TDeriving
/// @tparam TDeriving
template<class TDeriving>
class LogFunctions {
public:

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

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.
@ -66,23 +65,21 @@ namespace Assimp {
// ----------------------------------------------------------------------------------
class MemoryIOStream : public IOStream {
public:
MemoryIOStream (const uint8_t* buff, size_t len, bool own = false)
: buffer (buff)
, length(len)
, pos((size_t)0)
, own(own) {
MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) :
buffer (buff),
length(len),
pos(static_cast<size_t>(0)),
own(own) {
// empty
}
~MemoryIOStream () {
~MemoryIOStream() override {
if(own) {
delete[] buffer;
}
}
// -------------------------------------------------------------------
// Read from stream
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) override {
ai_assert(nullptr != pvBuffer);
ai_assert(0 != pSize);
@ -95,16 +92,12 @@ public:
return cnt;
}
// -------------------------------------------------------------------
// Write to stream
size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/,size_t /*pCount*/) {
size_t Write(const void*, size_t, size_t ) override {
ai_assert(false); // won't be needed
return 0;
}
// -------------------------------------------------------------------
// Seek specific position
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) {
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override {
if (aiOrigin_SET == pOrigin) {
if (pOffset > length) {
return AI_FAILURE;
@ -124,21 +117,15 @@ public:
return AI_SUCCESS;
}
// -------------------------------------------------------------------
// Get current seek position
size_t Tell() const {
size_t Tell() const override {
return pos;
}
// -------------------------------------------------------------------
// Get size of file
size_t FileSize() const {
size_t FileSize() const override {
return length;
}
// -------------------------------------------------------------------
// Flush file contents
void Flush() {
void Flush() override{
ai_assert(false); // won't be needed
}
@ -149,24 +136,19 @@ private:
};
// ---------------------------------------------------------------------------
/** Dummy IO system to read from a memory buffer */
/// @brief Dummy IO system to read from a memory buffer.
class MemoryIOSystem : public IOSystem {
public:
/** Constructor. */
MemoryIOSystem(const uint8_t* buff, size_t len, IOSystem* io)
: buffer(buff)
, length(len)
, existing_io(io)
, created_streams() {
/// @brief Constructor.
MemoryIOSystem(const uint8_t* buff, size_t len, IOSystem* io) : buffer(buff), length(len), existing_io(io) {
// empty
}
/** Destructor. */
~MemoryIOSystem() {
}
/// @brief Destructor.
~MemoryIOSystem() override = default;
// -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */
/// @brief Tests for the existence of a file at the given path.
bool Exists(const char* pFile) const override {
if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
return true;
@ -175,24 +157,24 @@ public:
}
// -------------------------------------------------------------------
/** Returns the directory separator. */
/// @brief Returns the directory separator.
char getOsSeparator() const override {
return existing_io ? existing_io->getOsSeparator()
: '/'; // why not? it doesn't care
}
// -------------------------------------------------------------------
/** Open a new file with a given path. */
/// @brief Open a new file with a given path.
IOStream* Open(const char* pFile, const char* pMode = "rb") override {
if ( 0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
created_streams.emplace_back(new MemoryIOStream(buffer, length));
return created_streams.back();
}
return existing_io ? existing_io->Open(pFile, pMode) : NULL;
return existing_io ? existing_io->Open(pFile, pMode) : nullptr;
}
// -------------------------------------------------------------------
/** Closes the given file and releases all resources associated with it. */
/// @brief Closes the given file and releases all resources associated with it.
void Close( IOStream* pFile) override {
auto it = std::find(created_streams.begin(), created_streams.end(), pFile);
if (it != created_streams.end()) {
@ -204,36 +186,43 @@ public:
}
// -------------------------------------------------------------------
/** Compare two paths */
/// @brief Compare two paths
bool ComparePaths(const char* one, const char* second) const override {
return existing_io ? existing_io->ComparePaths(one, second) : false;
}
/// @brief Will push the directory.
bool PushDirectory( const std::string &path ) override {
return existing_io ? existing_io->PushDirectory(path) : false;
}
/// @brief Will return the current directory from the stack top.
const std::string &CurrentDirectory() const override {
static std::string empty;
return existing_io ? existing_io->CurrentDirectory() : empty;
}
/// @brief Returns the stack size.
size_t StackSize() const override {
return existing_io ? existing_io->StackSize() : 0;
}
/// @brief Will pop the upper directory.
bool PopDirectory() override {
return existing_io ? existing_io->PopDirectory() : false;
}
/// @brief Will create the directory.
bool CreateDirectory( const std::string &path ) override {
return existing_io ? existing_io->CreateDirectory(path) : false;
}
/// @brief Will change the directory.
bool ChangeDirectory( const std::string &path ) override {
return existing_io ? existing_io->ChangeDirectory(path) : false;
}
/// @brief Will delete the file.
bool DeleteFile( const std::string &file ) override {
return existing_io ? existing_io->DeleteFile(file) : false;
}
@ -247,4 +236,4 @@ private:
} // end namespace Assimp
#endif
#endif // AI_MEMORYIOSTREAM_H_INC

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file OBJMATERIAL.h
* @brief Obj-specific material macros
*
*
*/
#ifndef AI_OBJMATERIAL_H_INC
@ -64,7 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Pure key names for all obj texture-related properties
//! @cond MATS_DOC_FULL
// support for bump -bm
// support for bump -bm
#define _AI_MATKEY_OBJ_BUMPMULT_BASE "$tex.bumpmult"
//! @endcond

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -70,7 +70,6 @@ namespace Assimp {
static const unsigned int BufferSize = 4096;
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool IsUpper(char_t in) {
@ -103,8 +102,8 @@ AI_FORCE_INLINE bool IsSpaceOrNewLine(char_t in) {
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out) {
while (*in == (char_t)' ' || *in == (char_t)'\t') {
AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out, const char_t *end) {
while ((*in == (char_t)' ' || *in == (char_t)'\t') && in != end) {
++in;
}
*out = in;
@ -113,19 +112,19 @@ AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out) {
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipSpaces(const char_t **inout) {
return SkipSpaces<char_t>(*inout, inout);
AI_FORCE_INLINE bool SkipSpaces(const char_t **inout, const char_t *end) {
return SkipSpaces<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out) {
while (*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') {
AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out, const char_t *end) {
while ((*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') && in != end) {
++in;
}
// files are opened in binary mode. Ergo there are both NL and CR
while (*in == (char_t)'\r' || *in == (char_t)'\n') {
while ((*in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
++in;
}
*out = in;
@ -134,14 +133,14 @@ AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out) {
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipLine(const char_t **inout) {
return SkipLine<char_t>(*inout, inout);
AI_FORCE_INLINE bool SkipLine(const char_t **inout, const char_t *end) {
return SkipLine<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out) {
while (*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') {
AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out, const char_t *end) {
while ((*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
++in;
}
*out = in;
@ -150,8 +149,8 @@ AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out)
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t **inout) {
return SkipSpacesAndLineEnd<char_t>(*inout, inout);
AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t **inout, const char_t *end) {
return SkipSpacesAndLineEnd<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
@ -211,16 +210,16 @@ AI_FORCE_INLINE bool TokenMatchI(const char *&in, const char *token, unsigned in
}
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE void SkipToken(const char *&in) {
SkipSpaces(&in);
AI_FORCE_INLINE void SkipToken(const char *&in, const char *end) {
SkipSpaces(&in, end);
while (!IsSpaceOrNewLine(*in)) {
++in;
}
}
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string GetNextToken(const char *&in) {
SkipSpacesAndLineEnd(&in);
AI_FORCE_INLINE std::string GetNextToken(const char *&in, const char *end) {
SkipSpacesAndLineEnd(&in, end);
const char *cur = in;
while (!IsSpaceOrNewLine(*in)) {
++in;

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -68,9 +68,7 @@ using namespace Formatter;
*/
class Profiler {
public:
Profiler() {
// empty
}
Profiler() = default;
/** Start a named timer */

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -67,15 +67,11 @@ class ASSIMP_API ProgressHandler
{
protected:
/// @brief Default constructor
ProgressHandler () AI_NO_EXCEPT {
// empty
}
ProgressHandler () AI_NO_EXCEPT = default;
public:
/// @brief Virtual destructor.
virtual ~ProgressHandler () {
// empty
}
virtual ~ProgressHandler () = default;
// -------------------------------------------------------------------
/** @brief Progress callback.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

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.
@ -63,10 +62,8 @@ namespace Assimp {
* implementation to handle all details of its file format correctly.
*/
// ----------------------------------------------------------------------------------
class ASSIMP_API SGSpatialSort
{
class ASSIMP_API SGSpatialSort {
public:
SGSpatialSort();
// -------------------------------------------------------------------
@ -90,7 +87,7 @@ public:
void Prepare();
/** Destructor */
~SGSpatialSort();
~SGSpatialSort() = default;
// -------------------------------------------------------------------
/** Returns an iterator for all positions close to the given position.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -191,13 +191,9 @@ struct SceneHelper {
*/
class ASSIMP_API SceneCombiner {
// class cannot be instanced
SceneCombiner() {
// empty
}
SceneCombiner() = delete;
~SceneCombiner() {
// empty
}
~SceneCombiner() = delete;
public:
// -------------------------------------------------------------------

View file

@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -79,7 +79,7 @@ public:
unsigned int pElementOffset);
/** Destructor */
~SpatialSort();
~SpatialSort() = default;
// ------------------------------------------------------------------------------------
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
@ -162,7 +162,7 @@ protected:
unsigned int mIndex; ///< The vertex referred by this entry
aiVector3D mPosition; ///< Position
/// Distance of this vertex to the sorting plane. This is set by Finalize.
ai_real mDistance;
ai_real mDistance;
Entry() AI_NO_EXCEPT
: mIndex(std::numeric_limits<unsigned int>::max()),

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -68,7 +68,7 @@ namespace Assimp {
*
* XXX switch from unsigned int for size types to size_t? or ptrdiff_t?*/
// --------------------------------------------------------------------------------------------
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
template <bool SwapEndianness = false, bool RuntimeSwitch = false>
class StreamReader {
public:
using diff = size_t;
@ -84,7 +84,7 @@ public:
* reads from the current position to the end of the stream.
* @param le If @c RuntimeSwitch is true: specifies whether the
* stream is in little endian byte order. Otherwise the
* endianness information is contained in the @c SwapEndianess
* endianness information is contained in the @c SwapEndianness
* template parameter and this parameter is meaningless. */
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
mStream(stream),
@ -291,7 +291,7 @@ public:
T f;
::memcpy(&f, mCurrent, sizeof(T));
Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
Intern::Getter<SwapEndianness, T, RuntimeSwitch>()(&f, mLe);
mCurrent += sizeof(T);
return f;

View file

@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -67,9 +65,8 @@ namespace Assimp {
* stream is to be determined at runtime.
*/
// --------------------------------------------------------------------------------------------
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
class StreamWriter
{
template <bool SwapEndianness = false, bool RuntimeSwitch = false>
class StreamWriter {
enum {
INITIAL_CAPACITY = 1024
};
@ -85,7 +82,7 @@ public:
continues at the current position of the stream cursor.
* @param le If @c RuntimeSwitch is true: specifies whether the
* stream is in little endian byte order. Otherwise the
* endianness information is defined by the @c SwapEndianess
* endianness information is defined by the @c SwapEndianness
* template parameter and this parameter is meaningless. */
StreamWriter(std::shared_ptr<IOStream> stream, bool le = false)
: stream(stream)
@ -263,7 +260,7 @@ public:
/** Generic write method. ByteSwap::Swap(T*) *must* be defined */
template <typename T>
void Put(T f) {
Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f, le);
Intern :: Getter<SwapEndianness,T,RuntimeSwitch>() (&f, le);
if (cursor + sizeof(T) >= buffer.size()) {
buffer.resize(cursor + sizeof(T));

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -57,7 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma GCC system_header
#endif
#include <assimp/StringComparison.h>
#include <assimp/ai_assert.h>
#include <assimp/defs.h>

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -56,10 +56,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <iomanip>
#ifdef _MSC_VER
#define AI_SIZEFMT "%Iu"
#if defined(_MSC_VER) && !defined(__clang__)
# define AI_SIZEFMT "%Iu"
#else
#define AI_SIZEFMT "%zu"
# define AI_SIZEFMT "%zu"
#endif
// ---------------------------------------------------------------------------------
@ -99,9 +99,9 @@ inline int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
}
#elif defined(__MINGW32__)
#define ai_snprintf __mingw_snprintf
# define ai_snprintf __mingw_snprintf
#else
#define ai_snprintf snprintf
# define ai_snprintf snprintf
#endif
// ---------------------------------------------------------------------------------
@ -185,6 +185,7 @@ AI_FORCE_INLINE std::string ai_rgba2hex(int r, int g, int b, int a, bool with_he
// ---------------------------------------------------------------------------------
/// @brief Performs a trim from start (in place)
/// @param s string to trim.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE void ai_trim_left(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
@ -195,7 +196,6 @@ AI_FORCE_INLINE void ai_trim_left(std::string &s) {
/// @brief Performs a trim from end (in place).
/// @param s string to trim.
// ---------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE void ai_trim_right(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
@ -214,6 +214,10 @@ AI_FORCE_INLINE std::string ai_trim(std::string &s) {
return out;
}
// ---------------------------------------------------------------------------------
/// @brief Performs a to lower operation onto on single character.
/// @param in The character
/// @return the character as lower-case.
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE char_t ai_tolower(char_t in) {
@ -233,6 +237,10 @@ AI_FORCE_INLINE std::string ai_tolower(const std::string &in) {
return out;
}
// ---------------------------------------------------------------------------------
/// @brief Performs a to upper operation onto on single character.
/// @param in The character
/// @return the character as upper-case.
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE char_t ai_toupper(char_t in) {
@ -243,6 +251,7 @@ AI_FORCE_INLINE char_t ai_toupper(char_t in) {
/// @brief Performs a ToLower-operation and return the upper-case string.
/// @param in The incoming string.
/// @return The string as uppercase.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
std::string out(in);
std::transform(out.begin(), out.end(), out.begin(), [](char c) { return ai_toupper(c); });
@ -255,6 +264,7 @@ AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
/// @param in The incoming string.
/// @param placeholder Placeholder character, default is a question mark.
/// @return The string, with all non-printable characters replaced.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char placeholder = '?') {
std::string out(in);
std::transform(out.begin(), out.end(), out.begin(), [placeholder] (unsigned char c) {
@ -271,9 +281,9 @@ AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char place
/// @param placeholder Placeholder character, default is a question mark.
/// @return The string, with all non-printable characters replaced. Will return an
/// empty string if in is null or len is <= 0.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toprintable(const char *in, int len, char placeholder = '?') {
return (in && len > 0) ? ai_str_toprintable(std::string(in, len), placeholder) : std::string();
}
#endif // INCLUDED_AI_STRINGUTILS_H

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

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.
@ -61,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <functional>
namespace Assimp {
namespace Assimp {
///////////////////////////////////////////////////////////////////////////
// std::plus-family operates on operands with identical types - we need to
@ -97,15 +96,22 @@ namespace Assimp {
* to *all* vertex components equally. This is useful for stuff like interpolation
* or subdivision, but won't work if special handling is required for some vertex components. */
// ------------------------------------------------------------------------------------------------
class Vertex {
struct Vertex {
friend Vertex operator + (const Vertex&,const Vertex&);
friend Vertex operator - (const Vertex&,const Vertex&);
friend Vertex operator * (const Vertex&,ai_real);
friend Vertex operator / (const Vertex&,ai_real);
friend Vertex operator * (ai_real, const Vertex&);
public:
Vertex() {}
aiVector3D position;
aiVector3D normal;
aiVector3D tangent, bitangent;
aiVector3D texcoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
aiColor4D colors[AI_MAX_NUMBER_OF_COLOR_SETS];
Vertex() = default;
~Vertex() = default;
// ----------------------------------------------------------------------------
/** Extract a particular vertex from a mesh and interleave all components */
@ -177,8 +183,31 @@ public:
return *this;
}
bool operator < (const Vertex & o) const {
if (position < o.position) return true;
if (position != o.position) return false;
if (normal < o.normal) return true;
if (normal != o.normal) return false;
for (uint32_t i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i ++) {
if (texcoords[i] < o.texcoords[i]) return true;
if (texcoords[i] != o.texcoords[i]) return false;
}
// note that tangent/bitangent are not checked since they are optional
for (uint32_t i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; i ++) {
if (colors[i] < o.colors[i]) return true;
if (colors[i] != o.colors[i]) return false;
}
// if reached this point, they are equal
return false;
}
// ----------------------------------------------------------------------------
/** Convert back to non-interleaved storage */
/// Convert back to non-interleaved storage
void SortBack(aiMesh* out, unsigned int idx) const {
ai_assert(idx<out->mNumVertices);
out->mVertices[idx] = position;
@ -204,7 +233,7 @@ public:
private:
// ----------------------------------------------------------------------------
/** Construct from two operands and a binary operation to combine them */
/// Construct from two operands and a binary operation to combine them
template <template <typename t> class op> static Vertex BinaryOp(const Vertex& v0, const Vertex& v1) {
// this is a heavy task for the compiler to optimize ... *pray*
@ -224,8 +253,9 @@ private:
}
// ----------------------------------------------------------------------------
/** This time binary arithmetic of v0 with a floating-point number */
template <template <typename, typename, typename> class op> static Vertex BinaryOp(const Vertex& v0, ai_real f) {
/// This time binary arithmetic of v0 with a floating-point number
template <template <typename, typename, typename> class op>
static Vertex BinaryOp(const Vertex& v0, ai_real f) {
// this is a heavy task for the compiler to optimize ... *pray*
Vertex res;
@ -238,14 +268,15 @@ private:
res.texcoords[i] = op<aiVector3D,ai_real,aiVector3D>()(v0.texcoords[i],f);
}
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
res.colors[i] = op<aiColor4D,ai_real,aiColor4D>()(v0.colors[i],f);
res.colors[i] = op<aiColor4D,float, aiColor4D>()(v0.colors[i],f);
}
return res;
}
// ----------------------------------------------------------------------------
/** This time binary arithmetic of v0 with a floating-point number */
template <template <typename, typename, typename> class op> static Vertex BinaryOp(ai_real f, const Vertex& v0) {
template <template <typename, typename, typename> class op>
static Vertex BinaryOp(ai_real f, const Vertex& v0) {
// this is a heavy task for the compiler to optimize ... *pray*
Vertex res;
@ -258,19 +289,10 @@ private:
res.texcoords[i] = op<ai_real,aiVector3D,aiVector3D>()(f,v0.texcoords[i]);
}
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
res.colors[i] = op<ai_real,aiColor4D,aiColor4D>()(f,v0.colors[i]);
res.colors[i] = op<float, aiColor4D,aiColor4D>()(f,v0.colors[i]);
}
return res;
}
public:
aiVector3D position;
aiVector3D normal;
aiVector3D tangent, bitangent;
aiVector3D texcoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
aiColor4D colors[AI_MAX_NUMBER_OF_COLOR_SETS];
};
// ------------------------------------------------------------------------------------------------

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -43,19 +43,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_IRRXML_WRAPPER
#include <assimp/ai_assert.h>
#include <assimp/StringUtils.h>
#include <assimp/DefaultLogger.hpp>
#include "BaseImporter.h"
#include "IOStream.hpp"
#include <pugixml.hpp>
#include <utility>
#include <vector>
namespace Assimp {
/// @brief Will find a node by its name.
struct find_node_by_name_predicate {
std::string mName;
/// @brief The default constructor.
find_node_by_name_predicate() = default;
std::string mName; ///< The name to find.
find_node_by_name_predicate(const std::string &name) :
mName(name) {
// empty
@ -67,7 +73,7 @@ struct find_node_by_name_predicate {
};
/// @brief Will convert an attribute to its int value.
/// @tparam TNodeType The node type.
/// @tparam[in] TNodeType The node type.
template <class TNodeType>
struct NodeConverter {
public:
@ -108,17 +114,17 @@ public:
void clear();
/// @brief Will search for a child-node by its name
/// @param name [in] The name of the child-node.
/// @param[in] name The name of the child-node.
/// @return The node instance or nullptr, if nothing was found.
TNodeType *findNode(const std::string &name);
/// @brief Will return true, if the node is a child-node.
/// @param name [in] The name of the child node to look for.
/// @param[in] name The name of the child node to look for.
/// @return true, if the node is a child-node or false if not.
bool hasNode(const std::string &name);
/// @brief Will parse an xml-file from a given stream.
/// @param stream The input stream.
/// @param[in] stream The input stream.
/// @return true, if the parsing was successful, false if not.
bool parse(IOStream *stream);
@ -139,87 +145,93 @@ public:
TNodeType getRootNode();
/// @brief Will check if a node with the given name is in.
/// @param node [in] The node to look in.
/// @param name [in] The name of the child-node.
/// @param[in] node The node to look in.
/// @param[in] name The name of the child-node.
/// @return true, if node was found, false if not.
static inline bool hasNode(XmlNode &node, const char *name);
/// @brief Will check if an attribute is part of the XmlNode.
/// @param xmlNode [in] The node to search in.
/// @param name [in} The attribute name to look for.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @return true, if the was found, false if not.
static inline bool hasAttribute(XmlNode &xmlNode, const char *name);
/// @brief Will try to get an unsigned int attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The unsigned int value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The unsigned int value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is an unsigned int.
static inline bool getUIntAttribute(XmlNode &xmlNode, const char *name, unsigned int &val);
/// @brief Will try to get an int attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The int value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The int value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is an int.
static inline bool getIntAttribute(XmlNode &xmlNode, const char *name, int &val);
/// @brief Will try to get a real attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The real value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The real value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a real.
static inline bool getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val);
/// @brief Will try to get a float attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The float value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The float value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a float.
static inline bool getFloatAttribute(XmlNode &xmlNode, const char *name, float &val);
/// @brief Will try to get a double attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The double value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The double value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a double.
static inline bool getDoubleAttribute(XmlNode &xmlNode, const char *name, double &val);
/// @brief Will try to get a std::string attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The std::string value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The std::string value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a std::string.
static inline bool getStdStrAttribute(XmlNode &xmlNode, const char *name, std::string &val);
/// @brief Will try to get a bool attribute value.
/// @param xmlNode [in] The node to search in.
/// @param name [in] The attribute name to look for.
/// @param val [out] The bool value from the attribute.
/// @param[in] xmlNode The node to search in.
/// @param[in] name The attribute name to look for.
/// @param[out] val The bool value from the attribute.
/// @return true, if the node contains an attribute with the given name and if the value is a bool.
static inline bool getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val);
/// @brief Will try to get the value of the node as a string.
/// @param node [in] The node to search in.
/// @param text [out] The value as a text.
/// @param[in] node The node to search in.
/// @param[out] text The value as a text.
/// @return true, if the value can be read out.
static inline bool getValueAsString(XmlNode &node, std::string &text);
/// @brief Will try to get the value of the node as a float.
/// @param node [in] The node to search in.
/// @param text [out] The value as a float.
/// @brief Will try to get the value of the node as a real.
/// @param[in] node The node to search in.
/// @param[out] v The value as a ai_real.
/// @return true, if the value can be read out.
static inline bool getValueAsFloat(XmlNode &node, ai_real &v);
static inline bool getValueAsReal(XmlNode &node, ai_real &v);
/// @brief Will try to get the value of the node as a float.
/// @param[in] node The node to search in.
/// @param[out]v The value as a float.
/// @return true, if the value can be read out.
static inline bool getValueAsFloat(XmlNode &node, float &v);
/// @brief Will try to get the value of the node as an integer.
/// @param node [in] The node to search in.
/// @param text [out] The value as a int.
/// @param[in] node The node to search in.
/// @param[out] i The value as a int.
/// @return true, if the value can be read out.
static inline bool getValueAsInt(XmlNode &node, int &v);
/// @brief Will try to get the value of the node as an bool.
/// @param node [in] The node to search in.
/// @param text [out] The value as a bool.
/// @param[in] node The node to search in.
/// @param[out] v The value as a bool.
/// @return true, if the value can be read out.
static inline bool getValueAsBool(XmlNode &node, bool &v);
@ -267,7 +279,7 @@ inline TNodeType *TXmlParser<TNodeType>::findNode(const std::string &name) {
}
find_node_by_name_predicate predicate(name);
mCurrent = mDoc->find_node(predicate);
mCurrent = mDoc->find_node(std::move(predicate));
if (mCurrent.empty()) {
return nullptr;
}
@ -297,7 +309,9 @@ bool TXmlParser<TNodeType>::parse(IOStream *stream) {
stream->Read(&mData[0], 1, len);
mDoc = new pugi::xml_document();
pugi::xml_parse_result parse_result = mDoc->load_string(&mData[0], pugi::parse_full);
// load_string assumes native encoding (aka always utf-8 per build options)
//pugi::xml_parse_result parse_result = mDoc->load_string(&mData[0], pugi::parse_full);
pugi::xml_parse_result parse_result = mDoc->load_buffer(&mData[0], mData.size(), pugi::parse_full);
if (parse_result.status == pugi::status_ok) {
return true;
}
@ -440,12 +454,25 @@ inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &
}
text = node.text().as_string();
text = ai_trim(text);
return true;
}
template <class TNodeType>
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, ai_real &v) {
inline bool TXmlParser<TNodeType>::getValueAsReal(XmlNode& node, ai_real& v) {
if (node.empty()) {
return false;
}
v = node.text().as_float();
return true;
}
template <class TNodeType>
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, float &v) {
if (node.empty()) {
return false;
}

View file

@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -55,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
#include <zlib.h>
namespace Assimp {
@ -63,7 +62,7 @@ public:
//! Open a Zip using the proffered IOSystem
ZipArchiveIOSystem(IOSystem* pIOHandler, const char *pFilename, const char* pMode = "r");
ZipArchiveIOSystem(IOSystem* pIOHandler, const std::string& rFilename, const char* pMode = "r");
virtual ~ZipArchiveIOSystem();
virtual ~ZipArchiveIOSystem() override;
bool Exists(const char* pFilename) const override;
char getOsSeparator() const override;
IOStream* Open(const char* pFilename, const char* pMode = "rb") override;

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -50,8 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/vector3.h>
// ---------------------------------------------------------------------------
/**
* An axis-aligned bounding box.
/**
* An axis-aligned bounding box.
*/
struct aiAABB {
C_STRUCT aiVector3D mMin;
@ -59,18 +59,12 @@ struct aiAABB {
#ifdef __cplusplus
/// @brief The default class constructor.
aiAABB() :
mMin(), mMax() {
// empty
}
aiAABB() = default;
/// @brief The class constructor with the minimum and maximum.
/// @param min The minimum dimension.
/// @param max The maximum dimension.
aiAABB(const aiVector3D &min, const aiVector3D &max) :
mMin(min), mMax(max) {
// empty
}
aiAABB(const aiVector3D &min, const aiVector3D &max) : mMin(min), mMax(max) {}
/// @brief The class destructor.
~aiAABB() = default;

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -55,7 +55,7 @@ namespace Assimp {
/// @brief Assert violation behavior can be customized: see AssertHandler.h.
/// @param failedExpression The expression to validate.
/// @param file The file location
/// @param file The file location
/// @param line The line number
ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line);

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -59,6 +59,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extern "C" {
#endif
// ---------------------------------------------------------------------------
/**
*/
enum aiAnimInterpolation {
/** */
aiAnimInterpolation_Step,
/** */
aiAnimInterpolation_Linear,
/** */
aiAnimInterpolation_Spherical_Linear,
/** */
aiAnimInterpolation_Cubic_Spline,
/** */
#ifndef SWIG
_aiAnimInterpolation_Force32Bit = INT_MAX
#endif
};
// ---------------------------------------------------------------------------
/** A time-value pair specifying a certain 3D vector for the given time. */
struct aiVectorKey {
@ -68,21 +90,18 @@ struct aiVectorKey {
/** The value of this key */
C_STRUCT aiVector3D mValue;
/** The interpolation setting of this key */
C_ENUM aiAnimInterpolation mInterpolation;
#ifdef __cplusplus
/// @brief The default constructor.
aiVectorKey() AI_NO_EXCEPT
: mTime(0.0),
mValue() {
// empty
}
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
/// @brief Construction from a given time and key value.
aiVectorKey(double time, const aiVector3D &value) :
mTime(time), mValue(value) {
// empty
}
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear){}
typedef aiVector3D elem_type;
@ -90,6 +109,7 @@ struct aiVectorKey {
bool operator==(const aiVectorKey &rhs) const {
return rhs.mValue == this->mValue;
}
bool operator!=(const aiVectorKey &rhs) const {
return rhs.mValue != this->mValue;
}
@ -98,7 +118,7 @@ struct aiVectorKey {
bool operator<(const aiVectorKey &rhs) const {
return mTime < rhs.mTime;
}
bool operator>(const aiVectorKey &rhs) const {
return mTime > rhs.mTime;
}
@ -115,16 +135,16 @@ struct aiQuatKey {
/** The value of this key */
C_STRUCT aiQuaternion mValue;
/** The interpolation setting of this key */
C_ENUM aiAnimInterpolation mInterpolation;
#ifdef __cplusplus
aiQuatKey() AI_NO_EXCEPT
: mTime(0.0),
mValue() {
// empty
}
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
/** Construction from a given time and key value */
aiQuatKey(double time, const aiQuaternion &value) :
mTime(time), mValue(value) {}
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear) {}
typedef aiQuaternion elem_type;
@ -132,7 +152,7 @@ struct aiQuatKey {
bool operator==(const aiQuatKey &rhs) const {
return rhs.mValue == this->mValue;
}
bool operator!=(const aiQuatKey &rhs) const {
return rhs.mValue != this->mValue;
}
@ -141,7 +161,7 @@ struct aiQuatKey {
bool operator<(const aiQuatKey &rhs) const {
return mTime < rhs.mTime;
}
bool operator>(const aiQuatKey &rhs) const {
return mTime > rhs.mTime;
}
@ -198,7 +218,10 @@ struct aiMeshMorphKey {
/** The time of this key */
double mTime;
/** The values and weights at the time of this key */
/** The values and weights at the time of this key
* - mValues: index of attachment mesh to apply weight at the same position in mWeights
* - mWeights: weight to apply to the blend shape index at the same position in mValues
*/
unsigned int *mValues;
double *mWeights;

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -58,6 +58,7 @@ extern "C" {
#endif
struct aiScene;
struct aiTexture;
struct aiFileIO;
typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */);
@ -373,6 +374,13 @@ ASSIMP_API void aiGetMemoryRequirements(
const C_STRUCT aiScene *pIn,
C_STRUCT aiMemoryInfo *in);
// --------------------------------------------------------------------------------
/** Returns an embedded texture, or nullptr.
* @param pIn Input asset.
* @param filename Texture path extracted from aiGetMaterialString.
*/
ASSIMP_API const C_STRUCT aiTexture *aiGetEmbeddedTexture(const C_STRUCT aiScene *pIn, const char *filename);
// --------------------------------------------------------------------------------
/** Create an empty property store. Property stores are used to collect import
* settings.
@ -644,14 +652,14 @@ ASSIMP_API void aiVector2DivideByVector(
/** Get the length of a 2D vector.
* @return v Vector to evaluate
*/
ASSIMP_API float aiVector2Length(
ASSIMP_API ai_real aiVector2Length(
const C_STRUCT aiVector2D *v);
// --------------------------------------------------------------------------------
/** Get the squared length of a 2D vector.
* @return v Vector to evaluate
*/
ASSIMP_API float aiVector2SquareLength(
ASSIMP_API ai_real aiVector2SquareLength(
const C_STRUCT aiVector2D *v);
// --------------------------------------------------------------------------------
@ -667,7 +675,7 @@ ASSIMP_API void aiVector2Negate(
* @param b Second vector
* @return The dot product of vectors
*/
ASSIMP_API float aiVector2DotProduct(
ASSIMP_API ai_real aiVector2DotProduct(
const C_STRUCT aiVector2D *a,
const C_STRUCT aiVector2D *b);
@ -774,14 +782,14 @@ ASSIMP_API void aiVector3DivideByVector(
/** Get the length of a 3D vector.
* @return v Vector to evaluate
*/
ASSIMP_API float aiVector3Length(
ASSIMP_API ai_real aiVector3Length(
const C_STRUCT aiVector3D *v);
// --------------------------------------------------------------------------------
/** Get the squared length of a 3D vector.
* @return v Vector to evaluate
*/
ASSIMP_API float aiVector3SquareLength(
ASSIMP_API ai_real aiVector3SquareLength(
const C_STRUCT aiVector3D *v);
// --------------------------------------------------------------------------------
@ -797,7 +805,7 @@ ASSIMP_API void aiVector3Negate(
* @param b Second vector
* @return The dot product of vectors
*/
ASSIMP_API float aiVector3DotProduct(
ASSIMP_API ai_real aiVector3DotProduct(
const C_STRUCT aiVector3D *a,
const C_STRUCT aiVector3D *b);
@ -889,7 +897,7 @@ ASSIMP_API void aiMatrix3Inverse(
/** Get the determinant of a 3x3 matrix.
* @param mat Matrix to get the determinant from
*/
ASSIMP_API float aiMatrix3Determinant(
ASSIMP_API ai_real aiMatrix3Determinant(
const C_STRUCT aiMatrix3x3 *mat);
// --------------------------------------------------------------------------------
@ -999,7 +1007,7 @@ ASSIMP_API void aiMatrix4Inverse(
* @param mat Matrix to get the determinant from
* @return The determinant of the matrix
*/
ASSIMP_API float aiMatrix4Determinant(
ASSIMP_API ai_real aiMatrix4Determinant(
const C_STRUCT aiMatrix4x4 *mat);
// --------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -88,12 +88,12 @@ public:
TReal r, g, b, a;
}; // !struct aiColor4D
typedef aiColor4t<ai_real> aiColor4D;
typedef aiColor4t<float> aiColor4D;
#else
struct aiColor4D {
ai_real r, g, b, a;
float r, g, b, a;
};
#endif // __cplusplus

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,8 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -60,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_CONFIG_H_INC
#define AI_CONFIG_H_INC
// ###########################################################################
// LIBRARY SETTINGS
// General, global settings
@ -79,7 +77,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_CONFIG_GLOB_MEASURE_TIME \
"GLOB_MEASURE_TIME"
// ---------------------------------------------------------------------------
/** @brief Global setting to disable generation of skeleton dummy meshes
*
@ -91,34 +88,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_CONFIG_IMPORT_NO_SKELETON_MESHES \
"IMPORT_NO_SKELETON_MESHES"
# if 0 // not implemented yet
// ---------------------------------------------------------------------------
/** @brief Set Assimp's multithreading policy.
*
* This setting is ignored if Assimp was built without boost.thread
* support (ASSIMP_BUILD_NO_THREADING, which is implied by ASSIMP_BUILD_BOOST_WORKAROUND).
* Possible values are: -1 to let Assimp decide what to do, 0 to disable
* multithreading entirely and any number larger than 0 to force a specific
* number of threads. Assimp is always free to ignore this settings, which is
* merely a hint. Usually, the default value (-1) will be fine. However, if
* Assimp is used concurrently from multiple user threads, it might be useful
* to limit each Importer instance to a specific number of cores.
*
* For more information, see the @link threading Threading page@endlink.
* Property type: int, default value: -1.
*/
#define AI_CONFIG_GLOB_MULTITHREADING \
"GLOB_MULTITHREADING"
#endif
// ###########################################################################
// POST PROCESSING SETTINGS
// Various stuff to fine-tune the behavior of a specific post processing step.
// ###########################################################################
// ---------------------------------------------------------------------------
/** @brief Maximum bone count per mesh for the SplitbyBoneCount step.
*
@ -131,13 +105,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_CONFIG_PP_SBBC_MAX_BONES \
"PP_SBBC_MAX_BONES"
// default limit for bone count
#if (!defined AI_SBBC_DEFAULT_MAX_BONES)
# define AI_SBBC_DEFAULT_MAX_BONES 60
#endif
// ---------------------------------------------------------------------------
/** @brief Specifies the maximum angle that may be between two vertex tangents
* that their tangents and bi-tangents are smoothed.
@ -174,7 +146,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE \
"PP_GSN_MAX_SMOOTHING_ANGLE"
// ---------------------------------------------------------------------------
/** @brief Sets the colormap (= palette) to be used to decode embedded
* textures in MDL (Quake or 3DGS) files.
@ -254,6 +225,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION \
"PP_PTV_ROOT_TRANSFORMATION"
// ---------------------------------------------------------------------------
/** @brief Set epsilon to check the identity of the matrix 4x4.
*
* This is used by aiMatrix4x4t<TReal>::IsIdentity(const TReal epsilon).
* @note The default value is 10e-3f for backward compatibility of legacy code.
* Property type: Float.
*/
#define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON \
"CHECK_IDENTITY_MATRIX_EPSILON"
// default value for AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON
#if (!defined AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT)
# define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT 10e-3f
#endif
// ---------------------------------------------------------------------------
/** @brief Configures the #aiProcess_FindDegenerates step to
* remove degenerated primitives from the import - immediately.
@ -270,7 +256,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---------------------------------------------------------------------------
/**
* @brief Configures the #aiProcess_FindDegenerates to check the area of a
* trinagle to be greates than e-6. If this is not the case the triangle will
* triangle to be greater than e-6. If this is not the case the triangle will
* be removed if #AI_CONFIG_PP_FD_REMOVE is set to true.
*/
#define AI_CONFIG_PP_FD_CHECKAREA \
@ -541,7 +527,6 @@ enum aiComponent
#define AI_CONFIG_FAVOUR_SPEED \
"FAVOUR_SPEED"
// ###########################################################################
// IMPORTER SETTINGS
// Various stuff to fine-tune the behaviour of specific importer plugins.
@ -692,7 +677,20 @@ enum aiComponent
"AI_CONFIG_FBX_CONVERT_TO_M"
// ---------------------------------------------------------------------------
/** @brief Will enable the skeleton structo to store bone data.
/** @brief Set whether the FBX importer shall ignore the provided axis configuration
*
* If this property is set to true, the axis directions provided in the FBX file
* will be ignored and the file will be loaded as is.
*
* Set to true for Assimp 5.3.x and earlier behavior
* Equivalent to AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION \
"AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION"
// ---------------------------------------------------------------------------
/** @brief Will enable the skeleton struct to store bone data.
*
* This will decouple the bone coupling to the mesh. This feature is
* experimental.
@ -739,6 +737,12 @@ enum aiComponent
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS "IMPORT_MDL_HL1_READ_ANIMATION_EVENTS"
// ---------------------------------------------------------------------------
/** @brief Set whether you want to convert the HS1 coordinate system in a special way.
* The default value is true (S1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_TRANSFORM_COORD_SYSTEM "TRANSFORM COORDSYSTEM FOR HS! MODELS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read blend controllers.
* \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true.
@ -1065,6 +1069,15 @@ enum aiComponent
*/
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
// ---------------------------------------------------------------------------
/** @brief Specifies whether the Collada loader will ignore the provided unit size.
*
* If this property is set to true, the unit size provided in the file header will
* be ignored and the file will be loaded without scaling the assets.
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UNIT_SIZE "IMPORT_COLLADA_IGNORE_UNIT_SIZE"
// ---------------------------------------------------------------------------
/** @brief Specifies whether the Collada loader should use Collada names.
*
@ -1090,9 +1103,45 @@ enum aiComponent
* Point clouds are only a collection of vertices which have nor spatial organization
* by a face and the validation process will remove them. Enabling this feature will
* switch off the flag and enable the functionality to export pure point clouds.
*
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_EXPORT_POINT_CLOUDS "EXPORT_POINT_CLOUDS"
/** @brief Specifies whether to use the deprecated KHR_materials_pbrSpecularGlossiness extension
*
* When this flag is undefined any material with specularity will use the new KHR_materials_specular
* extension. Enabling this flag will revert to the deprecated extension. Note that exporting
* KHR_materials_pbrSpecularGlossiness with extensions other than KHR_materials_unlit is unsupported,
* including the basic pbrMetallicRoughness spec.
*
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_USE_GLTF_PBR_SPECULAR_GLOSSINESS "USE_GLTF_PBR_SPECULAR_GLOSSINESS"
/** @brief Specifies whether to apply a limit on the number of four bones per vertex in skinning
*
* When this flag is not defined, all bone weights and indices are limited to a
* maximum of four bones for each vertex (attributes JOINT_0 and WEIGHT_0 only).
* By enabling this flag, the number of bones per vertex is unlimited.
* In both cases, indices and bone weights are sorted by weight in descending order.
* In the case of the limit of up to four bones, a maximum of the four largest values are exported.
* Weights are not normalized.
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX \
"USE_UNLIMITED_BONES_PER VERTEX"
/** @brief Specifies whether to write the value referenced to opacity in TransparencyFactor of each material.
*
* When this flag is not defined, the TransparencyFactor value of each meterial is 1.0.
* By enabling this flag, the value is 1.0 - opacity;
* Property type: Bool. Default value: false.
*/
#define AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY \
"EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY"
/**
* @brief Specifies the blob name, assimp uses for exporting.
*
@ -1111,7 +1160,7 @@ enum aiComponent
#define AI_CONFIG_EXPORT_BLOB_NAME "EXPORT_BLOB_NAME"
/**
* @brief Specifies a gobal key factor for scale, float value
* @brief Specifies a global key factor for scale, float value
*/
#define AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY "GLOBAL_SCALE_FACTOR"

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -49,14 +49,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_DEFINES_H_INC
#ifdef __GNUC__
#pragma GCC system_header
# pragma GCC system_header
#endif
#include <assimp/config.h>
//////////////////////////////////////////////////////////////////////////
/* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific
* file format loader. The loader is be excluded from the
/**
* @brief Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific file format loader.
*
* The loader is be excluded from the
* build in this case. 'XX' stands for the most common file
* extension of the file format. E.g.:
* ASSIMP_BUILD_NO_X_IMPORTER disables the X loader.
@ -76,34 +78,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//////////////////////////////////////////////////////////////////////////
#ifndef ASSIMP_BUILD_NO_COMPRESSED_X
#define ASSIMP_BUILD_NEED_Z_INFLATE
# define ASSIMP_BUILD_NEED_Z_INFLATE
#endif
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
#define ASSIMP_BUILD_NEED_Z_INFLATE
# define ASSIMP_BUILD_NEED_Z_INFLATE
#endif
#ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC
#define ASSIMP_BUILD_NEED_Z_INFLATE
#define ASSIMP_BUILD_NEED_UNZIP
# define ASSIMP_BUILD_NEED_Z_INFLATE
# define ASSIMP_BUILD_NEED_UNZIP
#endif
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
#define ASSIMP_BUILD_NEED_Z_INFLATE
#define ASSIMP_BUILD_NEED_UNZIP
# define ASSIMP_BUILD_NEED_Z_INFLATE
# define ASSIMP_BUILD_NEED_UNZIP
#endif
// We need those constants, workaround for any platforms where nobody defined them yet
/**
* @brief We need those constants, workaround for any platforms where nobody defined them yet.
*/
#if (!defined SIZE_MAX)
#define SIZE_MAX (~((size_t)0))
# define SIZE_MAX (~((size_t)0))
#endif
/*#if (!defined UINT_MAX)
#define UINT_MAX (~((unsigned int)0))
#endif*/
//////////////////////////////////////////////////////////////////////////
/* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
/** @brief Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
*
* post processing step. This is the current list of process names ('XX'):
* CALCTANGENTS
* JOINVERTICES
@ -134,46 +135,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OPTIMIZEGRAPH
* GENENTITYMESHES
* FIXTEXTUREPATHS
* GENBOUNDINGBOXES */
//////////////////////////////////////////////////////////////////////////
* GENBOUNDINGBOXES
*/
//////////////////////////////////////////////////////////////////////////
/** @brief Define 'ASSIMP_BUILD_DLL_EXPORT' to build a DLL of the library
*
* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
* an external DLL under Windows. Default is static linkage.
*/
//////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#undef ASSIMP_API
//////////////////////////////////////////////////////////////////////////
/* Define 'ASSIMP_BUILD_DLL_EXPORT' to build a DLL of the library */
//////////////////////////////////////////////////////////////////////////
#ifdef ASSIMP_BUILD_DLL_EXPORT
#define ASSIMP_API __declspec(dllexport)
#define ASSIMP_API_WINONLY __declspec(dllexport)
//////////////////////////////////////////////////////////////////////////
/* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
* an external DLL under Windows. Default is static linkage. */
//////////////////////////////////////////////////////////////////////////
#elif (defined ASSIMP_DLL)
#define ASSIMP_API __declspec(dllimport)
#define ASSIMP_API_WINONLY __declspec(dllimport)
#else
#define ASSIMP_API
#define ASSIMP_API_WINONLY
#endif
#elif defined(SWIG)
/* Do nothing, the relevant defines are all in AssimpSwigPort.i */
#else
#define ASSIMP_API __attribute__((visibility("default")))
#define ASSIMP_API_WINONLY
# undef ASSIMP_API
# ifdef ASSIMP_BUILD_DLL_EXPORT
# define ASSIMP_API __declspec(dllexport)
# define ASSIMP_API_WINONLY __declspec(dllexport)
# elif (defined ASSIMP_DLL)
# define ASSIMP_API __declspec(dllimport)
# define ASSIMP_API_WINONLY __declspec(dllimport)
# else
# define ASSIMP_API
# define ASSIMP_API_WINONLY
# endif
#else
# define ASSIMP_API __attribute__((visibility("default")))
# define ASSIMP_API_WINONLY
#endif // _WIN32
/**
* @brief Helper macros
*
* @def AI_FORCE_INLINE
* @brief Force the compiler to inline a function, if possible
*
* @def AI_WONT_RETURN
* @brief Tells the compiler that a function never returns.
*
* Used in code analysis to skip dead paths (e.g. after an assertion evaluated to false).
*/
#ifdef _MSC_VER
#pragma warning(disable : 4521 4512 4714 4127 4351 4510)
#ifdef ASSIMP_BUILD_DLL_EXPORT
#pragma warning(disable : 4251)
#endif
/* Force the compiler to inline a function, if possible */
#define AI_FORCE_INLINE inline
/* Tells the compiler that a function never returns. Used in code analysis
* to skip dead paths (e.g. after an assertion evaluated to false). */
#define AI_WONT_RETURN __declspec(noreturn)
#elif defined(SWIG)
/* Do nothing, the relevant defines are all in AssimpSwigPort.i */
@ -184,21 +189,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef __GNUC__
# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
#elif _MSC_VER
#if defined(__clang__)
# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
#else
# define AI_WONT_RETURN_SUFFIX
#endif
#else
# define AI_WONT_RETURN_SUFFIX
#endif // (defined __clang__)
#ifdef __cplusplus
/* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
* in doxydocs.
*/
* in doxydocs. */
#define C_STRUCT
#define C_ENUM
#else
//////////////////////////////////////////////////////////////////////////
/* To build the documentation, make sure ASSIMP_DOXYGEN_BUILD
* is defined by Doxygen's preprocessor. The corresponding
* entries in the DOXYFILE are: */
* is defined by Doxygen's preprocessor. The corresponding
* entries in the DOXYFILE are: */
//////////////////////////////////////////////////////////////////////////
#if 0
ENABLE_PREPROCESSING = YES
@ -218,34 +228,36 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* to typedef all structs/enums. */
//////////////////////////////////////////////////////////////////////////
#if (defined ASSIMP_DOXYGEN_BUILD)
#define C_STRUCT
#define C_ENUM
# define C_STRUCT
# define C_ENUM
#else
#define C_STRUCT struct
#define C_ENUM enum
# define C_STRUCT struct
# define C_ENUM enum
#endif
#endif
#if (defined(__BORLANDC__) || defined(__BCPLUSPLUS__))
#error Currently, Borland is unsupported. Feel free to port Assimp.
# error Currently, Borland is unsupported. Feel free to port Assimp.
#endif
//////////////////////////////////////////////////////////////////////////
/* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp
* without threading support. The library doesn't utilize
* threads then and is itself not threadsafe. */
/**
* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp
* without threading support. The library doesn't utilize
* threads then and is itself not threadsafe.
*/
//////////////////////////////////////////////////////////////////////////
#ifndef ASSIMP_BUILD_SINGLETHREADED
#define ASSIMP_BUILD_SINGLETHREADED
# define ASSIMP_BUILD_SINGLETHREADED
#endif
#if defined(_DEBUG) || !defined(NDEBUG)
#define ASSIMP_BUILD_DEBUG
# define ASSIMP_BUILD_DEBUG
#endif
//////////////////////////////////////////////////////////////////////////
/* Define ASSIMP_DOUBLE_PRECISION to compile assimp
* with double precision support (64-bit). */
* with double precision support (64-bit). */
//////////////////////////////////////////////////////////////////////////
#ifdef ASSIMP_DOUBLE_PRECISION
@ -283,54 +295,77 @@ typedef unsigned int ai_uint;
#define AI_RAD_TO_DEG(x) ((x) * (ai_real) 57.2957795)
/* Numerical limits */
static const ai_real ai_epsilon = (ai_real) 1e-6;
/* Support for big-endian builds */
#if defined(__BYTE_ORDER__)
#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#if !defined(__BIG_ENDIAN__)
#define __BIG_ENDIAN__
#endif
#else /* little endian */
#if defined(__BIG_ENDIAN__)
#undef __BIG_ENDIAN__
#endif
#endif
#endif
#if defined(__BIG_ENDIAN__)
#define AI_BUILD_BIG_ENDIAN
#ifdef __cplusplus
constexpr ai_real ai_epsilon = (ai_real) 1e-6;
#else
# define ai_epsilon ((ai_real)1e-6)
#endif
/**
* To avoid running out of memory
* @brief Support for big-endian builds
*
* This will check which byte ordering is used on the target architecture.
*/
#if defined(__BYTE_ORDER__)
# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
# if !defined(__BIG_ENDIAN__)
# define __BIG_ENDIAN__
# endif
# else /* little endian */
# if defined(__BIG_ENDIAN__)
# undef __BIG_ENDIAN__
# endif
# endif
#endif
#if defined(__BIG_ENDIAN__)
# define AI_BUILD_BIG_ENDIAN
#endif
/**
* @brief To avoid running out of memory
*
* This can be adjusted for specific use cases
* It's NOT a total limit, just a limit for individual allocations
*/
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
#ifndef _MSC_VER
#if __cplusplus >= 201103L // C++11
#define AI_NO_EXCEPT noexcept
# if __cplusplus >= 201103L // C++11
# define AI_NO_EXCEPT noexcept
# else
# define AI_NO_EXCEPT
# endif
#else
#define AI_NO_EXCEPT
#endif
#else
#if (_MSC_VER >= 1915)
#define AI_NO_EXCEPT noexcept
#else
#define AI_NO_EXCEPT
#endif
# if (_MSC_VER >= 1915)
# define AI_NO_EXCEPT noexcept
# else
# define AI_NO_EXCEPT
# endif
#endif // _MSC_VER
/**
* Helper macro to set a pointer to NULL in debug builds
* @brief Helper macro to set a pointer to NULL in debug builds
*/
#if (defined ASSIMP_BUILD_DEBUG)
#define AI_DEBUG_INVALIDATE_PTR(x) x = NULL;
# define AI_DEBUG_INVALIDATE_PTR(x) x = NULL;
#else
#define AI_DEBUG_INVALIDATE_PTR(x)
# define AI_DEBUG_INVALIDATE_PTR(x)
#endif
#define AI_COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
/**
* @brief Will mark functions or classes as deprecated.
*
* Deprecation means that we will remove this function, class or methods in the next m
*/
#if defined(__GNUC__) || defined(__clang__)
# define AI_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
# define AI_DEPRECATED __declspec(deprecated)
#else
# pragma message("WARNING: You need to implement DEPRECATED for this compiler")
# define AI_DEPRECATED
#endif
#endif // !! AI_DEFINES_H_INC

View file

@ -39,7 +39,9 @@
namespace Assimp {
const double fast_atof_table[16] = { // we write [16] here instead of [] to work around a swig bug
static constexpr size_t NumItems = 16;
constexpr double fast_atof_table[NumItems] = { // we write [16] here instead of [] to work around a swig bug
0.0,
0.1,
0.01,
@ -58,12 +60,10 @@ const double fast_atof_table[16] = { // we write [16] here instead of [] to wo
0.000000000000001
};
// ------------------------------------------------------------------------------------
// Convert a string in decimal format to a number
// ------------------------------------------------------------------------------------
inline
unsigned int strtoul10( const char* in, const char** out=0) {
inline unsigned int strtoul10( const char* in, const char** out=0) {
unsigned int value = 0;
for ( ;; ) {
@ -83,8 +83,7 @@ unsigned int strtoul10( const char* in, const char** out=0) {
// ------------------------------------------------------------------------------------
// Convert a string in octal format to a number
// ------------------------------------------------------------------------------------
inline
unsigned int strtoul8( const char* in, const char** out=0) {
inline unsigned int strtoul8( const char* in, const char** out=0) {
unsigned int value( 0 );
for ( ;; ) {
if ( *in < '0' || *in > '7' ) {
@ -103,8 +102,7 @@ unsigned int strtoul8( const char* in, const char** out=0) {
// ------------------------------------------------------------------------------------
// Convert a string in hex format to a number
// ------------------------------------------------------------------------------------
inline
unsigned int strtoul16( const char* in, const char** out=0) {
inline unsigned int strtoul16( const char* in, const char** out=0) {
unsigned int value( 0 );
for ( ;; ) {
if ( *in >= '0' && *in <= '9' ) {
@ -128,8 +126,7 @@ unsigned int strtoul16( const char* in, const char** out=0) {
// Convert just one hex digit
// Return value is UINT_MAX if the input character is not a hex digit.
// ------------------------------------------------------------------------------------
inline
unsigned int HexDigitToDecimal(char in) {
inline unsigned int HexDigitToDecimal(char in) {
unsigned int out( UINT_MAX );
if ( in >= '0' && in <= '9' ) {
out = in - '0';
@ -146,16 +143,14 @@ unsigned int HexDigitToDecimal(char in) {
// ------------------------------------------------------------------------------------
// Convert a hex-encoded octet (2 characters, i.e. df or 1a).
// ------------------------------------------------------------------------------------
inline
uint8_t HexOctetToDecimal(const char* in) {
inline uint8_t HexOctetToDecimal(const char* in) {
return ((uint8_t)HexDigitToDecimal(in[0])<<4)+(uint8_t)HexDigitToDecimal(in[1]);
}
// ------------------------------------------------------------------------------------
// signed variant of strtoul10
// ------------------------------------------------------------------------------------
inline
int strtol10( const char* in, const char** out=0) {
inline int strtol10( const char* in, const char** out = 0) {
bool inv = (*in=='-');
if ( inv || *in == '+' ) {
++in;
@ -163,7 +158,11 @@ int strtol10( const char* in, const char** out=0) {
int value = strtoul10(in,out);
if (inv) {
value = -value;
if (value < INT_MAX && value > INT_MIN) {
value = -value;
} else {
ASSIMP_LOG_WARN( "Converting the string \"", in, "\" into an inverted value resulted in overflow." );
}
}
return value;
}
@ -174,8 +173,7 @@ int strtol10( const char* in, const char** out=0) {
// 0NNN - oct
// NNN - dec
// ------------------------------------------------------------------------------------
inline
unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
inline unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
if ('0' == in[0]) {
return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,out);
}
@ -187,8 +185,7 @@ unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
// It is mainly used by fast_atof to prevent ugly and unwanted integer overflows.
// ------------------------------------------------------------------------------------
template<typename ExceptionType = DeadlyImportError>
inline
uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0) {
inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0) {
unsigned int cur = 0;
uint64_t value = 0;
@ -241,8 +238,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino
// signed variant of strtoul10_64
// ------------------------------------------------------------------------------------
template<typename ExceptionType = DeadlyImportError>
inline
int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inout = 0) {
inline int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inout = 0) {
bool inv = (*in == '-');
if ( inv || *in == '+' ) {
++in;
@ -264,8 +260,7 @@ int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inou
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
// ------------------------------------------------------------------------------------
template<typename Real, typename ExceptionType = DeadlyImportError>
inline
const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) {
inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) {
Real f = 0;
bool inv = (*c == '-');
@ -354,8 +349,7 @@ const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true)
// ------------------------------------------------------------------------------------
// The same but more human.
template<typename ExceptionType = DeadlyImportError>
inline
ai_real fast_atof(const char* c) {
inline ai_real fast_atof(const char* c) {
ai_real ret(0.0);
fast_atoreal_move<ai_real, ExceptionType>(c, ret);
@ -372,8 +366,7 @@ ai_real fast_atof( const char* c, const char** cout) {
}
template<typename ExceptionType = DeadlyImportError>
inline
ai_real fast_atof( const char** inout) {
inline ai_real fast_atof( const char** inout) {
ai_real ret(0.0);
*inout = fast_atoreal_move<ai_real, ExceptionType>(*inout, ret);

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -292,6 +292,14 @@ enum aiTextureType {
aiTextureType_DIFFUSE_ROUGHNESS = 16,
aiTextureType_AMBIENT_OCCLUSION = 17,
/** Unknown texture
*
* A texture reference that does not match any of the definitions
* above is considered to be 'unknown'. It is still imported,
* but is excluded from any further post-processing.
*/
aiTextureType_UNKNOWN = 18,
/** PBR Material Modifiers
* Some modern renderers have further PBR modifiers that may be overlaid
* on top of the 'base' PBR materials for additional realism.
@ -306,7 +314,7 @@ enum aiTextureType {
aiTextureType_SHEEN = 19,
/** Clearcoat
* Simulates a layer of 'polish' or 'laquer' layered on top of a PBR substrate
* Simulates a layer of 'polish' or 'lacquer' layered on top of a PBR substrate
* https://autodesk.github.io/standard-surface/#closures/coating
* https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
*/
@ -318,23 +326,28 @@ enum aiTextureType {
*/
aiTextureType_TRANSMISSION = 21,
/** Unknown texture
*
* A texture reference that does not match any of the definitions
* above is considered to be 'unknown'. It is still imported,
* but is excluded from any further post-processing.
*/
aiTextureType_UNKNOWN = 18,
/**
* Maya material declarations
*/
aiTextureType_MAYA_BASE = 22,
aiTextureType_MAYA_SPECULAR = 23,
aiTextureType_MAYA_SPECULAR_COLOR = 24,
aiTextureType_MAYA_SPECULAR_ROUGHNESS = 25,
#ifndef SWIG
_aiTextureType_Force32Bit = INT_MAX
#endif
};
#define AI_TEXTURE_TYPE_MAX aiTextureType_TRANSMISSION
#define AI_TEXTURE_TYPE_MAX aiTextureType_MAYA_SPECULAR_ROUGHNESS
// -------------------------------------------------------------------------------
// Get a string for a given aiTextureType
/**
* @brief Get a string for a given aiTextureType
*
* @param in The texture type
* @return The description string for the texture type.
*/
ASSIMP_API const char *aiTextureTypeToString(enum aiTextureType in);
// ---------------------------------------------------------------------------
@ -425,7 +438,8 @@ enum aiShadingMode {
};
// ---------------------------------------------------------------------------
/** @brief Defines some mixed flags for a particular texture.
/**
* @brief Defines some mixed flags for a particular texture.
*
* Usually you'll instruct your cg artists how textures have to look like ...
* and how they will be processed in your application. However, if you use
@ -464,7 +478,8 @@ enum aiTextureFlags {
};
// ---------------------------------------------------------------------------
/** @brief Defines alpha-blend flags.
/**
* @brief Defines alpha-blend flags.
*
* If you're familiar with OpenGL or D3D, these flags aren't new to you.
* They define *how* the final color value of a pixel is computed, basing
@ -508,7 +523,8 @@ enum aiBlendMode {
#include "./Compiler/pushpack1.h"
// ---------------------------------------------------------------------------
/** @brief Defines how an UV channel is transformed.
/**
* @brief Defines how an UV channel is transformed.
*
* This is just a helper structure for the #AI_MATKEY_UVTRANSFORM key.
* See its documentation for more details.
@ -552,8 +568,8 @@ struct aiUVTransform {
//! @cond AI_DOX_INCLUDE_INTERNAL
// ---------------------------------------------------------------------------
/** @brief A very primitive RTTI system for the contents of material
* properties.
/**
* @brief A very primitive RTTI system for the contents of material properties.
*/
enum aiPropertyTypeInfo {
/** Array of single-precision (32 Bit) floats
@ -685,7 +701,7 @@ struct aiMaterialProperty {
* Material data is stored using a key-value structure. A single key-value
* pair is called a 'material property'. C++ users should use the provided
* member functions of aiMaterial to process material properties, C users
* have to stick with the aiMaterialGetXXX family of unbound functions.
* have to stick with the aiGetMaterialXXX family of unbound functions.
* The library defines a set of standard keys (AI_MATKEY_XXX).
*/
#ifdef __cplusplus
@ -698,7 +714,14 @@ struct aiMaterial
#ifdef __cplusplus
public:
/**
* @brief The class constructor.
*/
aiMaterial();
/**
* @brief The class destructor.
*/
~aiMaterial();
// -------------------------------------------------------------------
@ -1016,7 +1039,7 @@ extern "C" {
// Clearcoat
// ---------
// Clearcoat layer intensity. 0.0 = none (disabled)
#define AI_MATKEY_CLEARCOAT_FACTOR "$mat.clearcoat.factor", 0, 0
#define AI_MATKEY_CLEARCOAT_FACTOR "$mat.clearcoat.factor", 0, 0
#define AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR "$mat.clearcoat.roughnessFactor", 0, 0
#define AI_MATKEY_CLEARCOAT_TEXTURE aiTextureType_CLEARCOAT, 0
#define AI_MATKEY_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_CLEARCOAT, 1
@ -1046,23 +1069,23 @@ extern "C" {
// Emissive
// --------
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
#define AI_MATKEY_EMISSIVE_INTENSITY "$mat.emissiveIntensity", 0, 0
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
// ---------------------------------------------------------------------------
// Pure key names for all texture-related properties
//! @cond MATS_DOC_FULL
#define _AI_MATKEY_TEXTURE_BASE "$tex.file"
#define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
#define _AI_MATKEY_TEXOP_BASE "$tex.op"
#define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
#define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
#define _AI_MATKEY_TEXTURE_BASE "$tex.file"
#define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
#define _AI_MATKEY_TEXOP_BASE "$tex.op"
#define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
#define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
#define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu"
#define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev"
#define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
#define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
#define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
#define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
//! @endcond
// ---------------------------------------------------------------------------
@ -1534,12 +1557,12 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
* @return Specifies whether the key has been found. If not, the output
* float remains unmodified.*/
// ---------------------------------------------------------------------------
inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
static inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
const char *pKey,
unsigned int type,
unsigned int index,
ai_real *pOut) {
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, NULL);
}
// ---------------------------------------------------------------------------
@ -1559,12 +1582,12 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial *
*
* See the sample for aiGetMaterialFloat for more information.*/
// ---------------------------------------------------------------------------
inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial *pMat,
static inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial *pMat,
const char *pKey,
unsigned int type,
unsigned int index,
int *pOut) {
return aiGetMaterialIntegerArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
return aiGetMaterialIntegerArray(pMat, pKey, type, index, pOut, NULL);
}
// ---------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -97,9 +97,12 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
if (prop->mType != aiPTI_Buffer) {
return AI_FAILURE;
}
// std::min has in some cases a conflict with a defined min
#ifdef min
# undef min
#endif
iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type)));
::memcpy(pOut,prop->mData,iNum * sizeof(Type));
std::memcpy(pOut,prop->mData,iNum * sizeof(Type));
if (pMax) {
*pMax = iNum;
}
@ -133,9 +136,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// Specialisation for a single bool.
// Casts floating point and integer to bool
template <>
AI_FORCE_INLINE
aiReturn
aiMaterial::Get(const char *pKey, unsigned int type,
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char *pKey, unsigned int type,
unsigned int idx, bool &pOut) const {
const aiMaterialProperty *prop;
const aiReturn ret = ::aiGetMaterialProperty(this, pKey, type, idx,
@ -190,7 +191,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
}
// ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real& pOut) const {
unsigned int idx, ai_real& pOut) const {
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
}
// ---------------------------------------------------------------------------
@ -208,7 +209,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,aiColor3D& pOut) const {
aiColor4D c;
const aiReturn ret = aiGetMaterialColor(this,pKey,type,idx,&c);
pOut = aiColor3D(c.r,c.g,c.b);
if (ret == aiReturn_SUCCESS)
pOut = aiColor3D(c.r,c.g,c.b);
return ret;
}
// ---------------------------------------------------------------------------
@ -224,8 +226,8 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// ---------------------------------------------------------------------------
template<class TYPE>
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues, const char* pKey, unsigned int type,
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
const unsigned int pNumValues, const char* pKey, unsigned int type,
unsigned int index) {
return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE),
pKey,type,index,aiPTI_Buffer);
@ -308,7 +310,6 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
pKey,type,index,aiPTI_Integer);
}
// ---------------------------------------------------------------------------
// The template specializations below are for backwards compatibility.
// The recommended way to add material properties is using the non-template

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/vector3.h>
#include <assimp/defs.h>
#include <assimp/config.h>
#ifdef __cplusplus
@ -136,9 +137,13 @@ public:
// -------------------------------------------------------------------
/** @brief Returns true of the matrix is the identity matrix.
* @param epsilon Value of epsilon. Default value is 10e-3 for backward
* compatibility with legacy code.
* @return Returns true of the matrix is the identity matrix.
* The check is performed against a not so small epsilon.
*/
inline bool IsIdentity() const;
inline bool IsIdentity(const TReal
epsilon = AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT) const;
// -------------------------------------------------------------------
/** @brief Decompose a trafo matrix into its original components

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -242,7 +242,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::Inverse() {
const TReal det = Determinant();
if(det == static_cast<TReal>(0.0))
{
// Matrix not invertible. Setting all elements to nan is not really
// Matrix is not invertible. Setting all elements to nan is not really
// correct in a mathematical sense but it is easy to debug for the
// programmer.
const TReal nan = std::numeric_limits<TReal>::quiet_NaN();
@ -545,10 +545,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::FromEulerAnglesXYZ(TReal x, TReal y, T
// ----------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
bool aiMatrix4x4t<TReal>::IsIdentity() const {
// Use a small epsilon to solve floating-point inaccuracies
const static TReal epsilon = 10e-3f;
bool aiMatrix4x4t<TReal>::IsIdentity(const TReal epsilon) const {
return (a2 <= epsilon && a2 >= -epsilon &&
a3 <= epsilon && a3 >= -epsilon &&
a4 <= epsilon && a4 >= -epsilon &&
@ -657,7 +654,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::Scaling( const aiVector3t<TReal>& v, a
/** A function for creating a rotation matrix that rotates a vector called
* "from" into another vector called "to".
* Input : from[3], to[3] which both must be *normalized* non-zero vectors
* Output: mtx[3][3] -- a 3x3 matrix in colum-major form
* Output: mtx[3][3] -- a 3x3 matrix in column-major form
* Authors: Tomas Möller, John Hughes
* "Efficiently Building a Matrix to Rotate One Vector to Another"
* Journal of Graphics Tools, 4(4):1-4, 1999

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -59,6 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/types.h>
#ifdef __cplusplus
#include <unordered_set>
extern "C" {
#endif
@ -111,7 +113,8 @@ extern "C" {
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
// ---------------------------------------------------------------------------
/** @brief A single face in a mesh, referring to multiple vertices.
/**
* @brief A single face in a mesh, referring to multiple vertices.
*
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
* it's called 'polygon' (hey, that's just a definition!).
@ -142,25 +145,25 @@ struct aiFace {
#ifdef __cplusplus
//! Default constructor
//! @brief Default constructor.
aiFace() AI_NO_EXCEPT
: mNumIndices(0),
mIndices(nullptr) {
// empty
}
//! Default destructor. Delete the index array
//! @brief Default destructor. Delete the index array
~aiFace() {
delete[] mIndices;
}
//! Copy constructor. Copy the index array
//! @brief Copy constructor. Copy the index array
aiFace(const aiFace &o) :
mNumIndices(0), mIndices(nullptr) {
*this = o;
}
//! Assignment operator. Copy the index array
//! @brief Assignment operator. Copy the index array
aiFace &operator=(const aiFace &o) {
if (&o == this) {
return *this;
@ -178,8 +181,7 @@ struct aiFace {
return *this;
}
//! Comparison operator. Checks whether the index array
//! of two faces is identical
//! @brief Comparison operator. Checks whether the index array of two faces is identical.
bool operator==(const aiFace &o) const {
if (mIndices == o.mIndices) {
return true;
@ -202,7 +204,7 @@ struct aiFace {
return true;
}
//! Inverse comparison operator. Checks whether the index
//! @brief Inverse comparison operator. Checks whether the index
//! array of two faces is NOT identical
bool operator!=(const aiFace &o) const {
return !(*this == o);
@ -223,14 +225,14 @@ struct aiVertexWeight {
#ifdef __cplusplus
//! Default constructor
//! @brief Default constructor
aiVertexWeight() AI_NO_EXCEPT
: mVertexId(0),
mWeight(0.0f) {
// empty
}
//! Initialization from a given index and vertex weight factor
//! @brief Initialization from a given index and vertex weight factor
//! \param pID ID
//! \param pWeight Vertex weight factor
aiVertexWeight(unsigned int pID, float pWeight) :
@ -261,27 +263,38 @@ struct aiNode;
* position of the bone at the time of binding.
*/
struct aiBone {
//! The name of the bone.
/**
* The name of the bone.
*/
C_STRUCT aiString mName;
//! The number of vertices affected by this bone.
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
/**
* The number of vertices affected by this bone.
* The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
*/
unsigned int mNumWeights;
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
/// The bone armature node - used for skeleton conversion
/// you must enable aiProcess_PopulateArmatureData to populate this
/**
* The bone armature node - used for skeleton conversion
* you must enable aiProcess_PopulateArmatureData to populate this
*/
C_STRUCT aiNode *mArmature;
/// The bone node in the scene - used for skeleton conversion
/// you must enable aiProcess_PopulateArmatureData to populate this
/**
* The bone node in the scene - used for skeleton conversion
* you must enable aiProcess_PopulateArmatureData to populate this
*/
C_STRUCT aiNode *mNode;
#endif
//! The influence weights of this bone, by vertex index.
/**
* The influence weights of this bone, by vertex index.
*/
C_STRUCT aiVertexWeight *mWeights;
/** Matrix that transforms from mesh space to bone space in bind pose.
/**
* Matrix that transforms from mesh space to bone space in bind pose.
*
* This matrix describes the position of the mesh
* in the local space of this bone when the skeleton was bound.
@ -338,7 +351,7 @@ struct aiBone {
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
}
//! Assignment operator
//! @brief Assignment operator
aiBone &operator = (const aiBone &other) {
if (this == &other) {
return *this;
@ -352,6 +365,7 @@ struct aiBone {
return *this;
}
/// @brief Compare operator.
bool operator==(const aiBone &rhs) const {
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
return false;
@ -365,7 +379,7 @@ struct aiBone {
return true;
}
//! Destructor - deletes the array of vertex weights
//! @brief Destructor - deletes the array of vertex weights
~aiBone() {
delete[] mWeights;
}
@ -381,27 +395,31 @@ struct aiBone {
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
*/
enum aiPrimitiveType {
/** A point primitive.
/**
* @brief A point primitive.
*
* This is just a single vertex in the virtual world,
* #aiFace contains just one index for such a primitive.
*/
aiPrimitiveType_POINT = 0x1,
/** A line primitive.
/**
* @brief A line primitive.
*
* This is a line defined through a start and an end position.
* #aiFace contains exactly two indices for such a primitive.
*/
aiPrimitiveType_LINE = 0x2,
/** A triangular primitive.
/**
* @brief A triangular primitive.
*
* A triangle consists of three indices.
*/
aiPrimitiveType_TRIANGLE = 0x4,
/** A higher-level polygon with more than 3 edges.
/**
* @brief A higher-level polygon with more than 3 edges.
*
* A triangle is a polygon, but polygon in this context means
* "all polygons that are not triangles". The "Triangulate"-Step
@ -411,7 +429,7 @@ enum aiPrimitiveType {
aiPrimitiveType_POLYGON = 0x8,
/**
* A flag to determine whether this triangles only mesh is NGON encoded.
* @brief A flag to determine whether this triangles only mesh is NGON encoded.
*
* NGON encoding is a special encoding that tells whether 2 or more consecutive triangles
* should be considered as a triangle fan. This is identified by looking at the first vertex index.
@ -428,8 +446,9 @@ enum aiPrimitiveType {
*/
aiPrimitiveType_NGONEncodingFlag = 0x10,
/** This value is not used. It is just here to force the
* compiler to map this enum to a 32 Bit integer.
/**
* This value is not used. It is just here to force the
* compiler to map this enum to a 32 Bit integer.
*/
#ifndef SWIG
_aiPrimitiveType_Force32Bit = INT_MAX
@ -494,25 +513,20 @@ struct aiAnimMesh {
float mWeight;
#ifdef __cplusplus
aiAnimMesh() AI_NO_EXCEPT
: mVertices(nullptr),
mNormals(nullptr),
mTangents(nullptr),
mBitangents(nullptr),
mColors(),
mTextureCoords(),
mNumVertices(0),
mWeight(0.0f) {
// fixme consider moving this to the ctor initializer list as well
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
mTextureCoords[a] = nullptr;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
mColors[a] = nullptr;
}
/// @brief The class constructor.
aiAnimMesh() AI_NO_EXCEPT :
mVertices(nullptr),
mNormals(nullptr),
mTangents(nullptr),
mBitangents(nullptr),
mColors {nullptr},
mTextureCoords{nullptr},
mNumVertices(0),
mWeight(0.0f) {
// empty
}
/// @brief The class destructor.
~aiAnimMesh() {
delete[] mVertices;
delete[] mNormals;
@ -526,35 +540,51 @@ struct aiAnimMesh {
}
}
/** Check whether the anim mesh overrides the vertex positions
* of its host mesh*/
/**
* @brief Check whether the anim-mesh overrides the vertex positions
* of its host mesh.
* @return true if positions are stored, false if not.
*/
bool HasPositions() const {
return mVertices != nullptr;
}
/** Check whether the anim mesh overrides the vertex normals
* of its host mesh*/
/**
* @brief Check whether the anim-mesh overrides the vertex normals
* of its host mesh
* @return true if normals are stored, false if not.
*/
bool HasNormals() const {
return mNormals != nullptr;
}
/** Check whether the anim mesh overrides the vertex tangents
* and bitangents of its host mesh. As for aiMesh,
* tangents and bitangents always go together. */
/**
* @brief Check whether the anim-mesh overrides the vertex tangents
* and bitangents of its host mesh. As for aiMesh,
* tangents and bitangents always go together.
* @return true if tangents and bi-tangents are stored, false if not.
*/
bool HasTangentsAndBitangents() const {
return mTangents != nullptr;
}
/** Check whether the anim mesh overrides a particular
* set of vertex colors on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */
/**
* @brief Check whether the anim mesh overrides a particular
* set of vertex colors on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS
* @return true if vertex colors are stored, false if not.
*/
bool HasVertexColors(unsigned int pIndex) const {
return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr;
}
/** Check whether the anim mesh overrides a particular
* set of texture coordinates on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */
/**
* @brief Check whether the anim mesh overrides a particular
* set of texture coordinates on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS
* @return true if texture coordinates are stored, false if not.
*/
bool HasTextureCoords(unsigned int pIndex) const {
return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr;
}
@ -566,6 +596,9 @@ struct aiAnimMesh {
/** @brief Enumerates the methods of mesh morphing supported by Assimp.
*/
enum aiMorphingMethod {
/** Morphing method to be determined */
aiMorphingMethod_UNKNOWN = 0x0,
/** Interpolation between morph targets */
aiMorphingMethod_VERTEX_BLEND = 0x1,
@ -585,143 +618,168 @@ enum aiMorphingMethod {
// ---------------------------------------------------------------------------
/** @brief A mesh represents a geometry or model with a single material.
*
* It usually consists of a number of vertices and a series of primitives/faces
* referencing the vertices. In addition there might be a series of bones, each
* of them addressing a number of vertices with a certain weight. Vertex data
* is presented in channels with each channel containing a single per-vertex
* information such as a set of texture coordinates or a normal vector.
* If a data pointer is non-null, the corresponding data stream is present.
* From C++-programs you can also use the comfort functions Has*() to
* test for the presence of various data streams.
*
* A Mesh uses only a single material which is referenced by a material ID.
* @note The mPositions member is usually not optional. However, vertex positions
* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
* @code
* aiScene::mFlags
* @endcode
*/
*
* It usually consists of a number of vertices and a series of primitives/faces
* referencing the vertices. In addition there might be a series of bones, each
* of them addressing a number of vertices with a certain weight. Vertex data
* is presented in channels with each channel containing a single per-vertex
* information such as a set of texture coordinates or a normal vector.
* If a data pointer is non-null, the corresponding data stream is present.
* From C++-programs you can also use the comfort functions Has*() to
* test for the presence of various data streams.
*
* A Mesh uses only a single material which is referenced by a material ID.
* @note The mPositions member is usually not optional. However, vertex positions
* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
* @code
* aiScene::mFlags
* @endcode
*/
struct aiMesh {
/** Bitwise combination of the members of the #aiPrimitiveType enum.
/**
* Bitwise combination of the members of the #aiPrimitiveType enum.
* This specifies which types of primitives are present in the mesh.
* The "SortByPrimitiveType"-Step can be used to make sure the
* output meshes consist of one primitive type each.
*/
unsigned int mPrimitiveTypes;
/** The number of vertices in this mesh.
* This is also the size of all of the per-vertex data arrays.
* The maximum value for this member is #AI_MAX_VERTICES.
*/
/**
* The number of vertices in this mesh.
* This is also the size of all of the per-vertex data arrays.
* The maximum value for this member is #AI_MAX_VERTICES.
*/
unsigned int mNumVertices;
/** The number of primitives (triangles, polygons, lines) in this mesh.
* This is also the size of the mFaces array.
* The maximum value for this member is #AI_MAX_FACES.
*/
/**
* The number of primitives (triangles, polygons, lines) in this mesh.
* This is also the size of the mFaces array.
* The maximum value for this member is #AI_MAX_FACES.
*/
unsigned int mNumFaces;
/** Vertex positions.
* This array is always present in a mesh. The array is
* mNumVertices in size.
*/
/**
* @brief Vertex positions.
*
* This array is always present in a mesh. The array is
* mNumVertices in size.
*/
C_STRUCT aiVector3D *mVertices;
/** Vertex normals.
* The array contains normalized vectors, nullptr if not present.
* The array is mNumVertices in size. Normals are undefined for
* point and line primitives. A mesh consisting of points and
* lines only may not have normal vectors. Meshes with mixed
* primitive types (i.e. lines and triangles) may have normals,
* but the normals for vertices that are only referenced by
* point or line primitives are undefined and set to QNaN (WARN:
* qNaN compares to inequal to *everything*, even to qNaN itself.
* Using code like this to check whether a field is qnan is:
* @code
* #define IS_QNAN(f) (f != f)
* @endcode
* still dangerous because even 1.f == 1.f could evaluate to false! (
* remember the subtleties of IEEE754 artithmetics). Use stuff like
* @c fpclassify instead.
* @note Normal vectors computed by Assimp are always unit-length.
* However, this needn't apply for normals that have been taken
* directly from the model file.
*/
/**
* @brief Vertex normals.
*
* The array contains normalized vectors, nullptr if not present.
* The array is mNumVertices in size. Normals are undefined for
* point and line primitives. A mesh consisting of points and
* lines only may not have normal vectors. Meshes with mixed
* primitive types (i.e. lines and triangles) may have normals,
* but the normals for vertices that are only referenced by
* point or line primitives are undefined and set to QNaN (WARN:
* qNaN compares to inequal to *everything*, even to qNaN itself.
* Using code like this to check whether a field is qnan is:
* @code
* #define IS_QNAN(f) (f != f)
* @endcode
* still dangerous because even 1.f == 1.f could evaluate to false! (
* remember the subtleties of IEEE754 artithmetics). Use stuff like
* @c fpclassify instead.
* @note Normal vectors computed by Assimp are always unit-length.
* However, this needn't apply for normals that have been taken
* directly from the model file.
*/
C_STRUCT aiVector3D *mNormals;
/** Vertex tangents.
* The tangent of a vertex points in the direction of the positive
* X texture axis. The array contains normalized vectors, nullptr if
* not present. The array is mNumVertices in size. A mesh consisting
* of points and lines only may not have normal vectors. Meshes with
* mixed primitive types (i.e. lines and triangles) may have
* normals, but the normals for vertices that are only referenced by
* point or line primitives are undefined and set to qNaN. See
* the #mNormals member for a detailed discussion of qNaNs.
* @note If the mesh contains tangents, it automatically also
* contains bitangents.
*/
/**
* @brief Vertex tangents.
*
* The tangent of a vertex points in the direction of the positive
* X texture axis. The array contains normalized vectors, nullptr if
* not present. The array is mNumVertices in size. A mesh consisting
* of points and lines only may not have normal vectors. Meshes with
* mixed primitive types (i.e. lines and triangles) may have
* normals, but the normals for vertices that are only referenced by
* point or line primitives are undefined and set to qNaN. See
* the #mNormals member for a detailed discussion of qNaNs.
* @note If the mesh contains tangents, it automatically also
* contains bitangents.
*/
C_STRUCT aiVector3D *mTangents;
/** Vertex bitangents.
* The bitangent of a vertex points in the direction of the positive
* Y texture axis. The array contains normalized vectors, nullptr if not
* present. The array is mNumVertices in size.
* @note If the mesh contains tangents, it automatically also contains
* bitangents.
*/
/**
* @brief Vertex bitangents.
*
* The bitangent of a vertex points in the direction of the positive
* Y texture axis. The array contains normalized vectors, nullptr if not
* present. The array is mNumVertices in size.
* @note If the mesh contains tangents, it automatically also contains
* bitangents.
*/
C_STRUCT aiVector3D *mBitangents;
/** Vertex color sets.
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
* colors per vertex. nullptr if not present. Each array is
* mNumVertices in size if present.
*/
/**
* @brief Vertex color sets.
*
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
* colors per vertex. nullptr if not present. Each array is
* mNumVertices in size if present.
*/
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
/** Vertex texture coordinates, also known as UV channels.
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
* vertex. nullptr if not present. The array is mNumVertices in size.
*/
/**
* @brief Vertex texture coordinates, also known as UV channels.
*
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS channels per
* vertex. Used and unused (nullptr) channels may go in any order.
* The array is mNumVertices in size.
*/
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
/** Specifies the number of components for a given UV channel.
* Up to three channels are supported (UVW, for accessing volume
* or cube maps). If the value is 2 for a given channel n, the
* component p.z of mTextureCoords[n][p] is set to 0.0f.
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
* @note 4D coordinates are not supported
*/
/**
* @brief Specifies the number of components for a given UV channel.
*
* Up to three channels are supported (UVW, for accessing volume
* or cube maps). If the value is 2 for a given channel n, the
* component p.z of mTextureCoords[n][p] is set to 0.0f.
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
* @note 4D coordinates are not supported
*/
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
/** The faces the mesh is constructed from.
* Each face refers to a number of vertices by their indices.
* This array is always present in a mesh, its size is given
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
* is NOT set each face references an unique set of vertices.
*/
/**
* @brief The faces the mesh is constructed from.
*
* Each face refers to a number of vertices by their indices.
* This array is always present in a mesh, its size is given
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
* is NOT set each face references an unique set of vertices.
*/
C_STRUCT aiFace *mFaces;
/** The number of bones this mesh contains.
* Can be 0, in which case the mBones array is nullptr.
/**
* The number of bones this mesh contains. Can be 0, in which case the mBones array is nullptr.
*/
unsigned int mNumBones;
/** The bones of this mesh.
* A bone consists of a name by which it can be found in the
* frame hierarchy and a set of vertex weights.
*/
/**
* @brief The bones of this mesh.
*
* A bone consists of a name by which it can be found in the
* frame hierarchy and a set of vertex weights.
*/
C_STRUCT aiBone **mBones;
/** The material used by this mesh.
/**
* @brief The material used by this mesh.
*
* A mesh uses only a single material. If an imported model uses
* multiple materials, the import splits up the mesh. Use this value
* as index into the scene's material list.
*/
unsigned int mMaterialIndex;
/** Name of the mesh. Meshes can be named, but this is not a
/**
* Name of the mesh. Meshes can be named, but this is not a
* requirement and leaving this field empty is totally fine.
* There are mainly three uses for mesh names:
* - some formats name nodes and meshes independently.
@ -731,36 +789,46 @@ struct aiMesh {
* aids the caller at recovering the original mesh
* partitioning.
* - Vertex animations refer to meshes by their names.
**/
*/
C_STRUCT aiString mName;
/** The number of attachment meshes. Note! Currently only works with Collada loader. */
/**
* The number of attachment meshes.
* Currently known to work with loaders:
* - Collada
* - gltf
*/
unsigned int mNumAnimMeshes;
/** Attachment meshes for this mesh, for vertex-based animation.
* Attachment meshes carry replacement data for some of the
* mesh'es vertex components (usually positions, normals).
* Note! Currently only works with Collada loader.*/
/**
* Attachment meshes for this mesh, for vertex-based animation.
* Attachment meshes carry replacement data for some of the
* mesh'es vertex components (usually positions, normals).
* Currently known to work with loaders:
* - Collada
* - gltf
*/
C_STRUCT aiAnimMesh **mAnimMeshes;
/**
* Method of morphing when anim-meshes are specified.
* @see aiMorphingMethod to learn more about the provided morphing targets.
*/
unsigned int mMethod;
enum aiMorphingMethod mMethod;
/**
* The bounding box.
*/
C_STRUCT aiAABB mAABB;
/** Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
/**
* Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
*/
C_STRUCT aiString **mTextureCoordsNames;
#ifdef __cplusplus
//! Default constructor. Initializes all members to 0
//! The default class constructor.
aiMesh() AI_NO_EXCEPT
: mPrimitiveTypes(0),
mNumVertices(0),
@ -769,29 +837,22 @@ struct aiMesh {
mNormals(nullptr),
mTangents(nullptr),
mBitangents(nullptr),
mColors(),
mTextureCoords(),
mNumUVComponents(),
mColors{nullptr},
mTextureCoords{nullptr},
mNumUVComponents{0},
mFaces(nullptr),
mNumBones(0),
mBones(nullptr),
mMaterialIndex(0),
mNumAnimMeshes(0),
mAnimMeshes(nullptr),
mMethod(0),
mMethod(aiMorphingMethod_UNKNOWN),
mAABB(),
mTextureCoordsNames(nullptr) {
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
mNumUVComponents[a] = 0;
mTextureCoords[a] = nullptr;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
mColors[a] = nullptr;
}
// empty
}
//! Deletes all storage allocated for the mesh
//! @brief The class destructor.
~aiMesh() {
delete[] mVertices;
delete[] mNormals;
@ -814,11 +875,15 @@ struct aiMesh {
// DO NOT REMOVE THIS ADDITIONAL CHECK
if (mNumBones && mBones) {
std::unordered_set<const aiBone *> bones;
for (unsigned int a = 0; a < mNumBones; a++) {
if (mBones[a]) {
delete mBones[a];
bones.insert(mBones[a]);
}
}
for (const aiBone *bone: bones) {
delete bone;
}
delete[] mBones;
}
@ -832,54 +897,71 @@ struct aiMesh {
delete[] mFaces;
}
//! Check whether the mesh contains positions. Provided no special
//! scene flags are set, this will always be true
bool HasPositions() const { return mVertices != nullptr && mNumVertices > 0; }
//! @brief Check whether the mesh contains positions. Provided no special
//! scene flags are set, this will always be true
//! @return true, if positions are stored, false if not.
bool HasPositions() const {
return mVertices != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains faces. If no special scene flags
//! are set this should always return true
bool HasFaces() const { return mFaces != nullptr && mNumFaces > 0; }
//! @brief Check whether the mesh contains faces. If no special scene flags
//! are set this should always return true
//! @return true, if faces are stored, false if not.
bool HasFaces() const {
return mFaces != nullptr && mNumFaces > 0;
}
//! Check whether the mesh contains normal vectors
bool HasNormals() const { return mNormals != nullptr && mNumVertices > 0; }
//! @brief Check whether the mesh contains normal vectors
//! @return true, if normals are stored, false if not.
bool HasNormals() const {
return mNormals != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains tangent and bitangent vectors
//! @brief Check whether the mesh contains tangent and bitangent vectors.
//!
//! It is not possible that it contains tangents and no bitangents
//! (or the other way round). The existence of one of them
//! implies that the second is there, too.
bool HasTangentsAndBitangents() const { return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains a vertex color set
//! \param pIndex Index of the vertex color set
bool HasVertexColors(unsigned int pIndex) const {
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
return false;
} else {
return mColors[pIndex] != nullptr && mNumVertices > 0;
}
//! @return true, if tangents and bi-tangents are stored, false if not.
bool HasTangentsAndBitangents() const {
return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains a texture coordinate set
//! \param pIndex Index of the texture coordinates set
bool HasTextureCoords(unsigned int pIndex) const {
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
//! @brief Check whether the mesh contains a vertex color set
//! @param index Index of the vertex color set
//! @return true, if vertex colors are stored, false if not.
bool HasVertexColors(unsigned int index) const {
if (index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
return false;
} else {
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
}
return mColors[index] != nullptr && mNumVertices > 0;
}
//! Get the number of UV channels the mesh contains
//! @brief Check whether the mesh contains a texture coordinate set
//! @param index Index of the texture coordinates set
//! @return true, if texture coordinates are stored, false if not.
bool HasTextureCoords(unsigned int index) const {
if (index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return false;
}
return (mTextureCoords[index] != nullptr && mNumVertices > 0);
}
//! @brief Get the number of UV channels the mesh contains.
//! @return the number of stored uv-channels.
unsigned int GetNumUVChannels() const {
unsigned int n(0);
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
++n;
for (unsigned i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) {
if (mTextureCoords[i]) {
++n;
}
}
return n;
}
//! Get the number of vertex color channels the mesh contains
//! @brief Get the number of vertex color channels the mesh contains.
//! @return The number of stored color channels.
unsigned int GetNumColorChannels() const {
unsigned int n(0);
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
@ -888,13 +970,15 @@ struct aiMesh {
return n;
}
//! Check whether the mesh contains bones
//! @brief Check whether the mesh contains bones.
//! @return true, if bones are stored.
bool HasBones() const {
return mBones != nullptr && mNumBones > 0;
}
//! Check whether the mesh contains a texture coordinate set name
//! \param pIndex Index of the texture coordinates set
//! @brief Check whether the mesh contains a texture coordinate set name
//! @param pIndex Index of the texture coordinates set
//! @return true, if texture coordinates for the index exists.
bool HasTextureCoordsName(unsigned int pIndex) const {
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return false;
@ -902,9 +986,9 @@ struct aiMesh {
return mTextureCoordsNames[pIndex] != nullptr;
}
//! Set a texture coordinate set name
//! \param pIndex Index of the texture coordinates set
//! \param texCoordsName name of the texture coordinate set
//! @brief Set a texture coordinate set name
//! @param pIndex Index of the texture coordinates set
//! @param texCoordsName name of the texture coordinate set
void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) {
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return;
@ -912,7 +996,10 @@ struct aiMesh {
if (mTextureCoordsNames == nullptr) {
// Construct and null-init array
mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {};
mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS];
for (size_t i=0; i<AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
mTextureCoordsNames[i] = nullptr;
}
}
if (texCoordsName.length == 0) {
@ -929,30 +1016,46 @@ struct aiMesh {
*mTextureCoordsNames[pIndex] = texCoordsName;
}
//! Get a texture coordinate set name
//! \param pIndex Index of the texture coordinates set
const aiString *GetTextureCoordsName(unsigned int pIndex) const {
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
//! @brief Get a texture coordinate set name
//! @param pIndex Index of the texture coordinates set
//! @return The texture coordinate name.
const aiString *GetTextureCoordsName(unsigned int index) const {
if (mTextureCoordsNames == nullptr || index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return nullptr;
}
return mTextureCoordsNames[pIndex];
return mTextureCoordsNames[index];
}
#endif // __cplusplus
};
/**
* @brief A skeleton bone represents a single bone is a skeleton structure.
*
* Skeleton-Animations can be represented via a skeleton struct, which describes
* a hierarchical tree assembled from skeleton bones. A bone is linked to a mesh.
* The bone knows its parent bone. If there is no parent bone the parent id is
* marked with -1.
* The skeleton-bone stores a pointer to its used armature. If there is no
* armature this value if set to nullptr.
* A skeleton bone stores its offset-matrix, which is the absolute transformation
* for the bone. The bone stores the locale transformation to its parent as well.
* You can compute the offset matrix by multiplying the hierarchy like:
* Tree: s1 -> s2 -> s3
* Offset-Matrix s3 = locale-s3 * locale-s2 * locale-s1
*/
struct aiSkeletonBone {
/// The parent bone index, is -1 one if this bone represents the root bone.
int mParent;
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
/// The bone armature node - used for skeleton conversion
/// @brief The bone armature node - used for skeleton conversion
/// you must enable aiProcess_PopulateArmatureData to populate this
C_STRUCT aiNode *mArmature;
/// The bone node in the scene - used for skeleton conversion
/// @brief The bone node in the scene - used for skeleton conversion
/// you must enable aiProcess_PopulateArmatureData to populate this
C_STRUCT aiNode *mNode;
@ -983,10 +1086,13 @@ struct aiSkeletonBone {
C_STRUCT aiMatrix4x4 mLocalMatrix;
#ifdef __cplusplus
/// @brief The class constructor.
aiSkeletonBone() :
mParent(-1),
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
mArmature(nullptr),
mNode(nullptr),
#endif
mNumnWeights(0),
mMeshId(nullptr),
mWeights(nullptr),
@ -995,6 +1101,22 @@ struct aiSkeletonBone {
// empty
}
/// @brief The class constructor with its parent
/// @param parent The parent node index.
aiSkeletonBone(unsigned int parent) :
mParent(parent),
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
mArmature(nullptr),
mNode(nullptr),
#endif
mNumnWeights(0),
mMeshId(nullptr),
mWeights(nullptr),
mOffsetMatrix(),
mLocalMatrix() {
// empty
}
/// @brief The class destructor.
~aiSkeletonBone() {
delete[] mWeights;
mWeights = nullptr;
@ -1002,34 +1124,45 @@ struct aiSkeletonBone {
#endif // __cplusplus
};
/**
* @brief
* @brief A skeleton represents the bone hierarchy of an animation.
*
* Skeleton animations can be described as a tree of bones:
* root
* |
* node1
* / \
* node3 node4
* If you want to calculate the transformation of node three you need to compute the
* transformation hierarchy for the transformation chain of node3:
* root->node1->node3
* Each node is represented as a skeleton instance.
*/
struct aiSkeleton {
/**
*
* @brief The name of the skeleton instance.
*/
C_STRUCT aiString mName;
/**
*
* @brief The number of bones in the skeleton.
*/
unsigned int mNumBones;
/**
*
* @brief The bone instance in the skeleton.
*/
C_STRUCT aiSkeletonBone **mBones;
#ifdef __cplusplus
/**
*
* @brief The class constructor.
*/
aiSkeleton() AI_NO_EXCEPT : mName(), mNumBones(0), mBones(nullptr) {
// empty
}
/**
*
* @brief The class destructor.
*/
~aiSkeleton() {
delete[] mBones;
@ -1039,4 +1172,6 @@ struct aiSkeleton {
#ifdef __cplusplus
}
#endif //! extern "C"
#endif // AI_MESH_H_INC

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -56,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h>
#endif
#include <assimp/quaternion.h>
// -------------------------------------------------------------------------------
/**
* Enum used to distinguish data types
@ -70,7 +72,9 @@ typedef enum aiMetadataType {
AI_AISTRING = 5,
AI_AIVECTOR3D = 6,
AI_AIMETADATA = 7,
AI_META_MAX = 8,
AI_INT64 = 8,
AI_UINT32 = 9,
AI_META_MAX = 10,
#ifndef SWIG
FORCE_32BIT = INT_MAX
@ -109,19 +113,19 @@ struct aiMetadata;
*/
// -------------------------------------------------------------------------------
inline aiMetadataType GetAiType(bool) {
inline aiMetadataType GetAiType(const bool &) {
return AI_BOOL;
}
inline aiMetadataType GetAiType(int32_t) {
return AI_INT32;
}
inline aiMetadataType GetAiType(uint64_t) {
inline aiMetadataType GetAiType(const uint64_t &) {
return AI_UINT64;
}
inline aiMetadataType GetAiType(float) {
inline aiMetadataType GetAiType(const float &) {
return AI_FLOAT;
}
inline aiMetadataType GetAiType(double) {
inline aiMetadataType GetAiType(const double &) {
return AI_DOUBLE;
}
inline aiMetadataType GetAiType(const aiString &) {
@ -133,6 +137,12 @@ inline aiMetadataType GetAiType(const aiVector3D &) {
inline aiMetadataType GetAiType(const aiMetadata &) {
return AI_AIMETADATA;
}
inline aiMetadataType GetAiType(const int64_t &) {
return AI_INT64;
}
inline aiMetadataType GetAiType(const uint32_t &) {
return AI_UINT32;
}
#endif // __cplusplus
@ -215,6 +225,16 @@ struct aiMetadata {
rhs.Get<aiMetadata>(static_cast<unsigned int>(i), v);
mValues[i].mData = new aiMetadata(v);
} break;
case AI_INT64: {
int64_t v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(int64_t));
mValues[i].mData = new int64_t(v);
} break;
case AI_UINT32: {
uint32_t v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(uint32_t));
mValues[i].mData = new uint32_t(v);
} break;
#ifndef SWIG
case FORCE_32BIT:
#endif
@ -267,6 +287,12 @@ struct aiMetadata {
case AI_AIMETADATA:
delete static_cast<aiMetadata *>(data);
break;
case AI_INT64:
delete static_cast<int64_t *>(data);
break;
case AI_UINT32:
delete static_cast<uint32_t *>(data);
break;
#ifndef SWIG
case FORCE_32BIT:
#endif
@ -510,6 +536,16 @@ struct aiMetadata {
return false;
}
} break;
case AI_INT64: {
if (*static_cast<int64_t *>(lhs.mValues[i].mData) != *static_cast<int64_t *>(rhs.mValues[i].mData)) {
return false;
}
} break;
case AI_UINT32: {
if (*static_cast<uint32_t *>(lhs.mValues[i].mData) != *static_cast<uint32_t *>(rhs.mValues[i].mData)) {
return false;
}
} break;
#ifndef SWIG
case FORCE_32BIT:
#endif

View file

@ -0,0 +1,33 @@
// Export headers for Swift (iOS)
module libassimp {
header "ColladaMetaData.h"
header "GltfMaterial.h"
header "ObjMaterial.h"
header "anim.h"
header "camera.h"
header "cexport.h"
header "cfileio.h"
header "cimport.h"
header "color4.h"
header "commonMetaData.h"
header "config.h"
header "defs.h"
header "importerdesc.h"
header "light.h"
header "material.h"
header "matrix3x3.h"
header "matrix4x4.h"
header "mesh.h"
header "metadata.h"
header "pbrmaterial.h"
header "postprocess.h"
header "quaternion.h"
header "revision.h"
header "scene.h"
header "texture.h"
header "types.h"
header "vector2.h"
header "vector3.h"
header "version.h"
export *
}

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -94,6 +94,7 @@ enum aiPostProcessSteps
* indexed geometry, this step is compulsory or you'll just waste rendering
* time. <b>If this flag is not specified</b>, no vertices are referenced by
* more than one face and <b>no index buffer is required</b> for rendering.
* Unless the importer (like ply) had to split vertices. Then you need one regardless.
*/
aiProcess_JoinIdenticalVertices = 0x2,
@ -378,7 +379,7 @@ enum aiPostProcessSteps
* point primitives to separate meshes.
* </li>
* <li>Set the <tt>#AI_CONFIG_PP_SBP_REMOVE</tt> importer property to
* @code aiPrimitiveType_POINTS | aiPrimitiveType_LINES
* @code aiPrimitiveType_POINT | aiPrimitiveType_LINE
* @endcode to cause SortByPType to reject point
* and line meshes from the scene.
* </li>

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team

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.
@ -36,7 +35,6 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
@ -47,29 +45,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_QUATERNION_H_INC
#define AI_QUATERNION_H_INC
#include <assimp/defs.h>
#ifdef __cplusplus
#ifdef __GNUC__
# pragma GCC system_header
#endif
#include <assimp/defs.h>
// Forward declarations
template <typename TReal> class aiVector3t;
template <typename TReal> class aiMatrix3x3t;
template <typename TReal> class aiMatrix4x4t;
// ---------------------------------------------------------------------------
/** Represents a quaternion in a 4D vector. */
/**
* @brief This class represents a quaternion as a 4D vector.
*/
template <typename TReal>
class aiQuaterniont
{
class aiQuaterniont {
public:
aiQuaterniont() AI_NO_EXCEPT : w(1.0), x(), y(), z() {}
aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
: w(pw), x(px), y(py), z(pz) {}
/** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */
/**
* @brief Construct from rotation matrix. Result is undefined if the matrix is not orthonormal.
*/
explicit aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix);
/** Construct from euler angles */
@ -84,8 +86,6 @@ public:
/** Returns a matrix representation of the quaternion */
aiMatrix3x3t<TReal> GetMatrix() const;
public:
bool operator== (const aiQuaterniont& o) const;
bool operator!= (const aiQuaterniont& o) const;
@ -94,23 +94,30 @@ public:
bool Equal(const aiQuaterniont &o, TReal epsilon = ai_epsilon) const;
public:
/** Normalize the quaternion */
/**
* @brief Will normalize the quaternion representation.
*/
aiQuaterniont& Normalize();
/** Compute quaternion conjugate */
aiQuaterniont& Conjugate ();
/**
* @brief Will compute the quaternion conjugate. The result will be stored in the instance.
*/
aiQuaterniont& Conjugate();
/** Rotate a point by this quaternion */
aiVector3t<TReal> Rotate (const aiVector3t<TReal>& in) const;
/**
* @brief Rotate a point by this quaternion
*/
aiVector3t<TReal> Rotate(const aiVector3t<TReal>& in) const;
/** Multiply two quaternions */
aiQuaterniont operator* (const aiQuaterniont& two) const;
/**
* @brief Multiply two quaternions
* @param two The other quaternion.
* @return The result of the multiplication.
*/
aiQuaterniont operator * (const aiQuaterniont& two) const;
public:
/** Performs a spherical interpolation between two quaternions and writes the result into the third.
/**
* @brief Performs a spherical interpolation between two quaternions and writes the result into the third.
* @param pOut Target object to received the interpolated rotation.
* @param pStart Start rotation of the interpolation at factor == 0.
* @param pEnd End rotation, factor == 1.
@ -119,13 +126,11 @@ public:
static void Interpolate( aiQuaterniont& pOut, const aiQuaterniont& pStart,
const aiQuaterniont& pEnd, TReal pFactor);
public:
//! w,x,y,z components of the quaternion
TReal w, x, y, z;
} ;
typedef aiQuaterniont<ai_real> aiQuaternion;
using aiQuaternion = aiQuaterniont<ai_real>;
#else

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
@ -237,7 +237,8 @@ inline void aiQuaterniont<TReal>::Interpolate( aiQuaterniont& pOut, const aiQuat
// Calculate coefficients
TReal sclp, sclq;
if( (static_cast<TReal>(1.0) - cosom) > static_cast<TReal>(0.0001)) // 0.0001 -> some epsillon
if ((static_cast<TReal>(1.0) - cosom) > ai_epsilon) // 0.0001 -> some epsillon
{
// Standard case (slerp)
TReal omega, sinom;

View file

@ -0,0 +1,29 @@
#ifndef ASSIMP_REVISION_H_INC
#define ASSIMP_REVISION_H_INC
#define GitVersion 0x@GIT_COMMIT_HASH@
#define GitBranch "@GIT_BRANCH@"
#define VER_MAJOR @ASSIMP_VERSION_MAJOR@
#define VER_MINOR @ASSIMP_VERSION_MINOR@
#define VER_PATCH @ASSIMP_VERSION_PATCH@
#define VER_BUILD @ASSIMP_PACKAGE_VERSION@
#define STR_HELP(x) #x
#define STR(x) STR_HELP(x)
#define VER_FILEVERSION VER_MAJOR,VER_MINOR,VER_PATCH,VER_BUILD
#if (GitVersion == 0)
#define VER_FILEVERSION_STR STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD)
#else
#define VER_FILEVERSION_STR STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD) " (Commit @GIT_COMMIT_HASH@)"
#endif
#define VER_COPYRIGHT_STR "\xA9 2006-2023"
#ifdef NDEBUG
#define VER_ORIGINAL_FILENAME_STR "@CMAKE_SHARED_LIBRARY_PREFIX@assimp@LIBRARY_SUFFIX@.dll"
#else
#define VER_ORIGINAL_FILENAME_STR "@CMAKE_SHARED_LIBRARY_PREFIX@assimp@LIBRARY_SUFFIX@@CMAKE_DEBUG_POSTFIX@.dll"
#endif // NDEBUG
#endif // ASSIMP_REVISION_H_INC

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -141,25 +141,28 @@ struct ASSIMP_API aiNode {
/** Destructor */
~aiNode();
/** Searches for a node with a specific name, beginning at this
/**
* @brief Searches for a node with a specific name, beginning at this
* nodes. Normally you will call this method on the root node
* of the scene.
*
* @param name Name to search for
* @return nullptr or a valid Node if the search was successful.
*/
inline
const aiNode* FindNode(const aiString& name) const {
inline const aiNode* FindNode(const aiString& name) const {
return FindNode(name.data);
}
inline
aiNode* FindNode(const aiString& name) {
inline aiNode* FindNode(const aiString& name) {
return FindNode(name.data);
}
/**
* @brief Will search for a node described by its name.
* @param[in] name The name for the node to look for.
* @return Pointer showing to the node or nullptr if not found.
*/
const aiNode* FindNode(const char* name) const;
aiNode* FindNode(const char* name);
/**
@ -240,8 +243,7 @@ struct ASSIMP_API aiNode {
* delete a given scene on your own.
*/
// -------------------------------------------------------------------------------
struct aiScene
{
struct ASSIMP_API aiScene {
/** Any combination of the AI_SCENE_FLAGS_XXX flags. By default
* this value is 0, no flags are set. Most applications will
* want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
@ -355,10 +357,10 @@ struct aiScene
#ifdef __cplusplus
//! Default constructor - set everything to 0/nullptr
ASSIMP_API aiScene();
aiScene();
//! Destructor
ASSIMP_API ~aiScene();
~aiScene();
//! Check whether the scene contains meshes
//! Unless no special scene flags are set this will always be true.
@ -399,8 +401,9 @@ struct aiScene
//! Returns a short filename from a full path
static const char* GetShortFilename(const char* filename) {
const char* lastSlash = strrchr(filename, '/');
if (lastSlash == nullptr) {
lastSlash = strrchr(filename, '\\');
const char* lastBackSlash = strrchr(filename, '\\');
if (lastSlash < lastBackSlash) {
lastSlash = lastBackSlash;
}
const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
return shortFilename;
@ -433,7 +436,7 @@ struct aiScene
for (unsigned int i = 0; i < mNumTextures; i++) {
const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
if (strcmp(shortTextureFilename, shortFilename) == 0) {
return std::make_pair(mTextures[i], i);
return std::make_pair(mTextures[i], static_cast<int>(i));
}
}
return std::make_pair(nullptr, -1);
@ -450,7 +453,7 @@ struct aiScene
};
#ifdef __cplusplus
}
}
#endif //! extern "C"
#endif // AI_SCENE_H_INC

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -74,7 +74,7 @@ typedef uint32_t ai_uint32;
#ifdef __cplusplus
#include <cstring>
#include <new> // for std::nothrow_t
#include <new> // for std::nothrow_t
#include <string> // for aiString::Set(const std::string&)
namespace Assimp {
@ -82,16 +82,16 @@ namespace Assimp {
namespace Intern {
// --------------------------------------------------------------------
/** @brief Internal helper class to utilize our internal new/delete
* routines for allocating object of this and derived classes.
*
* By doing this you can safely share class objects between Assimp
* and the application - it works even over DLL boundaries. A good
* example is the #IOSystem where the application allocates its custom
* #IOSystem, then calls #Importer::SetIOSystem(). When the Importer
* destructs, Assimp calls operator delete on the stored #IOSystem.
* If it lies on a different heap than Assimp is working with,
* the application is determined to crash.
*/
* routines for allocating object of this and derived classes.
*
* By doing this you can safely share class objects between Assimp
* and the application - it works even over DLL boundaries. A good
* example is the #IOSystem where the application allocates its custom
* #IOSystem, then calls #Importer::SetIOSystem(). When the Importer
* destructs, Assimp calls operator delete on the stored #IOSystem.
* If it lies on a different heap than Assimp is working with,
* the application is determined to crash.
*/
// --------------------------------------------------------------------
#ifndef SWIG
struct ASSIMP_API AllocateFromAssimpHeap {
@ -118,9 +118,9 @@ extern "C" {
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */
#ifdef __cplusplus
static const size_t MAXLEN = 1024;
static const size_t AI_MAXLEN = 1024;
#else
#define MAXLEN 1024
#define AI_MAXLEN 1024
#endif
// ----------------------------------------------------------------------------------
@ -165,9 +165,9 @@ struct aiRay {
struct aiColor3D {
#ifdef __cplusplus
aiColor3D() AI_NO_EXCEPT : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D(ai_real _r, ai_real _g, ai_real _b) :
aiColor3D(float _r, float _g, float _b) :
r(_r), g(_g), b(_b) {}
explicit aiColor3D(ai_real _r) :
explicit aiColor3D(float _r) :
r(_r), g(_r), b(_r) {}
aiColor3D(const aiColor3D &o) :
r(o.r), g(o.g), b(o.b) {}
@ -214,12 +214,12 @@ struct aiColor3D {
}
/** Access a specific color component */
ai_real operator[](unsigned int i) const {
float operator[](unsigned int i) const {
return *(&r + i);
}
/** Access a specific color component */
ai_real &operator[](unsigned int i) {
float &operator[](unsigned int i) {
if (0 == i) {
return r;
} else if (1 == i) {
@ -232,18 +232,19 @@ struct aiColor3D {
/** Check whether a color is black */
bool IsBlack() const {
static const ai_real epsilon = ai_real(10e-3);
static const float epsilon = float(10e-3);
return std::fabs(r) < epsilon && std::fabs(g) < epsilon && std::fabs(b) < epsilon;
}
#endif // !__cplusplus
//! Red, green and blue color values
ai_real r, g, b;
float r, g, b;
}; // !struct aiColor3D
// ----------------------------------------------------------------------------------
/** Represents an UTF-8 string, zero byte terminated.
/**
* @brief Represents an UTF-8 string, zero byte terminated.
*
* The character set of an aiString is explicitly defined to be UTF-8. This Unicode
* transformation was chosen in the belief that most strings in 3d files are limited
@ -260,42 +261,40 @@ struct aiColor3D {
* UTF-8 strings to their working character set (i.e. MBCS, WideChar).
*
* We use this representation instead of std::string to be C-compatible. The
* (binary) length of such a string is limited to MAXLEN characters (including the
* (binary) length of such a string is limited to AI_MAXLEN characters (including the
* the terminating zero).
*/
*/
struct aiString {
#ifdef __cplusplus
/** Default constructor, the string is set to have zero length */
aiString() AI_NO_EXCEPT
: length(0) {
data[0] = '\0';
aiString() AI_NO_EXCEPT :
length(0), data{'\0'} {
#ifdef ASSIMP_BUILD_DEBUG
// Debug build: overwrite the string on its full length with ESC (27)
memset(data + 1, 27, MAXLEN - 1);
memset(data + 1, 27, AI_MAXLEN - 1);
#endif
}
/** Copy constructor */
aiString(const aiString &rOther) :
length(rOther.length) {
length(rOther.length), data{'\0'} {
// Crop the string to the maximum length
length = length >= MAXLEN ? MAXLEN - 1 : length;
length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
memcpy(data, rOther.data, length);
data[length] = '\0';
}
/** Constructor from std::string */
explicit aiString(const std::string &pString) :
length((ai_uint32)pString.length()) {
length = length >= MAXLEN ? MAXLEN - 1 : length;
length((ai_uint32)pString.length()), data{'\0'} {
length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
memcpy(data, pString.c_str(), length);
data[length] = '\0';
}
/** Copy a std::string to the aiString */
void Set(const std::string &pString) {
if (pString.length() > MAXLEN - 1) {
if (pString.length() > AI_MAXLEN - 1) {
return;
}
length = (ai_uint32)pString.length();
@ -306,8 +305,8 @@ struct aiString {
/** Copy a const char* to the aiString */
void Set(const char *sz) {
ai_int32 len = (ai_uint32)::strlen(sz);
if (len > (ai_int32)MAXLEN - 1) {
len = (ai_int32) MAXLEN - 1;
if (len > static_cast<ai_int32>(AI_MAXLEN - 1)) {
len = static_cast<ai_int32>(AI_MAXLEN - 1);
}
length = len;
memcpy(data, sz, len);
@ -321,8 +320,8 @@ struct aiString {
}
length = rOther.length;
if (length >(MAXLEN - 1)) {
length = (ai_int32) MAXLEN - 1;
if (length > (AI_MAXLEN - 1)) {
length = static_cast<ai_int32>(AI_MAXLEN - 1);
}
memcpy(data, rOther.data, length);
@ -344,21 +343,24 @@ struct aiString {
/** Comparison operator */
bool operator==(const aiString &other) const {
return (length == other.length && 0 == memcmp(data, other.data, length));
if (length == other.length) {
return memcmp(data, other.data, length) == 0;
}
return false;
}
/** Inverse comparison operator */
bool operator!=(const aiString &other) const {
return (length != other.length || 0 != memcmp(data, other.data, length));
return !(*this == other);
}
/** Append a string to the string */
void Append(const char *app) {
const ai_uint32 len = (ai_uint32)::strlen(app);
const ai_uint32 len = static_cast<ai_uint32>(::strlen(app));
if (!len) {
return;
}
if (length + len >= MAXLEN) {
if (length + len >= AI_MAXLEN) {
return;
}
@ -373,7 +375,7 @@ struct aiString {
#ifdef ASSIMP_BUILD_DEBUG
// Debug build: overwrite the string on its full length with ESC (27)
memset(data + 1, 27, MAXLEN - 1);
memset(data + 1, 27, AI_MAXLEN - 1);
#endif
}
@ -389,8 +391,8 @@ struct aiString {
* the number of bytes from the beginning of the string to its end.*/
ai_uint32 length;
/** String buffer. Size limit is MAXLEN */
char data[MAXLEN];
/** String buffer. Size limit is AI_MAXLEN */
char data[AI_MAXLEN];
}; // !struct aiString
// ----------------------------------------------------------------------------------
@ -523,6 +525,23 @@ struct aiMemoryInfo {
unsigned int total;
}; // !struct aiMemoryInfo
/**
* @brief Type to store a in-memory data buffer.
*/
struct aiBuffer {
const char *data; ///< Begin poiner
const char *end; ///< End pointer
#ifdef __cplusplus
/// @brief The class constructor.
aiBuffer() :
data(nullptr), end(nullptr) {}
/// @brief The class destructor.
~aiBuffer() = default;
#endif //! __cplusplus
};
#ifdef __cplusplus
}
#endif //! __cplusplus

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -70,17 +70,17 @@ class aiVector3t {
public:
/// @brief The default class constructor.
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
/// @brief The class constructor with the components.
/// @param _x The x-component for the vector.
/// @param _y The y-component for the vector.
/// @param _z The z-component for the vector.
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
/// @brief The class constructor with a default value.
/// @param _xyz The value for x, y and z.
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
/// @brief The copy constructor.
/// @param o The instance to copy from.
aiVector3t( const aiVector3t& o ) = default;
@ -113,7 +113,7 @@ public:
bool operator!= (const aiVector3t& other) const;
bool operator < (const aiVector3t& other) const;
/// @brief
/// @brief
bool Equal(const aiVector3t &other, TReal epsilon = ai_epsilon) const;
template <typename TOther>
@ -151,6 +151,8 @@ public:
typedef aiVector3t<ai_real> aiVector3D;
typedef aiVector3t<float> aiVector3f;
typedef aiVector3t<double> aiVector3d;
#else

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.