mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Updated assimp to latest
This commit is contained in:
parent
25ce4477ce
commit
161bf7f83b
461 changed files with 34662 additions and 30165 deletions
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -46,11 +47,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
|
||||
|
||||
#include "XGLLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
#include "StreamReader.h"
|
||||
#include "MemoryIOWrapper.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
|
|
@ -71,17 +72,6 @@ using namespace irr::io;
|
|||
#endif
|
||||
|
||||
|
||||
// scopeguard for a malloc'ed buffer
|
||||
struct free_it
|
||||
{
|
||||
free_it(void* free) : free(free) {}
|
||||
~free_it() {
|
||||
::free(this->free);
|
||||
}
|
||||
|
||||
void* free;
|
||||
};
|
||||
|
||||
namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp
|
||||
template<> const char* LogFunctions<XGLImporter>::Prefix()
|
||||
{
|
||||
|
|
@ -154,8 +144,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
|||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
#ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
|
||||
Bytef* dest = NULL;
|
||||
free_it free_it_really(dest);
|
||||
std::vector<Bytef> uncompressed;
|
||||
#endif
|
||||
|
||||
m_scene = pScene;
|
||||
|
|
@ -191,6 +180,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
size_t total = 0l;
|
||||
|
||||
// TODO: be smarter about this, decompress directly into heap buffer
|
||||
// and decompress the data .... do 1k chunks in the hope that we won't kill the stack
|
||||
#define MYBLOCK 1024
|
||||
Bytef block[MYBLOCK];
|
||||
|
|
@ -205,8 +195,8 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
const size_t have = MYBLOCK - zstream.avail_out;
|
||||
total += have;
|
||||
dest = reinterpret_cast<Bytef*>( realloc(dest,total) );
|
||||
memcpy(dest + total - have,block,have);
|
||||
uncompressed.resize(total);
|
||||
memcpy(uncompressed.data() + total - have,block,have);
|
||||
}
|
||||
while (ret != Z_STREAM_END);
|
||||
|
||||
|
|
@ -214,7 +204,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
|||
inflateEnd(&zstream);
|
||||
|
||||
// replace the input stream with a memory stream
|
||||
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(dest),total));
|
||||
stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(uncompressed.data()),total));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +370,7 @@ aiLight* XGLImporter::ReadDirectionalLight()
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* closetag)
|
||||
{
|
||||
std::unique_ptr<aiNode> nd(new aiNode());
|
||||
aiNode *nd = new aiNode;
|
||||
std::vector<aiNode*> children;
|
||||
std::vector<unsigned int> meshes;
|
||||
|
||||
|
|
@ -463,11 +453,11 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
|
|||
nd->mChildren = new aiNode*[nd->mNumChildren]();
|
||||
for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
|
||||
nd->mChildren[i] = children[i];
|
||||
children[i]->mParent = nd.get();
|
||||
children[i]->mParent = nd;
|
||||
}
|
||||
}
|
||||
|
||||
return nd.release();
|
||||
return nd;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -508,7 +498,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo()
|
|||
right = forward ^ up;
|
||||
if (std::fabs(up * forward) > 1e-4) {
|
||||
// this is definitely wrong - a degenerate coordinate space ruins everything
|
||||
// so subtitute identity transform.
|
||||
// so substitute identity transform.
|
||||
LogError("<forward> and <up> vectors in <transform> are skewing, ignoring trafo");
|
||||
return m;
|
||||
}
|
||||
|
|
@ -741,11 +731,10 @@ unsigned int XGLImporter::ResolveMaterialRef(TempScope& scope)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void XGLImporter::ReadMaterial(TempScope& scope)
|
||||
{
|
||||
void XGLImporter::ReadMaterial(TempScope& scope) {
|
||||
const unsigned int mat_id = ReadIDAttr();
|
||||
|
||||
std::unique_ptr<aiMaterial> mat(new aiMaterial());
|
||||
aiMaterial *mat(new aiMaterial );
|
||||
while (ReadElementUpToClosing("mat")) {
|
||||
const std::string& s = GetElementName();
|
||||
if (s == "amb") {
|
||||
|
|
@ -774,11 +763,10 @@ void XGLImporter::ReadMaterial(TempScope& scope)
|
|||
}
|
||||
}
|
||||
|
||||
scope.materials[mat_id] = mat.get();
|
||||
scope.materials_linear.push_back(mat.release());
|
||||
scope.materials[mat_id] = mat;
|
||||
scope.materials_linear.push_back(mat);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
|
||||
{
|
||||
|
|
@ -904,12 +892,14 @@ aiVector2D XGLImporter::ReadVec2()
|
|||
}
|
||||
const char* s = m_reader->getNodeData();
|
||||
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
ai_real v[2];
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
if(!SkipSpaces(&s)) {
|
||||
LogError("unexpected EOL, failed to parse vec2");
|
||||
return vec;
|
||||
}
|
||||
vec[i] = fast_atof(&s);
|
||||
|
||||
v[i] = fast_atof(&s);
|
||||
|
||||
SkipSpaces(&s);
|
||||
if (i != 1 && *s != ',') {
|
||||
|
|
@ -918,6 +908,8 @@ aiVector2D XGLImporter::ReadVec2()
|
|||
}
|
||||
++s;
|
||||
}
|
||||
vec.x = v[0];
|
||||
vec.y = v[1];
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue