fix all unittests.

pull/3012/head
Kim Kulling 2020-03-15 10:17:54 +01:00
parent 255758e6ff
commit 0357333c81
9 changed files with 1360 additions and 1475 deletions

View File

@ -49,19 +49,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AssbinFileWriter.h" #include "AssbinFileWriter.h"
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/IOSystem.hpp>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/IOSystem.hpp>
namespace Assimp { namespace Assimp {
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { void ExportSceneAssbin(const char *pFile, IOSystem *pIOSystem, const aiScene *pScene, const ExportProperties * /*pProperties*/) {
DumpSceneToAssbin( DumpSceneToAssbin(
pFile, pFile,
"\0", // no command(s). "\0", // no command(s).
pIOSystem, pIOSystem,
pScene, pScene,
false, // shortened? false, // shortened?
false); // compressed? false); // compressed?
} }
} // end of namespace Assimp } // end of namespace Assimp

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -105,8 +103,9 @@ template <typename T>
T Read(IOStream *stream) { T Read(IOStream *stream) {
T t; T t;
size_t res = stream->Read(&t, sizeof(T), 1); size_t res = stream->Read(&t, sizeof(T), 1);
if (res != 1) if (res != 1) {
throw DeadlyImportError("Unexpected EOF"); throw DeadlyImportError("Unexpected EOF");
}
return t; return t;
} }
@ -313,6 +312,7 @@ void AssbinImporter::ReadBinaryBone(IOStream *stream, aiBone *b) {
static bool fitsIntoUI16(unsigned int mNumVertices) { static bool fitsIntoUI16(unsigned int mNumVertices) {
return (mNumVertices < (1u << 16)); return (mNumVertices < (1u << 16));
} }
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryMesh(IOStream *stream, aiMesh *mesh) { void AssbinImporter::ReadBinaryMesh(IOStream *stream, aiMesh *mesh) {
if (Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMESH) if (Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMESH)

View File

@ -618,7 +618,7 @@ inline void Image::Read(Value &obj, Asset &r) {
if (!mDataLength) { if (!mDataLength) {
Value *curUri = FindString(obj, "uri"); Value *curUri = FindString(obj, "uri");
if (nullptr != curUri ) { if (nullptr != curUri) {
const char *uristr = curUri->GetString(); const char *uristr = curUri->GetString();
glTFCommon::Util::DataURI dataURI; glTFCommon::Util::DataURI dataURI;
@ -1272,13 +1272,9 @@ inline void Asset::ReadBinaryHeader(IOStream &stream) {
inline void Asset::Load(const std::string &pFile, bool isBinary) { inline void Asset::Load(const std::string &pFile, bool isBinary) {
mCurrentAssetDir.clear(); mCurrentAssetDir.clear();
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\'))); /*int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
if (pos != int(std::string::npos)) mCurrentAssetDir = pFile.substr(0, pos + 1); if (pos != int(std::string::npos)) mCurrentAssetDir = pFile.substr(0, pos + 1);*/
mCurrentAssetDir = getCurrentAssetDir(pFile);
/* std::string::size_type pos = std::max(pFile.rfind('/'), pFile.rfind('\\'));
if (pos != std::string::npos) {
mCurrentAssetDir = pFile.substr(0, pos + 1);
}*/
shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true)); shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true));
if (!stream) { if (!stream) {
@ -1373,9 +1369,9 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
#undef CHECK_EXT #undef CHECK_EXT
} }
inline IOStream *Asset::OpenFile(std::string path, const char *mode, bool absolute ) { inline IOStream *Asset::OpenFile(std::string path, const char *mode, bool absolute) {
#ifdef ASSIMP_API #ifdef ASSIMP_API
(void) absolute; (void)absolute;
return mIOSystem->Open(path, mode); return mIOSystem->Open(path, mode);
#else #else
if (path.size() < 2) return 0; if (path.size() < 2) return 0;

View File

@ -46,7 +46,7 @@ using namespace glTFCommon::Util;
namespace Util { namespace Util {
size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out) { size_t DecodeBase64(const char *in, size_t inLength, uint8_t *&out) {
ai_assert(inLength % 4 == 0); ai_assert(inLength % 4 == 0);
if (inLength < 4) { if (inLength < 4) {
@ -55,7 +55,7 @@ size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out) {
} }
int nEquals = int(in[inLength - 1] == '=') + int nEquals = int(in[inLength - 1] == '=') +
int(in[inLength - 2] == '='); int(in[inLength - 2] == '=');
size_t outLength = (inLength * 3) / 4 - nEquals; size_t outLength = (inLength * 3) / 4 - nEquals;
out = new uint8_t[outLength]; out = new uint8_t[outLength];
@ -88,7 +88,7 @@ size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out) {
return outLength; return outLength;
} }
void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out) { void EncodeBase64(const uint8_t *in, size_t inLength, std::string &out) {
size_t outLength = ((inLength + 2) / 3) * 4; size_t outLength = ((inLength + 2) / 3) * 4;
size_t j = out.size(); size_t j = out.size();
@ -110,13 +110,11 @@ void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out) {
b = in[i + 2] & 0x3F; b = in[i + 2] & 0x3F;
out[j++] = EncodeCharBase64(b); out[j++] = EncodeCharBase64(b);
} } else {
else {
out[j++] = EncodeCharBase64(b); out[j++] = EncodeCharBase64(b);
out[j++] = '='; out[j++] = '=';
} }
} } else {
else {
out[j++] = EncodeCharBase64(b); out[j++] = EncodeCharBase64(b);
out[j++] = '='; out[j++] = '=';
out[j++] = '='; out[j++] = '=';
@ -124,7 +122,7 @@ void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out) {
} }
} }
bool ParseDataURI(const char* const_uri, size_t uriLen, DataURI& out) { bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) {
if (nullptr == const_uri) { if (nullptr == const_uri) {
return false; return false;
} }
@ -139,7 +137,7 @@ bool ParseDataURI(const char* const_uri, size_t uriLen, DataURI& out) {
out.charset = "US-ASCII"; out.charset = "US-ASCII";
out.base64 = false; out.base64 = false;
char* uri = const_cast<char*>(const_uri); char *uri = const_cast<char *>(const_uri);
if (uri[0] != 0x10) { if (uri[0] != 0x10) {
uri[0] = 0x10; uri[0] = 0x10;
uri[1] = uri[2] = uri[3] = uri[4] = 0; uri[1] = uri[2] = uri[3] = uri[4] = 0;
@ -159,16 +157,14 @@ bool ParseDataURI(const char* const_uri, size_t uriLen, DataURI& out) {
if (strncmp(uri + j, "charset=", 8) == 0) { if (strncmp(uri + j, "charset=", 8) == 0) {
uri[2] = char(j + 8); uri[2] = char(j + 8);
} } else if (strncmp(uri + j, "base64", 6) == 0) {
else if (strncmp(uri + j, "base64", 6) == 0) {
uri[3] = char(j); uri[3] = char(j);
} }
} }
if (i < uriLen) { if (i < uriLen) {
uri[i++] = '\0'; uri[i++] = '\0';
uri[4] = char(i); uri[4] = char(i);
} } else {
else {
uri[1] = uri[2] = uri[3] = 0; uri[1] = uri[2] = uri[3] = 0;
uri[4] = 5; uri[4] = 5;
} }
@ -189,5 +185,5 @@ bool ParseDataURI(const char* const_uri, size_t uriLen, DataURI& out) {
return true; return true;
} }
} } // namespace Util
} } // namespace glTFCommon

View File

@ -45,201 +45,219 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exceptional.h> #include <assimp/Exceptional.h>
#include <map>
#include <string>
#include <list>
#include <vector>
#include <algorithm> #include <algorithm>
#include <list>
#include <map>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <vector>
#define RAPIDJSON_HAS_STDSTRING 1 #define RAPIDJSON_HAS_STDSTRING 1
#include <rapidjson/rapidjson.h>
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/error/en.h> #include <rapidjson/error/en.h>
#include <rapidjson/rapidjson.h>
#ifdef ASSIMP_API #ifdef ASSIMP_API
# include <memory> #include <assimp/ByteSwapper.h>
# include <assimp/DefaultIOSystem.h> #include <assimp/DefaultIOSystem.h>
# include <assimp/ByteSwapper.h> #include <memory>
#else #else
# include <memory> #include <memory>
# define AI_SWAP4(p) #define AI_SWAP4(p)
# define ai_assert #define ai_assert
#endif #endif
#if _MSC_VER > 1500 || (defined __GNUC___) #if _MSC_VER > 1500 || (defined __GNUC___)
# define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP #define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
# else #else
# define gltf_unordered_map map #define gltf_unordered_map map
#endif #endif
#ifdef ASSIMP_GLTF_USE_UNORDERED_MULTIMAP #ifdef ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
# include <unordered_map> #include <unordered_map>
# if _MSC_VER > 1600 #if _MSC_VER > 1600
# define gltf_unordered_map unordered_map #define gltf_unordered_map unordered_map
# else #else
# define gltf_unordered_map tr1::unordered_map #define gltf_unordered_map tr1::unordered_map
# endif #endif
#endif #endif
namespace glTFCommon { namespace glTFCommon {
#ifdef ASSIMP_API #ifdef ASSIMP_API
using Assimp::IOStream; using Assimp::IOStream;
using Assimp::IOSystem; using Assimp::IOSystem;
using std::shared_ptr; using std::shared_ptr;
#else #else
using std::shared_ptr; using std::shared_ptr;
typedef std::runtime_error DeadlyImportError; typedef std::runtime_error DeadlyImportError;
typedef std::runtime_error DeadlyExportError; typedef std::runtime_error DeadlyExportError;
enum aiOrigin { enum aiOrigin {
aiOrigin_SET = 0, aiOrigin_SET = 0,
aiOrigin_CUR = 1, aiOrigin_CUR = 1,
aiOrigin_END = 2 aiOrigin_END = 2
}; };
class IOSystem; class IOSystem;
class IOStream { class IOStream {
public: public:
IOStream(FILE* file) : f(file) {} IOStream(FILE *file) :
~IOStream() { fclose(f); f = 0; } f(file) {}
~IOStream() {
fclose(f);
f = 0;
}
size_t Read(void* b, size_t sz, size_t n) { return fread(b, sz, n, f); } size_t Read(void *b, size_t sz, size_t n) { return fread(b, sz, n, f); }
size_t Write(const void* b, size_t sz, size_t n) { return fwrite(b, sz, n, f); } size_t Write(const void *b, size_t sz, size_t n) { return fwrite(b, sz, n, f); }
int Seek(size_t off, aiOrigin orig) { return fseek(f, off, int(orig)); } int Seek(size_t off, aiOrigin orig) { return fseek(f, off, int(orig)); }
size_t Tell() const { return ftell(f); } size_t Tell() const { return ftell(f); }
size_t FileSize() { size_t FileSize() {
long p = Tell(), len = (Seek(0, aiOrigin_END), Tell()); long p = Tell(), len = (Seek(0, aiOrigin_END), Tell());
return size_t((Seek(p, aiOrigin_SET), len)); return size_t((Seek(p, aiOrigin_SET), len));
} }
private: private:
FILE* f; FILE *f;
}; };
#endif #endif
// Vec/matrix types, as raw float arrays // Vec/matrix types, as raw float arrays
typedef float(vec3)[3]; typedef float(vec3)[3];
typedef float(vec4)[4]; typedef float(vec4)[4];
typedef float(mat4)[16]; typedef float(mat4)[16];
inline
void CopyValue(const glTFCommon::vec3& v, aiColor4D& out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
out.a = 1.0;
}
inline
void CopyValue(const glTFCommon::vec4& v, aiColor4D& out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
out.a = v[3];
}
inline
void CopyValue(const glTFCommon::vec4& v, aiColor3D& out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
}
inline
void CopyValue(const glTFCommon::vec3& v, aiColor3D& out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
}
inline
void CopyValue(const glTFCommon::vec3& v, aiVector3D& out) {
out.x = v[0];
out.y = v[1];
out.z = v[2];
}
inline
void CopyValue(const glTFCommon::vec4& v, aiQuaternion& out) {
out.x = v[0];
out.y = v[1];
out.z = v[2];
out.w = v[3];
}
inline
void CopyValue(const glTFCommon::mat4& v, aiMatrix4x4& o) {
o.a1 = v[0]; o.b1 = v[1]; o.c1 = v[2]; o.d1 = v[3];
o.a2 = v[4]; o.b2 = v[5]; o.c2 = v[6]; o.d2 = v[7];
o.a3 = v[8]; o.b3 = v[9]; o.c3 = v[10]; o.d3 = v[11];
o.a4 = v[12]; o.b4 = v[13]; o.c4 = v[14]; o.d4 = v[15];
}
namespace Util {
void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out);
size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out);
inline
size_t DecodeBase64(const char* in, uint8_t*& out) {
return DecodeBase64(in, strlen(in), out);
}
struct DataURI {
const char* mediaType;
const char* charset;
bool base64;
const char* data;
size_t dataLength;
};
//! Check if a uri is a data URI
bool ParseDataURI(const char* const_uri, size_t uriLen, DataURI& out);
template<bool B>
struct DATA {
static const uint8_t tableDecodeBase64[128];
};
template<bool B>
const uint8_t DATA<B>::tableDecodeBase64[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 64, 0, 0,
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0
};
inline
char EncodeCharBase64(uint8_t b) {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="[size_t(b)];
}
inline
uint8_t DecodeCharBase64(char c) {
return DATA<true>::tableDecodeBase64[size_t(c)]; // TODO faster with lookup table or ifs?
}
size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out);
void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out);
} // namespace Util
#define CHECK_EXT(EXT) \
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
inline void CopyValue(const glTFCommon::vec3 &v, aiColor4D &out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
out.a = 1.0;
} }
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER inline void CopyValue(const glTFCommon::vec4 &v, aiColor4D &out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
out.a = v[3];
}
inline void CopyValue(const glTFCommon::vec4 &v, aiColor3D &out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
}
inline void CopyValue(const glTFCommon::vec3 &v, aiColor3D &out) {
out.r = v[0];
out.g = v[1];
out.b = v[2];
}
inline void CopyValue(const glTFCommon::vec3 &v, aiVector3D &out) {
out.x = v[0];
out.y = v[1];
out.z = v[2];
}
inline void CopyValue(const glTFCommon::vec4 &v, aiQuaternion &out) {
out.x = v[0];
out.y = v[1];
out.z = v[2];
out.w = v[3];
}
inline void CopyValue(const glTFCommon::mat4 &v, aiMatrix4x4 &o) {
o.a1 = v[0];
o.b1 = v[1];
o.c1 = v[2];
o.d1 = v[3];
o.a2 = v[4];
o.b2 = v[5];
o.c2 = v[6];
o.d2 = v[7];
o.a3 = v[8];
o.b3 = v[9];
o.c3 = v[10];
o.d3 = v[11];
o.a4 = v[12];
o.b4 = v[13];
o.c4 = v[14];
o.d4 = v[15];
}
#pragma warning(push)
#pragma warning(disable : 4310)
inline std::string getCurrentAssetDir(const std::string &pFile) {
std::string path = pFile;
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
if (pos != int(std::string::npos)) {
path = pFile.substr(0, pos + 1);
}
return path;
}
#pragma warning(pop)
namespace Util {
void EncodeBase64(const uint8_t *in, size_t inLength, std::string &out);
size_t DecodeBase64(const char *in, size_t inLength, uint8_t *&out);
inline size_t DecodeBase64(const char *in, uint8_t *&out) {
return DecodeBase64(in, strlen(in), out);
}
struct DataURI {
const char *mediaType;
const char *charset;
bool base64;
const char *data;
size_t dataLength;
};
//! Check if a uri is a data URI
bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out);
template <bool B>
struct DATA {
static const uint8_t tableDecodeBase64[128];
};
template <bool B>
const uint8_t DATA<B>::tableDecodeBase64[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 64, 0, 0,
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0
};
inline char EncodeCharBase64(uint8_t b) {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="[size_t(b)];
}
inline uint8_t DecodeCharBase64(char c) {
return DATA<true>::tableDecodeBase64[size_t(c)]; // TODO faster with lookup table or ifs?
}
size_t DecodeBase64(const char *in, size_t inLength, uint8_t *&out);
void EncodeBase64(const uint8_t *in, size_t inLength, std::string &out);
} // namespace Util
#define CHECK_EXT(EXT) \
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
} // namespace glTFCommon
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // AI_GLFTCOMMON_H_INC #endif // AI_GLFTCOMMON_H_INC

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#include "glTF/glTFCommon.h"
#include <assimp/StringUtils.h> #include <assimp/StringUtils.h>
// Header files, Assimp // Header files, Assimp
@ -901,7 +902,7 @@ inline int Compare(const char *attr, const char (&str)[N]) {
} }
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4706 ) #pragma warning(disable : 4706)
inline bool GetAttribVector(Mesh::Primitive &p, const char *attr, Mesh::AccessorList *&v, int &pos) { inline bool GetAttribVector(Mesh::Primitive &p, const char *attr, Mesh::AccessorList *&v, int &pos) {
if ((pos = Compare(attr, "POSITION"))) { if ((pos = Compare(attr, "POSITION"))) {
v = &(p.attributes.position); v = &(p.attributes.position);
@ -1106,7 +1107,7 @@ inline void Node::Read(Value &obj, Asset &r) {
} }
Value *curMesh = FindUInt(obj, "mesh"); Value *curMesh = FindUInt(obj, "mesh");
if (nullptr != curMesh ) { if (nullptr != curMesh) {
unsigned int numMeshes = 1; unsigned int numMeshes = 1;
this->meshes.reserve(numMeshes); this->meshes.reserve(numMeshes);
Ref<Mesh> meshRef = r.meshes.Retrieve((*curMesh).GetUint()); Ref<Mesh> meshRef = r.meshes.Retrieve((*curMesh).GetUint());
@ -1116,12 +1117,12 @@ inline void Node::Read(Value &obj, Asset &r) {
} }
Value *curSkin = FindUInt(obj, "skin"); Value *curSkin = FindUInt(obj, "skin");
if (nullptr != curSkin ) { if (nullptr != curSkin) {
this->skin = r.skins.Retrieve(curSkin->GetUint()); this->skin = r.skins.Retrieve(curSkin->GetUint());
} }
Value *curCamera = FindUInt(obj, "camera"); Value *curCamera = FindUInt(obj, "camera");
if (nullptr != curCamera ) { if (nullptr != curCamera) {
this->camera = r.cameras.Retrieve(curCamera->GetUint()); this->camera = r.cameras.Retrieve(curCamera->GetUint());
if (this->camera) { if (this->camera) {
this->camera->id = this->id; this->camera->id = this->id;
@ -1328,8 +1329,10 @@ inline void Asset::ReadBinaryHeader(IOStream &stream, std::vector<char> &sceneDa
inline void Asset::Load(const std::string &pFile, bool isBinary) { inline void Asset::Load(const std::string &pFile, bool isBinary) {
mCurrentAssetDir.clear(); mCurrentAssetDir.clear();
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\'))); /*int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
if (pos != int(std::string::npos)) mCurrentAssetDir = pFile.substr(0, pos + 1); if (pos != int(std::string::npos)) */
mCurrentAssetDir = glTFCommon::getCurrentAssetDir(pFile);
shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true)); shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true));
if (!stream) { if (!stream) {
@ -1516,6 +1519,6 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi
return id; return id;
} }
#pragma warning( pop ) #pragma warning(pop)
} // namespace glTF2 } // namespace glTF2

View File

@ -110,8 +110,9 @@ const aiImporterDesc *glTF2Importer::GetInfo() const {
bool glTF2Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const { bool glTF2Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const {
const std::string &extension = GetExtension(pFile); const std::string &extension = GetExtension(pFile);
if (extension != "gltf" && extension != "glb") if (extension != "gltf" && extension != "glb") {
return false; return false;
}
if (pIOHandler) { if (pIOHandler) {
glTF2::Asset asset(pIOHandler); glTF2::Asset asset(pIOHandler);