Merge branch 'master' into remove-cout-2797
commit
505769935e
|
@ -493,7 +493,7 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
||||||
ReadFile(fbuff,pFlags);
|
ReadFile(fbuff,pFlags);
|
||||||
SetIOHandler(io);
|
SetIOHandler(io);
|
||||||
|
|
||||||
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
|
ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
|
||||||
return pimpl->mScene;
|
return pimpl->mScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||||
#endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
#endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
||||||
|
|
||||||
// either successful or failure - the pointer expresses it anyways
|
// either successful or failure - the pointer expresses it anyways
|
||||||
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
|
ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
|
||||||
return pimpl->mScene;
|
return pimpl->mScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,8 +362,8 @@ namespace glTF
|
||||||
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
||||||
unsigned int count; //!< The number of attributes referenced by this accessor. (required)
|
unsigned int count; //!< The number of attributes referenced by this accessor. (required)
|
||||||
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
||||||
std::vector<float> max; //!< Maximum value of each component in this attribute.
|
std::vector<double> max; //!< Maximum value of each component in this attribute.
|
||||||
std::vector<float> min; //!< Minimum value of each component in this attribute.
|
std::vector<double> min; //!< Minimum value of each component in this attribute.
|
||||||
|
|
||||||
unsigned int GetNumComponents();
|
unsigned int GetNumComponents();
|
||||||
unsigned int GetBytesPerComponent();
|
unsigned int GetBytesPerComponent();
|
||||||
|
|
|
@ -54,9 +54,9 @@ namespace glTF {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<size_t N>
|
template<typename T, size_t N>
|
||||||
inline
|
inline
|
||||||
Value& MakeValue(Value& val, float(&r)[N], MemoryPoolAllocator<>& al) {
|
Value& MakeValue(Value& val, T(&r)[N], MemoryPoolAllocator<>& al) {
|
||||||
val.SetArray();
|
val.SetArray();
|
||||||
val.Reserve(N, al);
|
val.Reserve(N, al);
|
||||||
for (decltype(N) i = 0; i < N; ++i) {
|
for (decltype(N) i = 0; i < N; ++i) {
|
||||||
|
@ -65,8 +65,9 @@ namespace glTF {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
inline
|
inline
|
||||||
Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
|
Value& MakeValue(Value& val, const std::vector<T> & r, MemoryPoolAllocator<>& al) {
|
||||||
val.SetArray();
|
val.SetArray();
|
||||||
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
||||||
for (unsigned int i = 0; i < r.size(); ++i) {
|
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||||
|
@ -75,6 +76,16 @@ namespace glTF {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename C, typename T>
|
||||||
|
inline Value& MakeValueCast(Value& val, const std::vector<T> & r, MemoryPoolAllocator<>& al) {
|
||||||
|
val.SetArray();
|
||||||
|
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
||||||
|
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||||
|
val.PushBack(static_cast<C>(r[i]), al);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void AddRefsVector(Value& obj, const char* fieldId, std::vector< Ref<T> >& v, MemoryPoolAllocator<>& al) {
|
inline void AddRefsVector(Value& obj, const char* fieldId, std::vector< Ref<T> >& v, MemoryPoolAllocator<>& al) {
|
||||||
if (v.empty()) return;
|
if (v.empty()) return;
|
||||||
|
@ -100,8 +111,13 @@ namespace glTF {
|
||||||
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
||||||
|
|
||||||
Value vTmpMax, vTmpMin;
|
Value vTmpMax, vTmpMin;
|
||||||
|
if (a.componentType == ComponentType_FLOAT) {
|
||||||
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
||||||
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
||||||
|
} else {
|
||||||
|
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
|
||||||
|
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
||||||
|
|
|
@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Header files, standard library.
|
// Header files, standard library.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <limits>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||||
|
@ -173,6 +174,62 @@ static void IdentityMatrix4(glTF::mat4& o)
|
||||||
o[12] = 0; o[13] = 0; o[14] = 0; o[15] = 1;
|
o[12] = 0; o[13] = 0; o[14] = 0; o[15] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SetAccessorRange(Ref<Accessor> acc, void* data, unsigned int count,
|
||||||
|
unsigned int numCompsIn, unsigned int numCompsOut)
|
||||||
|
{
|
||||||
|
ai_assert(numCompsOut <= numCompsIn);
|
||||||
|
|
||||||
|
// Allocate and initialize with large values.
|
||||||
|
for (unsigned int i = 0 ; i < numCompsOut ; i++) {
|
||||||
|
acc->min.push_back( std::numeric_limits<double>::max());
|
||||||
|
acc->max.push_back(-std::numeric_limits<double>::max());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t totalComps = count * numCompsIn;
|
||||||
|
T* buffer_ptr = static_cast<T*>(data);
|
||||||
|
T* buffer_end = buffer_ptr + totalComps;
|
||||||
|
|
||||||
|
// Search and set extreme values.
|
||||||
|
for (; buffer_ptr < buffer_end ; buffer_ptr += numCompsIn) {
|
||||||
|
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
|
||||||
|
double valueTmp = buffer_ptr[j];
|
||||||
|
|
||||||
|
if (valueTmp < acc->min[j]) {
|
||||||
|
acc->min[j] = valueTmp;
|
||||||
|
}
|
||||||
|
if (valueTmp > acc->max[j]) {
|
||||||
|
acc->max[j] = valueTmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetAccessorRange(ComponentType compType, Ref<Accessor> acc, void* data,
|
||||||
|
unsigned int count, unsigned int numCompsIn, unsigned int numCompsOut)
|
||||||
|
{
|
||||||
|
switch (compType) {
|
||||||
|
case ComponentType_SHORT:
|
||||||
|
SetAccessorRange<short>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_SHORT:
|
||||||
|
SetAccessorRange<unsigned short>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_INT:
|
||||||
|
SetAccessorRange<unsigned int>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_FLOAT:
|
||||||
|
SetAccessorRange<float>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_BYTE:
|
||||||
|
SetAccessorRange<int8_t>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_BYTE:
|
||||||
|
SetAccessorRange<uint8_t>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
||||||
unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
|
unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
|
||||||
{
|
{
|
||||||
|
@ -206,33 +263,7 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
|
||||||
acc->type = typeOut;
|
acc->type = typeOut;
|
||||||
|
|
||||||
// calculate min and max values
|
// calculate min and max values
|
||||||
{
|
SetAccessorRange(compType, acc, data, count, numCompsIn, numCompsOut);
|
||||||
// Allocate and initialize with large values.
|
|
||||||
float float_MAX = 10000000000000.0f;
|
|
||||||
for (unsigned int i = 0 ; i < numCompsOut ; i++) {
|
|
||||||
acc->min.push_back( float_MAX);
|
|
||||||
acc->max.push_back(-float_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search and set extreme values.
|
|
||||||
float valueTmp;
|
|
||||||
for (unsigned int i = 0 ; i < count ; i++) {
|
|
||||||
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
|
|
||||||
if (numCompsOut == 1) {
|
|
||||||
valueTmp = static_cast<unsigned short*>(data)[i];
|
|
||||||
} else {
|
|
||||||
valueTmp = static_cast<aiVector3D*>(data)[i][j];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueTmp < acc->min[j]) {
|
|
||||||
acc->min[j] = valueTmp;
|
|
||||||
}
|
|
||||||
if (valueTmp > acc->max[j]) {
|
|
||||||
acc->max[j] = valueTmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy the data
|
// copy the data
|
||||||
acc->WriteData(count, data, numCompsIn*bytesPerComp);
|
acc->WriteData(count, data, numCompsIn*bytesPerComp);
|
||||||
|
|
|
@ -387,8 +387,8 @@ namespace glTF2
|
||||||
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
||||||
size_t count; //!< The number of attributes referenced by this accessor. (required)
|
size_t count; //!< The number of attributes referenced by this accessor. (required)
|
||||||
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
||||||
std::vector<float> max; //!< Maximum value of each component in this attribute.
|
std::vector<double> max; //!< Maximum value of each component in this attribute.
|
||||||
std::vector<float> min; //!< Minimum value of each component in this attribute.
|
std::vector<double> min; //!< Minimum value of each component in this attribute.
|
||||||
|
|
||||||
unsigned int GetNumComponents();
|
unsigned int GetNumComponents();
|
||||||
unsigned int GetBytesPerComponent();
|
unsigned int GetBytesPerComponent();
|
||||||
|
|
|
@ -54,8 +54,8 @@ namespace glTF2 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<size_t N>
|
template<typename T, size_t N>
|
||||||
inline Value& MakeValue(Value& val, float(&r)[N], MemoryPoolAllocator<>& al) {
|
inline Value& MakeValue(Value& val, T(&r)[N], MemoryPoolAllocator<>& al) {
|
||||||
val.SetArray();
|
val.SetArray();
|
||||||
val.Reserve(N, al);
|
val.Reserve(N, al);
|
||||||
for (decltype(N) i = 0; i < N; ++i) {
|
for (decltype(N) i = 0; i < N; ++i) {
|
||||||
|
@ -64,7 +64,8 @@ namespace glTF2 {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
|
template<typename T>
|
||||||
|
inline Value& MakeValue(Value& val, const std::vector<T> & r, MemoryPoolAllocator<>& al) {
|
||||||
val.SetArray();
|
val.SetArray();
|
||||||
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
||||||
for (unsigned int i = 0; i < r.size(); ++i) {
|
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||||
|
@ -73,8 +74,19 @@ namespace glTF2 {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Value& MakeValue(Value& val, float r, MemoryPoolAllocator<>& /*al*/) {
|
template<typename C, typename T>
|
||||||
val.SetDouble(r);
|
inline Value& MakeValueCast(Value& val, const std::vector<T> & r, MemoryPoolAllocator<>& al) {
|
||||||
|
val.SetArray();
|
||||||
|
val.Reserve(static_cast<rapidjson::SizeType>(r.size()), al);
|
||||||
|
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||||
|
val.PushBack(static_cast<C>(r[i]), al);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline Value& MakeValue(Value& val, T r, MemoryPoolAllocator<>& /*al*/) {
|
||||||
|
val.Set(r);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +116,13 @@ namespace glTF2 {
|
||||||
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
||||||
|
|
||||||
Value vTmpMax, vTmpMin;
|
Value vTmpMax, vTmpMin;
|
||||||
|
if (a.componentType == ComponentType_FLOAT) {
|
||||||
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
||||||
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
||||||
|
} else {
|
||||||
|
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
|
||||||
|
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
||||||
|
|
|
@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Header files, standard library.
|
// Header files, standard library.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <limits>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
@ -152,6 +153,62 @@ static void IdentityMatrix4(mat4& o) {
|
||||||
o[12] = 0; o[13] = 0; o[14] = 0; o[15] = 1;
|
o[12] = 0; o[13] = 0; o[14] = 0; o[15] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SetAccessorRange(Ref<Accessor> acc, void* data, size_t count,
|
||||||
|
unsigned int numCompsIn, unsigned int numCompsOut)
|
||||||
|
{
|
||||||
|
ai_assert(numCompsOut <= numCompsIn);
|
||||||
|
|
||||||
|
// Allocate and initialize with large values.
|
||||||
|
for (unsigned int i = 0 ; i < numCompsOut ; i++) {
|
||||||
|
acc->min.push_back( std::numeric_limits<double>::max());
|
||||||
|
acc->max.push_back(-std::numeric_limits<double>::max());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t totalComps = count * numCompsIn;
|
||||||
|
T* buffer_ptr = static_cast<T*>(data);
|
||||||
|
T* buffer_end = buffer_ptr + totalComps;
|
||||||
|
|
||||||
|
// Search and set extreme values.
|
||||||
|
for (; buffer_ptr < buffer_end ; buffer_ptr += numCompsIn) {
|
||||||
|
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
|
||||||
|
double valueTmp = buffer_ptr[j];
|
||||||
|
|
||||||
|
if (valueTmp < acc->min[j]) {
|
||||||
|
acc->min[j] = valueTmp;
|
||||||
|
}
|
||||||
|
if (valueTmp > acc->max[j]) {
|
||||||
|
acc->max[j] = valueTmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetAccessorRange(ComponentType compType, Ref<Accessor> acc, void* data,
|
||||||
|
size_t count, unsigned int numCompsIn, unsigned int numCompsOut)
|
||||||
|
{
|
||||||
|
switch (compType) {
|
||||||
|
case ComponentType_SHORT:
|
||||||
|
SetAccessorRange<short>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_SHORT:
|
||||||
|
SetAccessorRange<unsigned short>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_INT:
|
||||||
|
SetAccessorRange<unsigned int>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_FLOAT:
|
||||||
|
SetAccessorRange<float>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_BYTE:
|
||||||
|
SetAccessorRange<int8_t>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
case ComponentType_UNSIGNED_BYTE:
|
||||||
|
SetAccessorRange<uint8_t>(acc, data, count, numCompsIn, numCompsOut);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
||||||
size_t count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
|
size_t count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
|
||||||
{
|
{
|
||||||
|
@ -187,33 +244,7 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
|
||||||
acc->type = typeOut;
|
acc->type = typeOut;
|
||||||
|
|
||||||
// calculate min and max values
|
// calculate min and max values
|
||||||
{
|
SetAccessorRange(compType, acc, data, count, numCompsIn, numCompsOut);
|
||||||
// Allocate and initialize with large values.
|
|
||||||
float float_MAX = 10000000000000.0f;
|
|
||||||
for (unsigned int i = 0 ; i < numCompsOut ; i++) {
|
|
||||||
acc->min.push_back( float_MAX);
|
|
||||||
acc->max.push_back(-float_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search and set extreme values.
|
|
||||||
float valueTmp;
|
|
||||||
for (unsigned int i = 0 ; i < count ; i++) {
|
|
||||||
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
|
|
||||||
if (numCompsOut == 1) {
|
|
||||||
valueTmp = static_cast<unsigned short*>(data)[i];
|
|
||||||
} else {
|
|
||||||
valueTmp = static_cast<aiVector3D*>(data)[i][j];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueTmp < acc->min[j]) {
|
|
||||||
acc->min[j] = valueTmp;
|
|
||||||
}
|
|
||||||
if (valueTmp > acc->max[j]) {
|
|
||||||
acc->max[j] = valueTmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy the data
|
// copy the data
|
||||||
acc->WriteData(count, data, numCompsIn*bytesPerComp);
|
acc->WriteData(count, data, numCompsIn*bytesPerComp);
|
||||||
|
|
|
@ -119,6 +119,16 @@ struct ExceptionSwallower<void> {
|
||||||
{\
|
{\
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString)\
|
||||||
|
} catch(const DeadlyImportError& e) {\
|
||||||
|
ASSIMP_END_EXCEPTION_REGION_errorString = e.what();\
|
||||||
|
return ExceptionSwallower<type>()();\
|
||||||
|
} catch(...) {\
|
||||||
|
ASSIMP_END_EXCEPTION_REGION_errorString = "Unknown exception";\
|
||||||
|
return ExceptionSwallower<type>()();\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSIMP_END_EXCEPTION_REGION(type)\
|
#define ASSIMP_END_EXCEPTION_REGION(type)\
|
||||||
} catch(...) {\
|
} catch(...) {\
|
||||||
return ExceptionSwallower<type>()();\
|
return ExceptionSwallower<type>()();\
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"generator": "COLLADA2GLTF",
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0,
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
"nodes": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"children": [
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"matrix": [
|
||||||
|
1.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
-1.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mesh": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meshes": [
|
||||||
|
{
|
||||||
|
"primitives": [
|
||||||
|
{
|
||||||
|
"attributes": {
|
||||||
|
"NORMAL": 1,
|
||||||
|
"POSITION": 2,
|
||||||
|
"TEXCOORD_0": 3
|
||||||
|
},
|
||||||
|
"indices": 0,
|
||||||
|
"mode": 4,
|
||||||
|
"material": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Mesh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"accessors": [
|
||||||
|
{
|
||||||
|
"bufferView": 0,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5123,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "SCALAR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 1,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 24,
|
||||||
|
"max": [
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-1.0,
|
||||||
|
-1.0,
|
||||||
|
-1.0
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 1,
|
||||||
|
"byteOffset": 288,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 24,
|
||||||
|
"max": [
|
||||||
|
0.5,
|
||||||
|
0.5,
|
||||||
|
0.5
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-0.5,
|
||||||
|
-0.5,
|
||||||
|
-0.5
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 2,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 24,
|
||||||
|
"max": [
|
||||||
|
6.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"type": "VEC2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"materials": [
|
||||||
|
{
|
||||||
|
"pbrMetallicRoughness": {
|
||||||
|
"baseColorTexture": {
|
||||||
|
"index": 0
|
||||||
|
},
|
||||||
|
"metallicFactor": 0.0
|
||||||
|
},
|
||||||
|
"name": "Texture"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textures": [
|
||||||
|
{
|
||||||
|
"sampler": 0,
|
||||||
|
"source": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"uri": "CesiumLogoFlat.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"samplers": [
|
||||||
|
{
|
||||||
|
"magFilter": 9729,
|
||||||
|
"minFilter": 9986,
|
||||||
|
"wrapS": 33648,
|
||||||
|
"wrapT": 33071
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bufferViews": [
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 768,
|
||||||
|
"byteLength": 72,
|
||||||
|
"target": 34963
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"byteLength": 576,
|
||||||
|
"byteStride": 12,
|
||||||
|
"target": 34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 576,
|
||||||
|
"byteLength": 192,
|
||||||
|
"byteStride": 8,
|
||||||
|
"target": 34962
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buffers": [
|
||||||
|
{
|
||||||
|
"byteLength": 840,
|
||||||
|
"uri": "BoxTextured0.bin"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -426,4 +426,13 @@ TEST_F( utglTF2ImportExport, crash_in_anim_mesh_destructor ) {
|
||||||
ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube_out.glTF"));
|
ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube_out.glTF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(utglTF2ImportExport, error_string_preserved) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/MissingBin/BoxTextured.gltf",
|
||||||
|
aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_EQ(nullptr, scene);
|
||||||
|
std::string error = importer.GetErrorString();
|
||||||
|
ASSERT_NE(error.find("BoxTextured0.bin"), std::string::npos) << "Error string should contain an error about missing .bin file";
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
Loading…
Reference in New Issue