mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Update Assimp from 5.2.3 to 5.2.5
This commit is contained in:
parent
ea7ca63301
commit
16f3710058
379 changed files with 14469 additions and 47175 deletions
|
|
@ -50,16 +50,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace Assimp {
|
||||
namespace Base64 {
|
||||
|
||||
/// @brief Will encode the given
|
||||
/// @param in
|
||||
/// @param inLength
|
||||
/// @param out
|
||||
/// @brief Will encode the given character buffer from UTF64 to ASCII
|
||||
/// @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);
|
||||
|
||||
/// @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);
|
||||
|
||||
/// @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);
|
||||
|
||||
/// @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);
|
||||
|
||||
/// @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);
|
||||
|
||||
/// @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);
|
||||
|
||||
} // namespace Base64
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ protected:
|
|||
|
||||
// We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
|
||||
static constexpr std::size_t header_size =
|
||||
sizeof(type) +
|
||||
sizeof(size) +
|
||||
sizeof(reserved1) +
|
||||
sizeof(reserved2) +
|
||||
sizeof(offset);
|
||||
sizeof(uint16_t) +
|
||||
sizeof(uint32_t) +
|
||||
sizeof(uint16_t) +
|
||||
sizeof(uint16_t) +
|
||||
sizeof(uint32_t);
|
||||
};
|
||||
|
||||
struct DIB {
|
||||
|
|
@ -100,17 +100,17 @@ protected:
|
|||
|
||||
// We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
|
||||
static constexpr std::size_t dib_size =
|
||||
sizeof(size) +
|
||||
sizeof(width) +
|
||||
sizeof(height) +
|
||||
sizeof(planes) +
|
||||
sizeof(bits_per_pixel) +
|
||||
sizeof(compression) +
|
||||
sizeof(image_size) +
|
||||
sizeof(x_resolution) +
|
||||
sizeof(y_resolution) +
|
||||
sizeof(nb_colors) +
|
||||
sizeof(nb_important_colors);
|
||||
sizeof(uint32_t) +
|
||||
sizeof(int32_t) +
|
||||
sizeof(int32_t) +
|
||||
sizeof(uint16_t) +
|
||||
sizeof(uint16_t) +
|
||||
sizeof(uint32_t) +
|
||||
sizeof(uint32_t) +
|
||||
sizeof(int32_t) +
|
||||
sizeof(int32_t) +
|
||||
sizeof(uint32_t) +
|
||||
sizeof(uint32_t);
|
||||
};
|
||||
|
||||
static constexpr std::size_t mBytesPerPixel = 4;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Hashing function taken from
|
||||
|
|
@ -73,9 +74,8 @@ 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;
|
||||
size_t offset;
|
||||
uint32_t tmp;
|
||||
int rem;
|
||||
|
||||
if (!data) return 0;
|
||||
if (!len)len = (uint32_t)::strlen(data);
|
||||
|
|
@ -96,11 +96,7 @@ size_t offset;
|
|||
switch (rem) {
|
||||
case 3: hash += get16bits (data);
|
||||
hash ^= hash << 16;
|
||||
offset = static_cast<size_t>(sizeof(uint16_t));
|
||||
if (offset < 0) {
|
||||
return 0;
|
||||
}
|
||||
hash ^= data[offset] << 18;
|
||||
hash ^= abs(data[sizeof(uint16_t)]) << 18;
|
||||
hash += hash >> 11;
|
||||
break;
|
||||
case 2: hash += get16bits (data);
|
||||
|
|
|
|||
|
|
@ -134,9 +134,7 @@ IOStream::IOStream() AI_NO_EXCEPT {
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
IOStream::~IOStream() {
|
||||
// empty
|
||||
}
|
||||
IOStream::~IOStream() = default;
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
} //!namespace Assimp
|
||||
|
|
|
|||
|
|
@ -243,9 +243,7 @@ AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT :
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE IOSystem::~IOSystem() {
|
||||
// empty
|
||||
}
|
||||
AI_FORCE_INLINE IOSystem::~IOSystem() = default;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// For compatibility, the interface of some functions taking a std::string was
|
||||
|
|
|
|||
|
|
@ -99,13 +99,9 @@ public:
|
|||
|
||||
}; // !class LogStream
|
||||
|
||||
inline LogStream::LogStream() AI_NO_EXCEPT {
|
||||
// empty
|
||||
}
|
||||
inline LogStream::LogStream() AI_NO_EXCEPT = default;
|
||||
|
||||
inline LogStream::~LogStream() {
|
||||
// empty
|
||||
}
|
||||
inline LogStream::~LogStream() = default;
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
|
|
|
|||
|
|
@ -263,9 +263,7 @@ inline Logger::Logger() AI_NO_EXCEPT :
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline Logger::~Logger() {
|
||||
// empty
|
||||
}
|
||||
inline Logger::~Logger() = default;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline Logger::Logger(LogSeverity severity) :
|
||||
|
|
|
|||
|
|
@ -122,10 +122,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
inline
|
||||
Subdivider::~Subdivider() {
|
||||
// empty
|
||||
}
|
||||
inline Subdivider::~Subdivider() = default;
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
|
|
|
|||
|
|
@ -99,295 +99,129 @@ template <class TNodeType>
|
|||
class TXmlParser {
|
||||
public:
|
||||
/// @brief The default class constructor.
|
||||
TXmlParser() :
|
||||
mDoc(nullptr),
|
||||
mData() {
|
||||
// empty
|
||||
}
|
||||
TXmlParser();
|
||||
|
||||
/// @brief The class destructor.
|
||||
~TXmlParser() {
|
||||
clear();
|
||||
}
|
||||
~TXmlParser();
|
||||
|
||||
/// @brief Will clear the parsed xml-file.
|
||||
void clear() {
|
||||
if (mData.empty()) {
|
||||
mDoc = nullptr;
|
||||
return;
|
||||
}
|
||||
mData.clear();
|
||||
delete mDoc;
|
||||
mDoc = nullptr;
|
||||
}
|
||||
void clear();
|
||||
|
||||
/// @brief Will search for a child-node by its name
|
||||
/// @param name [in] The name of the child-node.
|
||||
/// @return The node instance or nullptr, if nothing was found.
|
||||
TNodeType *findNode(const std::string &name) {
|
||||
if (name.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (nullptr == mDoc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
find_node_by_name_predicate predicate(name);
|
||||
mCurrent = mDoc->find_node(predicate);
|
||||
if (mCurrent.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &mCurrent;
|
||||
}
|
||||
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.
|
||||
/// @return true, if the node is a child-node or false if not.
|
||||
bool hasNode(const std::string &name) {
|
||||
return nullptr != findNode(name);
|
||||
}
|
||||
bool hasNode(const std::string &name);
|
||||
|
||||
/// @brief Will parse an xml-file from a given stream.
|
||||
/// @param stream The input stream.
|
||||
/// @return true, if the parsing was successful, false if not.
|
||||
bool parse(IOStream *stream) {
|
||||
if (nullptr == stream) {
|
||||
ASSIMP_LOG_DEBUG("Stream is nullptr.");
|
||||
return false;
|
||||
}
|
||||
bool parse(IOStream *stream);
|
||||
|
||||
const size_t len = stream->FileSize();
|
||||
mData.resize(len + 1);
|
||||
memset(&mData[0], '\0', len + 1);
|
||||
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);
|
||||
if (parse_result.status == pugi::status_ok) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ASSIMP_LOG_DEBUG("Error while parse xml.", std::string(parse_result.description()), " @ ", parse_result.offset);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Will return truem if a root node is there.
|
||||
/// @brief Will return true if a root node is there.
|
||||
/// @return true in case of an existing root.
|
||||
bool hasRoot() const {
|
||||
return nullptr != mDoc;
|
||||
}
|
||||
bool hasRoot() const;
|
||||
|
||||
/// @brief Will return the document pointer, is nullptr if no xml-file was parsed.
|
||||
/// @return The pointer showing to the document.
|
||||
pugi::xml_document *getDocument() const {
|
||||
return mDoc;
|
||||
}
|
||||
pugi::xml_document *getDocument() const;
|
||||
|
||||
/// @brief Will return the root node, const version.
|
||||
/// @return The root node.
|
||||
const TNodeType getRootNode() const {
|
||||
static pugi::xml_node none;
|
||||
if (nullptr == mDoc) {
|
||||
return none;
|
||||
}
|
||||
return mDoc->root();
|
||||
}
|
||||
const TNodeType getRootNode() const;
|
||||
|
||||
/// @brief Will return the root node, non-const version.
|
||||
/// @return The root node.
|
||||
TNodeType getRootNode() {
|
||||
static pugi::xml_node none;
|
||||
if (nullptr == mDoc) {
|
||||
return none;
|
||||
}
|
||||
return mDoc->root();
|
||||
}
|
||||
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.
|
||||
/// @return true, if node was found, false if not.
|
||||
static inline bool hasNode(XmlNode &node, const char *name) {
|
||||
pugi::xml_node child = node.find_child(find_node_by_name_predicate(name));
|
||||
return !child.empty();
|
||||
}
|
||||
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.
|
||||
/// @return true, if the was found, false if not.
|
||||
static inline bool hasAttribute(XmlNode &xmlNode, const char *name) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
return !attr.empty();
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_uint();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_int();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
#ifdef ASSIMP_DOUBLE_PRECISION
|
||||
val = attr.as_double();
|
||||
#else
|
||||
val = attr.as_float();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_float();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_double();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_string();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @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) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_bool();
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsString(XmlNode &node, std::string &text) {
|
||||
text = std::string();
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
text = node.text().as_string();
|
||||
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsFloat(XmlNode &node, ai_real &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_float();
|
||||
|
||||
return true;
|
||||
}
|
||||
static inline bool getValueAsFloat(XmlNode &node, ai_real &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.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsInt(XmlNode &node, int &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_int();
|
||||
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsBool(XmlNode& node, bool& v)
|
||||
{
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_bool();
|
||||
|
||||
return true;
|
||||
}
|
||||
static inline bool getValueAsBool(XmlNode &node, bool &v);
|
||||
|
||||
private:
|
||||
pugi::xml_document *mDoc;
|
||||
|
|
@ -395,6 +229,254 @@ private:
|
|||
std::vector<char> mData;
|
||||
};
|
||||
|
||||
template <class TNodeType>
|
||||
inline TXmlParser<TNodeType>::TXmlParser() :
|
||||
mDoc(nullptr),
|
||||
mData() {
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline TXmlParser<TNodeType>::~TXmlParser() {
|
||||
clear();
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline void TXmlParser<TNodeType>::clear() {
|
||||
if (mData.empty()) {
|
||||
if (mDoc) {
|
||||
delete mDoc;
|
||||
}
|
||||
mDoc = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mData.clear();
|
||||
delete mDoc;
|
||||
mDoc = nullptr;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline TNodeType *TXmlParser<TNodeType>::findNode(const std::string &name) {
|
||||
if (name.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (nullptr == mDoc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
find_node_by_name_predicate predicate(name);
|
||||
mCurrent = mDoc->find_node(predicate);
|
||||
if (mCurrent.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &mCurrent;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
bool TXmlParser<TNodeType>::hasNode(const std::string &name) {
|
||||
return nullptr != findNode(name);
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
bool TXmlParser<TNodeType>::parse(IOStream *stream) {
|
||||
if (hasRoot()) {
|
||||
clear();
|
||||
}
|
||||
|
||||
if (nullptr == stream) {
|
||||
ASSIMP_LOG_DEBUG("Stream is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t len = stream->FileSize();
|
||||
mData.resize(len + 1);
|
||||
memset(&mData[0], '\0', len + 1);
|
||||
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);
|
||||
if (parse_result.status == pugi::status_ok) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ASSIMP_LOG_DEBUG("Error while parse xml.", std::string(parse_result.description()), " @ ", parse_result.offset);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
bool TXmlParser<TNodeType>::hasRoot() const {
|
||||
return nullptr != mDoc;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
pugi::xml_document *TXmlParser<TNodeType>::getDocument() const {
|
||||
return mDoc;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
const TNodeType TXmlParser<TNodeType>::getRootNode() const {
|
||||
static pugi::xml_node none;
|
||||
if (nullptr == mDoc) {
|
||||
return none;
|
||||
}
|
||||
return mDoc->root();
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
TNodeType TXmlParser<TNodeType>::getRootNode() {
|
||||
static pugi::xml_node none;
|
||||
if (nullptr == mDoc) {
|
||||
return none;
|
||||
}
|
||||
|
||||
return mDoc->root();
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::hasNode(XmlNode &node, const char *name) {
|
||||
pugi::xml_node child = node.find_child(find_node_by_name_predicate(name));
|
||||
return !child.empty();
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::hasAttribute(XmlNode &xmlNode, const char *name) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
return !attr.empty();
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getUIntAttribute(XmlNode &xmlNode, const char *name, unsigned int &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_uint();
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getIntAttribute(XmlNode &xmlNode, const char *name, int &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_int();
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
#ifdef ASSIMP_DOUBLE_PRECISION
|
||||
val = attr.as_double();
|
||||
#else
|
||||
val = attr.as_float();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getFloatAttribute(XmlNode &xmlNode, const char *name, float &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_float();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getDoubleAttribute(XmlNode &xmlNode, const char *name, double &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_double();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getStdStrAttribute(XmlNode &xmlNode, const char *name, std::string &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_string();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val) {
|
||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||
if (attr.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val = attr.as_bool();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &text) {
|
||||
text = std::string();
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
text = node.text().as_string();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, ai_real &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_float();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsInt(XmlNode &node, int &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_int();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsBool(XmlNode &node, bool &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_bool();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
using XmlParser = TXmlParser<pugi::xml_node>;
|
||||
|
||||
/// @brief This class declares an iterator to loop through all children of the root node.
|
||||
|
|
@ -419,10 +501,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/// @brief The class destructor.
|
||||
~XmlNodeIterator() {
|
||||
// empty
|
||||
}
|
||||
/// @brief The class destructor, default implementation.
|
||||
~XmlNodeIterator() = default;
|
||||
|
||||
/// @brief Will iterate through all children in pre-order iteration.
|
||||
/// @param node [in] The nod to iterate through.
|
||||
|
|
|
|||
|
|
@ -73,9 +73,7 @@ struct aiAABB {
|
|||
}
|
||||
|
||||
/// @brief The class destructor.
|
||||
~aiAABB() {
|
||||
// empty
|
||||
}
|
||||
~aiAABB() = default;
|
||||
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
Copyright (c) 2006-2022, 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.
|
||||
|
|
@ -541,7 +512,6 @@ enum aiComponent
|
|||
#define AI_CONFIG_FAVOUR_SPEED \
|
||||
"FAVOUR_SPEED"
|
||||
|
||||
|
||||
// ###########################################################################
|
||||
// IMPORTER SETTINGS
|
||||
// Various stuff to fine-tune the behaviour of specific importer plugins.
|
||||
|
|
@ -691,6 +661,15 @@ enum aiComponent
|
|||
#define AI_CONFIG_FBX_CONVERT_TO_M \
|
||||
"AI_CONFIG_FBX_CONVERT_TO_M"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Will enable the skeleton structo to store bone data.
|
||||
*
|
||||
* This will decouple the bone coupling to the mesh. This feature is
|
||||
* experimental.
|
||||
*/
|
||||
#define AI_CONFIG_FBX_USE_SKELETON_BONE_CONTAINER \
|
||||
"AI_CONFIG_FBX_USE_SKELETON_BONE_CONTAINER"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the vertex animation keyframe to be imported
|
||||
*
|
||||
|
|
@ -1081,6 +1060,8 @@ 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"
|
||||
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ enum aiTextureType {
|
|||
|
||||
// -------------------------------------------------------------------------------
|
||||
// Get a string for a given aiTextureType
|
||||
ASSIMP_API const char *TextureTypeToString(enum aiTextureType in);
|
||||
ASSIMP_API const char *aiTextureTypeToString(enum aiTextureType in);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Defines all shading models supported by the library
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ AI_FORCE_INLINE
|
|||
case aiPTI_Float:
|
||||
case aiPTI_Double: {
|
||||
// Read as float and cast to bool
|
||||
float value = 0.0f;
|
||||
ai_real value = 0.0f;
|
||||
if (AI_SUCCESS == ::aiGetMaterialFloat(this, pKey, type, idx, &value)) {
|
||||
pOut = static_cast<bool>(value);
|
||||
return AI_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ extern "C" {
|
|||
* primitive are actually present in a mesh. The #aiProcess_SortByPType flag
|
||||
* executes a special post-processing algorithm which splits meshes with
|
||||
* *different* primitive types mixed up (e.g. lines and triangles) in several
|
||||
* 'clean' submeshes. Furthermore there is a configuration option (
|
||||
* 'clean' sub-meshes. Furthermore there is a configuration option (
|
||||
* #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove
|
||||
* specific kinds of primitives from the imported scene, completely and forever.
|
||||
* In many cases you'll probably want to set this setting to
|
||||
|
|
@ -269,19 +269,19 @@ struct aiBone {
|
|||
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.
|
||||
C_STRUCT aiVertexWeight *mWeights;
|
||||
|
||||
/** Matrix that transforms from bone space to mesh 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.
|
||||
|
|
@ -296,7 +296,7 @@ struct aiBone {
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor
|
||||
/// @brief Default constructor
|
||||
aiBone() AI_NO_EXCEPT
|
||||
: mName(),
|
||||
mNumWeights(0),
|
||||
|
|
@ -309,7 +309,7 @@ struct aiBone {
|
|||
// empty
|
||||
}
|
||||
|
||||
//! Copy constructor
|
||||
/// @brief Copy constructor
|
||||
aiBone(const aiBone &other) :
|
||||
mName(other.mName),
|
||||
mNumWeights(other.mNumWeights),
|
||||
|
|
@ -319,14 +319,27 @@ struct aiBone {
|
|||
#endif
|
||||
mWeights(nullptr),
|
||||
mOffsetMatrix(other.mOffsetMatrix) {
|
||||
if (other.mWeights && other.mNumWeights) {
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||
copyVertexWeights(other);
|
||||
}
|
||||
|
||||
void copyVertexWeights( const aiBone &other ) {
|
||||
if (other.mWeights == nullptr || other.mNumWeights == 0) {
|
||||
mWeights = nullptr;
|
||||
mNumWeights = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
mNumWeights = other.mNumWeights;
|
||||
if (mWeights) {
|
||||
delete[] mWeights;
|
||||
}
|
||||
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||
}
|
||||
|
||||
//! Assignment operator
|
||||
aiBone &operator=(const aiBone &other) {
|
||||
aiBone &operator = (const aiBone &other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -334,21 +347,13 @@ struct aiBone {
|
|||
mName = other.mName;
|
||||
mNumWeights = other.mNumWeights;
|
||||
mOffsetMatrix = other.mOffsetMatrix;
|
||||
|
||||
if (other.mWeights && other.mNumWeights) {
|
||||
if (mWeights) {
|
||||
delete[] mWeights;
|
||||
}
|
||||
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||
}
|
||||
copyVertexWeights(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const aiBone &rhs) const {
|
||||
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights) {
|
||||
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -937,6 +942,100 @@ struct aiMesh {
|
|||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
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
|
||||
/// 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
|
||||
C_STRUCT aiNode *mNode;
|
||||
|
||||
#endif
|
||||
/// @brief The number of weights
|
||||
unsigned int mNumnWeights;
|
||||
|
||||
/// The mesh index, which will get influenced by the weight.
|
||||
C_STRUCT aiMesh *mMeshId;
|
||||
|
||||
/// The influence weights of this bone, by vertex index.
|
||||
C_STRUCT aiVertexWeight *mWeights;
|
||||
|
||||
/** Matrix that transforms from bone space to mesh space in bind pose.
|
||||
*
|
||||
* This matrix describes the position of the mesh
|
||||
* in the local space of this bone when the skeleton was bound.
|
||||
* Thus it can be used directly to determine a desired vertex position,
|
||||
* given the world-space transform of the bone when animated,
|
||||
* and the position of the vertex in mesh space.
|
||||
*
|
||||
* It is sometimes called an inverse-bind matrix,
|
||||
* or inverse bind pose matrix.
|
||||
*/
|
||||
C_STRUCT aiMatrix4x4 mOffsetMatrix;
|
||||
|
||||
/// Matrix that transforms the locale bone in bind pose.
|
||||
C_STRUCT aiMatrix4x4 mLocalMatrix;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiSkeletonBone() :
|
||||
mParent(-1),
|
||||
mArmature(nullptr),
|
||||
mNode(nullptr),
|
||||
mNumnWeights(0),
|
||||
mMeshId(nullptr),
|
||||
mWeights(nullptr),
|
||||
mOffsetMatrix(),
|
||||
mLocalMatrix() {
|
||||
// empty
|
||||
}
|
||||
|
||||
~aiSkeletonBone() {
|
||||
delete[] mWeights;
|
||||
mWeights = nullptr;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
struct aiSkeleton {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
C_STRUCT aiString mName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
unsigned int mNumBones;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
C_STRUCT aiSkeletonBone **mBones;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
*
|
||||
*/
|
||||
aiSkeleton() AI_NO_EXCEPT : mName(), mNumBones(0), mBones(nullptr) {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
~aiSkeleton() {
|
||||
delete[] mBones;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //! extern "C"
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ extern "C" {
|
|||
* the imported scene does consist of only a single root node without children.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
struct ASSIMP_API aiNode
|
||||
{
|
||||
struct ASSIMP_API aiNode {
|
||||
/** The name of the node.
|
||||
*
|
||||
* The name might be empty (length of zero) but all nodes which
|
||||
|
|
@ -343,6 +342,16 @@ struct aiScene
|
|||
*/
|
||||
C_STRUCT aiString mName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
unsigned int mNumSkeletons;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
C_STRUCT aiSkeleton **mSkeletons;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor - set everything to 0/nullptr
|
||||
|
|
@ -383,6 +392,10 @@ struct aiScene
|
|||
return mAnimations != nullptr && mNumAnimations > 0;
|
||||
}
|
||||
|
||||
bool hasSkeletons() const {
|
||||
return mSkeletons != nullptr && mNumSkeletons > 0;
|
||||
}
|
||||
|
||||
//! Returns a short filename from a full path
|
||||
static const char* GetShortFilename(const char* filename) {
|
||||
const char* lastSlash = strrchr(filename, '/');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue