Merge branch 'master' into exportGLTF
commit
5935bca90d
|
@ -258,7 +258,7 @@ IF( UNIX )
|
|||
ENDIF()
|
||||
|
||||
# Grouped compiler settings ########################################
|
||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
|
||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW AND NOT HAIKU)
|
||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
ENDIF()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
Copyright (c) 2006-2023, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -87,7 +87,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Report error to the log stream
|
||||
/*static*/ AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) {
|
||||
AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) {
|
||||
char szBuffer[1024];
|
||||
::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, error);
|
||||
throw DeadlyImportError(szBuffer);
|
||||
|
@ -95,7 +95,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Report warning to the log stream
|
||||
/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
|
||||
void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
|
||||
char szBuffer[1024];
|
||||
::snprintf(szBuffer, sizeof(szBuffer), "[MD5] Line %u: %s", line, warn);
|
||||
ASSIMP_LOG_WARN(szBuffer);
|
||||
|
@ -122,8 +122,8 @@ void MD5Parser::ParseHeader() {
|
|||
// print the command line options to the console
|
||||
// FIX: can break the log length limit, so we need to be careful
|
||||
char *sz = buffer;
|
||||
while (!IsLineEnd(*buffer++))
|
||||
;
|
||||
while (!IsLineEnd(*buffer++));
|
||||
|
||||
ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz))));
|
||||
SkipSpacesAndLineEnd();
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
|
||||
Copyright (c) 2006-2023, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -93,7 +92,7 @@ struct Section {
|
|||
std::string mName;
|
||||
|
||||
//! For global elements: the value of the element as string
|
||||
//! Iif !length() the section is not a global element
|
||||
//! if !length() the section is not a global element
|
||||
std::string mGlobalValue;
|
||||
};
|
||||
|
||||
|
@ -185,7 +184,7 @@ using FrameList = std::vector<FrameDesc>;
|
|||
*/
|
||||
struct VertexDesc {
|
||||
VertexDesc() AI_NO_EXCEPT
|
||||
: mFirstWeight(0), mNumWeights(0) {
|
||||
: mFirstWeight(0), mNumWeights(0) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -349,62 +348,61 @@ public:
|
|||
*/
|
||||
MD5Parser(char* buffer, unsigned int fileSize);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Report a specific error message and throw an exception
|
||||
* @param error Error message to be reported
|
||||
* @param line Index of the line where the error occurred
|
||||
*/
|
||||
AI_WONT_RETURN static void ReportError (const char* error, unsigned int line) AI_WONT_RETURN_SUFFIX;
|
||||
AI_WONT_RETURN static void ReportError(const char* error, unsigned int line) AI_WONT_RETURN_SUFFIX;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Report a specific warning
|
||||
* @param warn Warn message to be reported
|
||||
* @param line Index of the line where the error occurred
|
||||
*/
|
||||
static void ReportWarning (const char* warn, unsigned int line);
|
||||
|
||||
static void ReportWarning(const char* warn, unsigned int line);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Report a specific error
|
||||
* @param error Error message to be reported
|
||||
*/
|
||||
AI_WONT_RETURN void ReportError (const char* error) AI_WONT_RETURN_SUFFIX;
|
||||
|
||||
void ReportWarning (const char* warn) {
|
||||
return ReportWarning(warn, lineNumber);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
/** Report a specific warning
|
||||
* @param error Warn message to be reported
|
||||
*/
|
||||
void ReportWarning (const char* warn);
|
||||
|
||||
//! 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.
|
||||
* @param out Receives the section data
|
||||
* @return true if the end of the file has been reached
|
||||
* @throws ImportErrorException if an error occurs
|
||||
*/
|
||||
bool ParseSection(Section& out);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parses the file header
|
||||
* @throws ImportErrorException if an error occurs
|
||||
*/
|
||||
void ParseHeader();
|
||||
|
||||
bool SkipLine(const char* in, const char** out);
|
||||
bool SkipLine( );
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd();
|
||||
bool SkipSpaces();
|
||||
|
||||
private:
|
||||
char* buffer;
|
||||
char* bufferEnd;
|
||||
unsigned int fileSize;
|
||||
unsigned int lineNumber;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline void MD5Parser::ReportWarning (const char* warn) {
|
||||
return ReportWarning(warn, lineNumber);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline void MD5Parser::ReportError(const char* error) {
|
||||
ReportError(error, lineNumber);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
|
||||
++lineNumber;
|
||||
|
@ -418,18 +416,24 @@ inline bool MD5Parser::SkipLine( ) {
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
if (in == bufferEnd) {
|
||||
*out = in;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bHad = false, running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
// 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;
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
++in;
|
||||
if (in == bufferEnd) {
|
||||
break;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
Copyright (c) 2006-2023, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -273,7 +273,8 @@ void FindInvalidDataProcess::ProcessAnimation(aiAnimation *anim) {
|
|||
void FindInvalidDataProcess::ProcessAnimationChannel(aiNodeAnim *anim) {
|
||||
ai_assert(nullptr != anim);
|
||||
if (anim->mNumPositionKeys == 0 && anim->mNumRotationKeys == 0 && anim->mNumScalingKeys == 0) {
|
||||
ai_assert_entry();
|
||||
ASSIMP_LOG_ERROR("Invalid node anuimation instance detected.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <stdio.h>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -145,7 +146,7 @@ bool areVerticesEqual(
|
|||
}
|
||||
|
||||
template<class XMesh>
|
||||
void updateXMeshVertices(XMesh *pMesh, std::vector<Vertex> &uniqueVertices) {
|
||||
void updateXMeshVertices(XMesh *pMesh, std::vector<int> &uniqueVertices) {
|
||||
// replace vertex data with the unique data sets
|
||||
pMesh->mNumVertices = (unsigned int)uniqueVertices.size();
|
||||
|
||||
|
@ -156,53 +157,47 @@ void updateXMeshVertices(XMesh *pMesh, std::vector<Vertex> &uniqueVertices) {
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Position, if present (check made for aiAnimMesh)
|
||||
if (pMesh->mVertices) {
|
||||
delete [] pMesh->mVertices;
|
||||
if (pMesh->mVertices) {
|
||||
std::unique_ptr<aiVector3D[]> oldVertices(pMesh->mVertices);
|
||||
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
||||
pMesh->mVertices[a] = uniqueVertices[a].position;
|
||||
}
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
|
||||
pMesh->mVertices[a] = oldVertices[uniqueVertices[a]];
|
||||
}
|
||||
|
||||
// Normals, if present
|
||||
if (pMesh->mNormals) {
|
||||
delete [] pMesh->mNormals;
|
||||
std::unique_ptr<aiVector3D[]> oldNormals(pMesh->mNormals);
|
||||
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
|
||||
for( unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
||||
pMesh->mNormals[a] = uniqueVertices[a].normal;
|
||||
}
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
|
||||
pMesh->mNormals[a] = oldNormals[uniqueVertices[a]];
|
||||
}
|
||||
// Tangents, if present
|
||||
if (pMesh->mTangents) {
|
||||
delete [] pMesh->mTangents;
|
||||
std::unique_ptr<aiVector3D[]> oldTangents(pMesh->mTangents);
|
||||
pMesh->mTangents = new aiVector3D[pMesh->mNumVertices];
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
||||
pMesh->mTangents[a] = uniqueVertices[a].tangent;
|
||||
}
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
|
||||
pMesh->mTangents[a] = oldTangents[uniqueVertices[a]];
|
||||
}
|
||||
// Bitangents as well
|
||||
if (pMesh->mBitangents) {
|
||||
delete [] pMesh->mBitangents;
|
||||
std::unique_ptr<aiVector3D[]> oldBitangents(pMesh->mBitangents);
|
||||
pMesh->mBitangents = new aiVector3D[pMesh->mNumVertices];
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
||||
pMesh->mBitangents[a] = uniqueVertices[a].bitangent;
|
||||
}
|
||||
for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
|
||||
pMesh->mBitangents[a] = oldBitangents[uniqueVertices[a]];
|
||||
}
|
||||
// Vertex colors
|
||||
for (unsigned int a = 0; pMesh->HasVertexColors(a); a++) {
|
||||
delete [] pMesh->mColors[a];
|
||||
std::unique_ptr<aiColor4D[]> oldColors(pMesh->mColors[a]);
|
||||
pMesh->mColors[a] = new aiColor4D[pMesh->mNumVertices];
|
||||
for( unsigned int b = 0; b < pMesh->mNumVertices; b++) {
|
||||
pMesh->mColors[a][b] = uniqueVertices[b].colors[a];
|
||||
}
|
||||
for (unsigned int b = 0; b < pMesh->mNumVertices; b++)
|
||||
pMesh->mColors[a][b] = oldColors[uniqueVertices[b]];
|
||||
}
|
||||
// Texture coords
|
||||
for (unsigned int a = 0; pMesh->HasTextureCoords(a); a++) {
|
||||
delete [] pMesh->mTextureCoords[a];
|
||||
std::unique_ptr<aiVector3D[]> oldTextureCoords(pMesh->mTextureCoords[a]);
|
||||
pMesh->mTextureCoords[a] = new aiVector3D[pMesh->mNumVertices];
|
||||
for (unsigned int b = 0; b < pMesh->mNumVertices; b++) {
|
||||
pMesh->mTextureCoords[a][b] = uniqueVertices[b].texcoords[a];
|
||||
}
|
||||
for (unsigned int b = 0; b < pMesh->mNumVertices; b++)
|
||||
pMesh->mTextureCoords[a][b] = oldTextureCoords[uniqueVertices[b]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +265,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
|||
}
|
||||
|
||||
// We'll never have more vertices afterwards.
|
||||
std::vector<Vertex> uniqueVertices;
|
||||
std::vector<int> uniqueVertices;
|
||||
uniqueVertices.reserve( pMesh->mNumVertices);
|
||||
|
||||
// For each vertex the index of the vertex it was replaced by.
|
||||
|
@ -311,7 +306,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
|||
const bool hasAnimMeshes = pMesh->mNumAnimMeshes > 0;
|
||||
|
||||
// We'll never have more vertices afterwards.
|
||||
std::vector<std::vector<Vertex>> uniqueAnimatedVertices;
|
||||
std::vector<std::vector<int>> uniqueAnimatedVertices;
|
||||
if (hasAnimMeshes) {
|
||||
uniqueAnimatedVertices.resize(pMesh->mNumAnimMeshes);
|
||||
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
||||
|
@ -345,10 +340,10 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
|||
//keep track of its index and increment 1
|
||||
replaceIndex[a] = newIndex++;
|
||||
// add the vertex to the unique vertices
|
||||
uniqueVertices.push_back(v);
|
||||
uniqueVertices.push_back(a);
|
||||
if (hasAnimMeshes) {
|
||||
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
||||
uniqueAnimatedVertices[animMeshIndex].emplace_back(pMesh->mAnimMeshes[animMeshIndex], a);
|
||||
uniqueAnimatedVertices[animMeshIndex].emplace_back(a);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#else
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftello
|
||||
#define fseeko64 fseeko
|
||||
|
|
Loading…
Reference in New Issue