mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
* Adjustment: Update Assimp version to 5.0.1.
This commit is contained in:
parent
14ebeaf3eb
commit
4758f7bdaf
679 changed files with 50502 additions and 19698 deletions
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -110,7 +110,10 @@ struct Object {
|
|||
std::vector<unsigned int> m_Meshes;
|
||||
|
||||
//! \brief Default constructor
|
||||
Object() = default;
|
||||
Object()
|
||||
: m_strObjName("") {
|
||||
// empty
|
||||
}
|
||||
|
||||
//! \brief Destructor
|
||||
~Object() {
|
||||
|
|
@ -188,12 +191,16 @@ struct Material {
|
|||
, illumination_model (1)
|
||||
, ior ( ai_real( 1.0 ) )
|
||||
, transparent( ai_real( 1.0), ai_real (1.0), ai_real(1.0)) {
|
||||
|
||||
std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
|
||||
// empty
|
||||
for (size_t i = 0; i < TextureTypeCount; ++i) {
|
||||
clamp[ i ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~Material() = default;
|
||||
~Material() {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -175,15 +175,15 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene
|
|||
ai_assert(false);
|
||||
}
|
||||
|
||||
if (!pModel->m_Objects.empty()) {
|
||||
if (pModel->m_Objects.size() > 0) {
|
||||
|
||||
unsigned int meshCount = 0;
|
||||
unsigned int childCount = 0;
|
||||
|
||||
for (auto object : pModel->m_Objects) {
|
||||
if(object) {
|
||||
for(size_t index = 0; index < pModel->m_Objects.size(); ++index) {
|
||||
if(pModel->m_Objects[index]) {
|
||||
++childCount;
|
||||
meshCount += (unsigned int)object->m_Meshes.size();
|
||||
meshCount += (unsigned int)pModel->m_Objects[index]->m_Meshes.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,8 +365,8 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj
|
|||
unsigned int outIndex( 0 );
|
||||
|
||||
// Copy all data from all stored meshes
|
||||
for (auto& face : pObjMesh->m_Faces) {
|
||||
ObjFile::Face* const inp = face;
|
||||
for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++) {
|
||||
ObjFile::Face* const inp = pObjMesh->m_Faces[ index ];
|
||||
if (inp->m_PrimitiveType == aiPrimitiveType_LINE) {
|
||||
for(size_t i = 0; i < inp->m_vertices.size() - 1; ++i) {
|
||||
aiFace& f = pMesh->mFaces[ outIndex++ ];
|
||||
|
|
@ -385,7 +385,7 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj
|
|||
}
|
||||
|
||||
aiFace *pFace = &pMesh->mFaces[ outIndex++ ];
|
||||
const unsigned int uiNumIndices = (unsigned int) face->m_vertices.size();
|
||||
const unsigned int uiNumIndices = (unsigned int) pObjMesh->m_Faces[ index ]->m_vertices.size();
|
||||
uiIdxCount += pFace->mNumIndices = (unsigned int) uiNumIndices;
|
||||
if (pFace->mNumIndices > 0) {
|
||||
pFace->mIndices = new unsigned int[ uiNumIndices ];
|
||||
|
|
@ -446,10 +446,13 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
|||
// Copy vertices, normals and textures into aiMesh instance
|
||||
bool normalsok = true, uvok = true;
|
||||
unsigned int newIndex = 0, outIndex = 0;
|
||||
for (auto sourceFace : pObjMesh->m_Faces) {
|
||||
for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ ) {
|
||||
// Get source face
|
||||
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
|
||||
|
||||
// Copy all index arrays
|
||||
for (size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < sourceFace->m_vertices.size(); vertexIndex++ ) {
|
||||
const unsigned int vertex = sourceFace->m_vertices.at(vertexIndex );
|
||||
for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_vertices.size(); vertexIndex++ ) {
|
||||
const unsigned int vertex = pSourceFace->m_vertices.at( vertexIndex );
|
||||
if ( vertex >= pModel->m_Vertices.size() ) {
|
||||
throw DeadlyImportError( "OBJ: vertex index out of range" );
|
||||
}
|
||||
|
|
@ -461,8 +464,8 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
|||
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
|
||||
|
||||
// Copy all normals
|
||||
if ( normalsok && !pModel->m_Normals.empty() && vertexIndex < sourceFace->m_normals.size()) {
|
||||
const unsigned int normal = sourceFace->m_normals.at(vertexIndex );
|
||||
if ( normalsok && !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_normals.size()) {
|
||||
const unsigned int normal = pSourceFace->m_normals.at( vertexIndex );
|
||||
if ( normal >= pModel->m_Normals.size() )
|
||||
{
|
||||
normalsok = false;
|
||||
|
|
@ -481,9 +484,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
|||
}
|
||||
|
||||
// Copy all texture coordinates
|
||||
if ( uvok && !pModel->m_TextureCoord.empty() && vertexIndex < sourceFace->m_texturCoords.size())
|
||||
if ( uvok && !pModel->m_TextureCoord.empty() && vertexIndex < pSourceFace->m_texturCoords.size())
|
||||
{
|
||||
const unsigned int tex = sourceFace->m_texturCoords.at(vertexIndex );
|
||||
const unsigned int tex = pSourceFace->m_texturCoords.at( vertexIndex );
|
||||
|
||||
if ( tex >= pModel->m_TextureCoord.size() )
|
||||
{
|
||||
|
|
@ -499,16 +502,16 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
|||
// Get destination face
|
||||
aiFace *pDestFace = &pMesh->mFaces[ outIndex ];
|
||||
|
||||
const bool last = (vertexIndex == sourceFace->m_vertices.size() - 1 );
|
||||
if (sourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last) {
|
||||
const bool last = ( vertexIndex == pSourceFace->m_vertices.size() - 1 );
|
||||
if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last) {
|
||||
pDestFace->mIndices[ outVertexIndex ] = newIndex;
|
||||
outVertexIndex++;
|
||||
}
|
||||
|
||||
if (sourceFace->m_PrimitiveType == aiPrimitiveType_POINT) {
|
||||
if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT) {
|
||||
outIndex++;
|
||||
outVertexIndex = 0;
|
||||
} else if (sourceFace->m_PrimitiveType == aiPrimitiveType_LINE) {
|
||||
} else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE) {
|
||||
outVertexIndex = 0;
|
||||
|
||||
if(!last)
|
||||
|
|
@ -517,7 +520,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
|||
if (vertexIndex) {
|
||||
if(!last) {
|
||||
pMesh->mVertices[ newIndex+1 ] = pMesh->mVertices[ newIndex ];
|
||||
if (!sourceFace->m_normals.empty() && !pModel->m_Normals.empty()) {
|
||||
if ( !pSourceFace->m_normals.empty() && !pModel->m_Normals.empty()) {
|
||||
pMesh->mNormals[ newIndex+1 ] = pMesh->mNormals[newIndex ];
|
||||
}
|
||||
if ( !pModel->m_TextureCoord.empty() ) {
|
||||
|
|
@ -560,11 +563,13 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
|
|||
return;
|
||||
|
||||
iNumMeshes += static_cast<unsigned int>( rObjects.size() );
|
||||
for (auto object: rObjects)
|
||||
for (std::vector<ObjFile::Object*>::const_iterator it = rObjects.begin();
|
||||
it != rObjects.end();
|
||||
++it)
|
||||
{
|
||||
if (!object->m_SubObjects.empty())
|
||||
if (!(*it)->m_SubObjects.empty())
|
||||
{
|
||||
countObjects(object->m_SubObjects, iNumMeshes);
|
||||
countObjects((*it)->m_SubObjects, iNumMeshes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ void ObjFileMtlImporter::getFloatValue( ai_real &value )
|
|||
// Creates a material from loaded data.
|
||||
void ObjFileMtlImporter::createMaterial()
|
||||
{
|
||||
std::string line;
|
||||
std::string line( "" );
|
||||
while( !IsLineEnd( *m_DataIt ) ) {
|
||||
line += *m_DataIt;
|
||||
++m_DataIt;
|
||||
|
|
@ -282,7 +282,7 @@ void ObjFileMtlImporter::createMaterial()
|
|||
|
||||
std::vector<std::string> token;
|
||||
const unsigned int numToken = tokenize<std::string>( line, token, " \t" );
|
||||
std::string name;
|
||||
std::string name( "" );
|
||||
if ( numToken == 1 ) {
|
||||
name = AI_DEFAULT_MATERIAL_NAME;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,8 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/material.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
@ -73,16 +71,16 @@ ObjFileParser::ObjFileParser()
|
|||
|
||||
ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName,
|
||||
IOSystem *io, ProgressHandler* progress,
|
||||
std::string originalObjFileName) :
|
||||
const std::string &originalObjFileName) :
|
||||
m_DataIt(),
|
||||
m_DataItEnd(),
|
||||
m_pModel(nullptr),
|
||||
m_uiLine(0),
|
||||
m_pIO(io),
|
||||
m_pIO( io ),
|
||||
m_progress(progress),
|
||||
m_originalObjFileName(std::move(originalObjFileName))
|
||||
m_originalObjFileName(originalObjFileName)
|
||||
{
|
||||
std::fill_n(m_buffer, Buffersize,0);
|
||||
std::fill_n(m_buffer,Buffersize,0);
|
||||
|
||||
// Create the model instance to store all the data
|
||||
m_pModel.reset(new ObjFile::Model());
|
||||
|
|
@ -98,8 +96,7 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
|
|||
parseFile( streamBuffer );
|
||||
}
|
||||
|
||||
ObjFileParser::~ObjFileParser()
|
||||
{
|
||||
ObjFileParser::~ObjFileParser() {
|
||||
}
|
||||
|
||||
void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
|
||||
|
|
@ -131,7 +128,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|||
processed = static_cast<unsigned int>(filePos);
|
||||
lastFilePos = filePos;
|
||||
progressCounter++;
|
||||
m_progress->UpdateFileRead(processed, progressTotal);
|
||||
m_progress->UpdateFileRead( processed, progressTotal );
|
||||
}
|
||||
|
||||
// parse line
|
||||
|
|
@ -185,7 +182,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|||
|
||||
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
||||
|
||||
size_t nextSpace = name.find(' ');
|
||||
size_t nextSpace = name.find(" ");
|
||||
if (nextSpace != std::string::npos)
|
||||
name = name.substr(0, nextSpace);
|
||||
|
||||
|
|
@ -202,7 +199,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|||
|
||||
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
||||
|
||||
size_t nextSpace = name.find(' ');
|
||||
size_t nextSpace = name.find(" ");
|
||||
if (nextSpace != std::string::npos)
|
||||
name = name.substr(0, nextSpace);
|
||||
|
||||
|
|
@ -277,8 +274,13 @@ static bool isDataDefinitionEnd( const char *tmp ) {
|
|||
|
||||
static bool isNanOrInf(const char * in) {
|
||||
// Look for "nan" or "inf", case insensitive
|
||||
return ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) ||
|
||||
((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0);
|
||||
if ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) {
|
||||
return true;
|
||||
}
|
||||
else if ((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t ObjFileParser::getNumComponentsInDataDefinition() {
|
||||
|
|
@ -339,7 +341,7 @@ size_t ObjFileParser::getTexCoordVector( std::vector<aiVector3D> &point3d_array
|
|||
if (!std::isfinite(z))
|
||||
z = 0;
|
||||
|
||||
point3d_array.emplace_back( x, y, z );
|
||||
point3d_array.push_back( aiVector3D( x, y, z ) );
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
return numComponents;
|
||||
}
|
||||
|
|
@ -355,7 +357,7 @@ void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
|||
copyNextWord( m_buffer, Buffersize );
|
||||
z = ( ai_real ) fast_atof( m_buffer );
|
||||
|
||||
point3d_array.emplace_back( x, y, z );
|
||||
point3d_array.push_back( aiVector3D( x, y, z ) );
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +378,7 @@ void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_arra
|
|||
if (w == 0)
|
||||
throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)");
|
||||
|
||||
point3d_array.emplace_back( x/w, y/w, z/w );
|
||||
point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) );
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +393,7 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
|
|||
copyNextWord( m_buffer, Buffersize );
|
||||
z = ( ai_real ) fast_atof( m_buffer );
|
||||
|
||||
point3d_array_a.emplace_back( x, y, z );
|
||||
point3d_array_a.push_back( aiVector3D( x, y, z ) );
|
||||
|
||||
copyNextWord(m_buffer, Buffersize);
|
||||
x = (ai_real) fast_atof(m_buffer);
|
||||
|
|
@ -402,7 +404,7 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
|
|||
copyNextWord( m_buffer, Buffersize );
|
||||
z = ( ai_real ) fast_atof( m_buffer );
|
||||
|
||||
point3d_array_b.emplace_back( x, y, z );
|
||||
point3d_array_b.push_back( aiVector3D( x, y, z ) );
|
||||
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
}
|
||||
|
|
@ -415,7 +417,7 @@ void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
|
|||
copyNextWord(m_buffer, Buffersize);
|
||||
y = (ai_real) fast_atof(m_buffer);
|
||||
|
||||
point2d_array.emplace_back(x, y);
|
||||
point2d_array.push_back(aiVector2D(x, y));
|
||||
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
}
|
||||
|
|
@ -437,9 +439,9 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
|||
|
||||
const bool vt = (!m_pModel->m_TextureCoord.empty());
|
||||
const bool vn = (!m_pModel->m_Normals.empty());
|
||||
int iPos = 0;
|
||||
int iStep = 0, iPos = 0;
|
||||
while ( m_DataIt != m_DataItEnd ) {
|
||||
int iStep = 1;
|
||||
iStep = 1;
|
||||
|
||||
if ( IsLineEnd( *m_DataIt ) ) {
|
||||
break;
|
||||
|
|
@ -843,7 +845,7 @@ void ObjFileParser::createMesh( const std::string &meshName )
|
|||
bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
||||
{
|
||||
// If no mesh data yet
|
||||
if (m_pModel->m_pCurrentMesh == nullptr)
|
||||
if(m_pModel->m_pCurrentMesh == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -854,7 +856,7 @@ bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
|||
&& curMatIdx != matIdx
|
||||
// no need create a new mesh if no faces in current
|
||||
// lets say 'usemtl' goes straight after 'g'
|
||||
&& !m_pModel->m_pCurrentMesh->m_Faces.empty() )
|
||||
&& m_pModel->m_pCurrentMesh->m_Faces.size() > 0 )
|
||||
{
|
||||
// New material -> only one material per mesh, so we need to create a new
|
||||
// material
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -78,7 +78,7 @@ public:
|
|||
/// @brief The default constructor.
|
||||
ObjFileParser();
|
||||
/// @brief Constructor with data array.
|
||||
ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, std::string originalObjFileName);
|
||||
ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, const std::string &originalObjFileName);
|
||||
/// @brief Destructor
|
||||
~ObjFileParser();
|
||||
/// @brief If you want to load in-core data.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue