mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 13:00:33 +00:00
update assimp to 5.2.5 Bugfix-Release
This commit is contained in:
parent
360edf18a1
commit
c3f53b99ea
886 changed files with 7946 additions and 524449 deletions
|
|
@ -305,16 +305,19 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
|||
}
|
||||
}
|
||||
|
||||
if (nodes.empty()) {
|
||||
if (nodes.size()) {
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
}
|
||||
nodes.clear();
|
||||
} else {
|
||||
parent->mNumChildren = 0;
|
||||
parent->mChildren = nullptr;
|
||||
}
|
||||
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i) {
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
}
|
||||
}
|
||||
|
||||
void FBXConverter::ConvertLights(const Model &model, const std::string &orig_name) {
|
||||
|
|
|
|||
|
|
@ -415,11 +415,9 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
{
|
||||
bool isDirect = ReferenceInformationType == "Direct";
|
||||
bool isIndexToDirect = ReferenceInformationType == "IndexToDirect";
|
||||
const bool hasDataElement = HasElement(source, dataElementName);
|
||||
const bool hasIndexDataElement = HasElement(source, indexDataElementName);
|
||||
|
||||
// fall-back to direct data if there is no index data element
|
||||
if (isIndexToDirect && !hasIndexDataElement) {
|
||||
if ( isIndexToDirect && !HasElement( source, indexDataElementName ) ) {
|
||||
isDirect = true;
|
||||
isIndexToDirect = false;
|
||||
}
|
||||
|
|
@ -428,8 +426,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
// deal with this more elegantly and with less redundancy, but right
|
||||
// now it seems unavoidable.
|
||||
if (MappingInformationType == "ByVertice" && isDirect) {
|
||||
if (!hasDataElement) {
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!HasElement(source, dataElementName)) {
|
||||
return;
|
||||
}
|
||||
std::vector<T> tempData;
|
||||
|
|
@ -451,15 +448,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
else if (MappingInformationType == "ByVertice" && isIndexToDirect) {
|
||||
std::vector<T> tempData;
|
||||
if (!hasDataElement || !hasIndexDataElement) {
|
||||
if (!hasDataElement)
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!hasIndexDataElement)
|
||||
FBXImporter::LogWarn("missing index data element: ", indexDataElementName);
|
||||
return;
|
||||
}
|
||||
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
std::vector<int> uvIndices;
|
||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||
|
|
@ -484,11 +473,6 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
}
|
||||
else if (MappingInformationType == "ByPolygonVertex" && isDirect) {
|
||||
if (!hasDataElement) {
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<T> tempData;
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
|
|
@ -503,14 +487,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
else if (MappingInformationType == "ByPolygonVertex" && isIndexToDirect) {
|
||||
std::vector<T> tempData;
|
||||
if (!hasDataElement || !hasIndexDataElement) {
|
||||
if (!hasDataElement)
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!hasIndexDataElement)
|
||||
FBXImporter::LogWarn("missing index data element: ", indexDataElementName);
|
||||
return;
|
||||
}
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
std::vector<int> uvIndices;
|
||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||
|
|
|
|||
|
|
@ -60,11 +60,14 @@ using namespace Assimp::MD5;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse the segment structure for an MD5 file
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), bufferEnd(nullptr), fileSize(_fileSize), lineNumber(0) {
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) {
|
||||
ai_assert(nullptr != _buffer);
|
||||
ai_assert(0 != _fileSize);
|
||||
|
||||
bufferEnd = buffer + fileSize;
|
||||
buffer = _buffer;
|
||||
fileSize = _fileSize;
|
||||
lineNumber = 0;
|
||||
|
||||
ASSIMP_LOG_DEBUG("MD5Parser begin");
|
||||
|
||||
// parse the file header
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
/** @file MD5Parser.h
|
||||
* @brief Definition of the .MD5 parser class.
|
||||
|
|
@ -51,19 +51,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/types.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
struct aiFace;
|
||||
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a single element in a MD5 file
|
||||
*
|
||||
* Elements are always contained in sections.
|
||||
*/
|
||||
struct Element {
|
||||
struct Element
|
||||
{
|
||||
//! Points to the starting point of the element
|
||||
//! Whitespace at the beginning and at the end have been removed,
|
||||
//! Elements are terminated with \0
|
||||
|
|
@ -74,14 +75,15 @@ struct Element {
|
|||
unsigned int iLineNumber;
|
||||
};
|
||||
|
||||
using ElementList = std::vector<Element>;
|
||||
typedef std::vector< Element > ElementList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a section of a MD5 file (such as the mesh or the joints section)
|
||||
*
|
||||
* A section is always enclosed in { and } brackets.
|
||||
*/
|
||||
struct Section {
|
||||
struct Section
|
||||
{
|
||||
//! Original line number (can be used in error messages
|
||||
//! if a parsing error occurs)
|
||||
unsigned int iLineNumber;
|
||||
|
|
@ -97,12 +99,13 @@ struct Section {
|
|||
std::string mGlobalValue;
|
||||
};
|
||||
|
||||
using SectionList = std::vector<Section>;
|
||||
typedef std::vector< Section> SectionList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Basic information about a joint
|
||||
*/
|
||||
struct BaseJointDescription {
|
||||
struct BaseJointDescription
|
||||
{
|
||||
//! Name of the bone
|
||||
aiString mName;
|
||||
|
||||
|
|
@ -113,7 +116,8 @@ struct BaseJointDescription {
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Mesh file
|
||||
*/
|
||||
struct BoneDesc : BaseJointDescription {
|
||||
struct BoneDesc : BaseJointDescription
|
||||
{
|
||||
//! Absolute position of the bone
|
||||
aiVector3D mPositionXYZ;
|
||||
|
||||
|
|
@ -133,12 +137,13 @@ struct BoneDesc : BaseJointDescription {
|
|||
unsigned int mMap;
|
||||
};
|
||||
|
||||
using BoneList = std::vector<BoneDesc>;
|
||||
typedef std::vector< BoneDesc > BoneList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Anim file
|
||||
*/
|
||||
struct AnimBoneDesc : BaseJointDescription {
|
||||
struct AnimBoneDesc : BaseJointDescription
|
||||
{
|
||||
//! Flags (AI_MD5_ANIMATION_FLAG_xxx)
|
||||
unsigned int iFlags;
|
||||
|
||||
|
|
@ -146,31 +151,35 @@ struct AnimBoneDesc : BaseJointDescription {
|
|||
unsigned int iFirstKeyIndex;
|
||||
};
|
||||
|
||||
using AnimBoneList = std::vector< AnimBoneDesc >;
|
||||
typedef std::vector< AnimBoneDesc > AnimBoneList;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a base frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct BaseFrameDesc {
|
||||
struct BaseFrameDesc
|
||||
{
|
||||
aiVector3D vPositionXYZ;
|
||||
aiVector3D vRotationQuat;
|
||||
};
|
||||
|
||||
using BaseFrameList = std::vector<BaseFrameDesc>;
|
||||
typedef std::vector< BaseFrameDesc > BaseFrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a camera animation frame in a MDCamera file
|
||||
*/
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc {
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc
|
||||
{
|
||||
float fFOV;
|
||||
};
|
||||
|
||||
using CameraFrameList = std::vector<CameraAnimFrameDesc>;
|
||||
typedef std::vector< CameraAnimFrameDesc > CameraFrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct FrameDesc {
|
||||
struct FrameDesc
|
||||
{
|
||||
//! Index of the frame
|
||||
unsigned int iIndex;
|
||||
|
||||
|
|
@ -178,14 +187,15 @@ struct FrameDesc {
|
|||
std::vector< float > mValues;
|
||||
};
|
||||
|
||||
using FrameList = std::vector<FrameDesc>;
|
||||
typedef std::vector< FrameDesc > FrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex descriptor in a MD5 file
|
||||
*/
|
||||
struct VertexDesc {
|
||||
VertexDesc() AI_NO_EXCEPT
|
||||
: mFirstWeight(0), mNumWeights(0) {
|
||||
: mFirstWeight(0)
|
||||
, mNumWeights(0) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
@ -200,12 +210,13 @@ struct VertexDesc {
|
|||
unsigned int mNumWeights;
|
||||
};
|
||||
|
||||
using VertexList = std::vector<VertexDesc>;
|
||||
typedef std::vector< VertexDesc > VertexList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex weight descriptor in a MD5 file
|
||||
*/
|
||||
struct WeightDesc {
|
||||
struct WeightDesc
|
||||
{
|
||||
//! Index of the bone to which this weight refers
|
||||
unsigned int mBone;
|
||||
|
||||
|
|
@ -217,13 +228,14 @@ struct WeightDesc {
|
|||
aiVector3D vOffsetPosition;
|
||||
};
|
||||
|
||||
using WeightList = std::vector<WeightDesc>;
|
||||
using FaceList = std::vector<aiFace>;
|
||||
typedef std::vector< WeightDesc > WeightList;
|
||||
typedef std::vector< aiFace > FaceList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a mesh in a MD5 file
|
||||
*/
|
||||
struct MeshDesc {
|
||||
struct MeshDesc
|
||||
{
|
||||
//! Weights of the mesh
|
||||
WeightList mWeights;
|
||||
|
||||
|
|
@ -237,7 +249,7 @@ struct MeshDesc {
|
|||
aiString mShader;
|
||||
};
|
||||
|
||||
using MeshList = std::vector<MeshDesc>;
|
||||
typedef std::vector< MeshDesc > MeshList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Convert a quaternion to its usual representation
|
||||
|
|
@ -249,11 +261,9 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
|
||||
const float t = 1.0f - (in.x*in.x) - (in.y*in.y) - (in.z*in.z);
|
||||
|
||||
if (t < 0.0f) {
|
||||
if (t < 0.0f)
|
||||
out.w = 0.0f;
|
||||
} else {
|
||||
out.w = std::sqrt (t);
|
||||
}
|
||||
else out.w = std::sqrt (t);
|
||||
|
||||
// Assimp convention.
|
||||
out.w *= -1.f;
|
||||
|
|
@ -262,8 +272,10 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 mesh file
|
||||
*/
|
||||
class MD5MeshParser {
|
||||
class MD5MeshParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5MeshParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -285,8 +297,10 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 animation file
|
||||
*/
|
||||
class MD5AnimParser {
|
||||
class MD5AnimParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5AnimParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -315,8 +329,10 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 camera animation file
|
||||
*/
|
||||
class MD5CameraParser {
|
||||
class MD5CameraParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5CameraParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -325,6 +341,7 @@ public:
|
|||
*/
|
||||
explicit MD5CameraParser(SectionList& mSections);
|
||||
|
||||
|
||||
//! Output frame rate
|
||||
float fFrameRate;
|
||||
|
||||
|
|
@ -339,8 +356,10 @@ public:
|
|||
/** Parses the block structure of MD5MESH and MD5ANIM files (but does no
|
||||
* further processing)
|
||||
*/
|
||||
class MD5Parser {
|
||||
class MD5Parser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5Parser instance from an existing buffer.
|
||||
*
|
||||
|
|
@ -373,10 +392,13 @@ public:
|
|||
return ReportWarning(warn, lineNumber);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! List of all sections which have been read
|
||||
SectionList mSections;
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parses a file section. The current file pointer must be outside
|
||||
* of a section.
|
||||
|
|
@ -392,63 +414,54 @@ private:
|
|||
*/
|
||||
void ParseHeader();
|
||||
|
||||
bool SkipLine(const char* in, const char** out);
|
||||
bool SkipLine( );
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd();
|
||||
bool SkipSpaces();
|
||||
|
||||
// override these functions to make sure the line counter gets incremented
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( const char* in, const char** out)
|
||||
{
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in,out);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( )
|
||||
{
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out)
|
||||
{
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
in++;
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( )
|
||||
{
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpaces( )
|
||||
{
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
|
||||
char* buffer;
|
||||
char* bufferEnd;
|
||||
unsigned int fileSize;
|
||||
unsigned int lineNumber;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in ,out);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine( ) {
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
++in;
|
||||
if (in == bufferEnd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd() {
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpaces() {
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
} // namespace MD5
|
||||
}}
|
||||
|
||||
#endif // AI_MD5PARSER_H_INCLUDED
|
||||
|
|
|
|||
|
|
@ -75,10 +75,15 @@ static const aiImporterDesc desc = {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
XFileImporter::XFileImporter() : mBuffer() {
|
||||
XFileImporter::XFileImporter()
|
||||
: mBuffer() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
XFileImporter::~XFileImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace XFile {
|
|||
class XFileImporter : public BaseImporter {
|
||||
public:
|
||||
XFileImporter();
|
||||
~XFileImporter() override = default;
|
||||
~XFileImporter() override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue