mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-25 00:28:51 +00:00
Compare commits
4 Commits
remove-ass
...
sajson
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed3f31e95 | ||
|
|
6fcee26d0f | ||
|
|
bafde6a53e | ||
|
|
b8c04b0a9d |
@@ -153,6 +153,7 @@ if (!ret) {
|
|||||||
|
|
||||||
## Compile options
|
## Compile options
|
||||||
|
|
||||||
|
* `TINYGLTF_ENABLE_SERIALIZER` : Enable glTF serialization feature.
|
||||||
* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION` to fully remove C++ exception codes when compiling TinyGLTF.
|
* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION` to fully remove C++ exception codes when compiling TinyGLTF.
|
||||||
* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images.
|
* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images.
|
||||||
* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images.
|
* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images.
|
||||||
|
|||||||
199
tiny_gltf.h
199
tiny_gltf.h
@@ -26,6 +26,8 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
// Version:
|
// Version:
|
||||||
|
// - v2.4.3 Experimental sajson(lightweight JSON parser) backend support.
|
||||||
|
// Introduce TINYGLTF_ENABLE_SERIALIZER.
|
||||||
// - v2.4.2 Decode percent-encoded URI.
|
// - v2.4.2 Decode percent-encoded URI.
|
||||||
// - v2.4.1 Fix some glTF object class does not have `extensions` and/or
|
// - v2.4.1 Fix some glTF object class does not have `extensions` and/or
|
||||||
// `extras` property.
|
// `extras` property.
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
//
|
//
|
||||||
// Tiny glTF loader is using following third party libraries:
|
// Tiny glTF loader is using following third party libraries:
|
||||||
//
|
//
|
||||||
|
// - sajso: Lightweight C++ JSON library.
|
||||||
// - jsonhpp: C++ JSON library.
|
// - jsonhpp: C++ JSON library.
|
||||||
// - base64: base64 decode/encode library.
|
// - base64: base64 decode/encode library.
|
||||||
// - stb_image: Image loading library.
|
// - stb_image: Image loading library.
|
||||||
@@ -1323,6 +1326,8 @@ class TinyGLTF {
|
|||||||
const std::string &base_dir = "",
|
const std::string &base_dir = "",
|
||||||
unsigned int check_sections = REQUIRE_VERSION);
|
unsigned int check_sections = REQUIRE_VERSION);
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Write glTF to stream, buffers and images will be embeded
|
/// Write glTF to stream, buffers and images will be embeded
|
||||||
///
|
///
|
||||||
@@ -1336,16 +1341,22 @@ class TinyGLTF {
|
|||||||
bool embedImages, bool embedBuffers,
|
bool embedImages, bool embedBuffers,
|
||||||
bool prettyPrint, bool writeBinary);
|
bool prettyPrint, bool writeBinary);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callback to use for loading image data
|
/// Set callback to use for loading image data
|
||||||
///
|
///
|
||||||
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
|
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callback to use for writing image data
|
/// Set callback to use for writing image data
|
||||||
///
|
///
|
||||||
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
|
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callbacks to use for filesystem (fs) access and their user data
|
/// Set callbacks to use for filesystem (fs) access and their user data
|
||||||
///
|
///
|
||||||
@@ -1507,14 +1518,38 @@ class TinyGLTF {
|
|||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|
||||||
#ifndef TINYGLTF_NO_INCLUDE_JSON
|
#ifndef TINYGLTF_NO_INCLUDE_JSON
|
||||||
#ifndef TINYGLTF_USE_RAPIDJSON
|
#if defined(TINYGLTF_USE_RAPIDJSON)
|
||||||
#include "json.hpp"
|
|
||||||
#else
|
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "prettywriter.h"
|
#include "prettywriter.h"
|
||||||
#include "rapidjson.h"
|
#include "rapidjson.h"
|
||||||
#include "stringbuffer.h"
|
#include "stringbuffer.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
|
||||||
|
#if __has_warning("-Wc99-extensions")
|
||||||
|
#pragma clang diagnostic ignored "-Wc99-extensions"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_warning("-Wshadow-field-in-constructor")
|
||||||
|
#pragma clang diagnostic ignored "-Wshadow-field-in-constructor"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "sajson.h"
|
||||||
|
|
||||||
|
// Serialization is not available for sajson backend.
|
||||||
|
#ifdef TINYGLTF_ENABLE_SERIALIZER
|
||||||
|
#undef TINYGLTF_ENABLE_SERIALIZER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Default = nlohmann json
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1650,7 +1685,62 @@ struct JsonDocument : public rapidjson::Document {
|
|||||||
|
|
||||||
#endif // TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
|
#endif // TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
|
||||||
|
|
||||||
#else
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
|
||||||
|
using json = sajson::value;
|
||||||
|
using JsonDocument = json;
|
||||||
|
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
// muda
|
||||||
|
|
||||||
|
class sajson_const_iterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
sajson_const_iterator() = default;
|
||||||
|
sajson_const_iterator(const sajson::value &v) : _v(v) {
|
||||||
|
}
|
||||||
|
|
||||||
|
sajson_const_iterator(const sajson_const_iterator &rhs) = default;
|
||||||
|
sajson_const_iterator &operator=(const sajson_const_iterator &rhs) = default;
|
||||||
|
|
||||||
|
std::string key() const {
|
||||||
|
}
|
||||||
|
|
||||||
|
sajson::value &value() {
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sajson::value *begin() {
|
||||||
|
return &_v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(sajson_const_iterator &rhs) {
|
||||||
|
// TODO
|
||||||
|
assert(0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sajson_const_iterator &operator++() {
|
||||||
|
// TODO
|
||||||
|
assert(0);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
sajson::value &operator*() {
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// `sajson::value` itself is a small struct, so having a copy of it
|
||||||
|
// does not affect performance and memory consumption.
|
||||||
|
sajson::value _v;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
using json_const_iterator = sajson_const_iterator;
|
||||||
|
using json_const_array_iterator = json_const_iterator;
|
||||||
|
|
||||||
|
#else // nlohmann JSON
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
using json_const_iterator = json::const_iterator;
|
using json_const_iterator = json::const_iterator;
|
||||||
using json_const_array_iterator = json_const_iterator;
|
using json_const_array_iterator = json_const_iterator;
|
||||||
@@ -1662,6 +1752,14 @@ void JsonParse(JsonDocument &doc, const char *str, size_t length,
|
|||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
(void)throwExc;
|
(void)throwExc;
|
||||||
doc.Parse(str, length);
|
doc.Parse(str, length);
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// This code path is not available.
|
||||||
|
(void)doc;
|
||||||
|
(void)str;
|
||||||
|
(void)length;
|
||||||
|
(void)throwExc;
|
||||||
|
//doc = sajson::parse(sajson::dynamic_allocation(), sajson::mutable_string_view(length, const_cast<char *>(str)));
|
||||||
|
//doc.parse(sajson::dynamic_allocation(), sajson::mutable_string_view(length, const_cast<char *>(str)));
|
||||||
#else
|
#else
|
||||||
doc = json::parse(str, str + length, nullptr, throwExc);
|
doc = json::parse(str, str + length, nullptr, throwExc);
|
||||||
#endif
|
#endif
|
||||||
@@ -2393,11 +2491,15 @@ bool LoadImageData(Image *image, const int image_idx, std::string *err,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
|
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
|
||||||
WriteImageData = func;
|
WriteImageData = func;
|
||||||
write_image_user_data_ = user_data;
|
write_image_user_data_ = user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
||||||
static void WriteToMemory_stbi(void *context, void *data, int size) {
|
static void WriteToMemory_stbi(void *context, void *data, int size) {
|
||||||
std::vector<unsigned char> *buffer =
|
std::vector<unsigned char> *buffer =
|
||||||
@@ -2888,6 +2990,15 @@ bool GetInt(const json &o, int &val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
auto type = o.get_type();
|
||||||
|
|
||||||
|
if (type == sajson::TYPE_INTEGER) {
|
||||||
|
val = static_cast<int>(o.get_number_value());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
auto type = o.type();
|
auto type = o.type();
|
||||||
@@ -2920,6 +3031,16 @@ bool GetNumber(const json &o, double &val) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
auto type = o.get_type();
|
||||||
|
|
||||||
|
if ((type == sajson::TYPE_DOUBLE) ||
|
||||||
|
(type == sajson::TYPE_INTEGER)) {
|
||||||
|
val = static_cast<double>(o.get_number_value());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if (o.is_number()) {
|
if (o.is_number()) {
|
||||||
@@ -2938,6 +3059,15 @@ bool GetString(const json &o, std::string &val) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
auto type = o.get_type();
|
||||||
|
|
||||||
|
if (type == sajson::TYPE_STRING) {
|
||||||
|
val = o.as_string();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if (o.type() == json::value_t::string) {
|
if (o.type() == json::value_t::string) {
|
||||||
@@ -2952,6 +3082,8 @@ bool GetString(const json &o, std::string &val) {
|
|||||||
bool IsArray(const json &o) {
|
bool IsArray(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.IsArray();
|
return o.IsArray();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
return o.get_type() == sajson::TYPE_ARRAY;
|
||||||
#else
|
#else
|
||||||
return o.is_array();
|
return o.is_array();
|
||||||
#endif
|
#endif
|
||||||
@@ -2960,6 +3092,10 @@ bool IsArray(const json &o) {
|
|||||||
json_const_array_iterator ArrayBegin(const json &o) {
|
json_const_array_iterator ArrayBegin(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.Begin();
|
return o.Begin();
|
||||||
|
#elif TINYGLTF_USE_SAJSON
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return json_const_array_iterator(o);
|
||||||
#else
|
#else
|
||||||
return o.begin();
|
return o.begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -2968,6 +3104,10 @@ json_const_array_iterator ArrayBegin(const json &o) {
|
|||||||
json_const_array_iterator ArrayEnd(const json &o) {
|
json_const_array_iterator ArrayEnd(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.End();
|
return o.End();
|
||||||
|
#elif TINYGLTF_USE_SAJSON
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return json_const_array_iterator(o);
|
||||||
#else
|
#else
|
||||||
return o.end();
|
return o.end();
|
||||||
#endif
|
#endif
|
||||||
@@ -2976,6 +3116,8 @@ json_const_array_iterator ArrayEnd(const json &o) {
|
|||||||
bool IsObject(const json &o) {
|
bool IsObject(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.IsObject();
|
return o.IsObject();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
return o.get_type() == sajson::TYPE_OBJECT;
|
||||||
#else
|
#else
|
||||||
return o.is_object();
|
return o.is_object();
|
||||||
#endif
|
#endif
|
||||||
@@ -2984,6 +3126,11 @@ bool IsObject(const json &o) {
|
|||||||
json_const_iterator ObjectBegin(const json &o) {
|
json_const_iterator ObjectBegin(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.MemberBegin();
|
return o.MemberBegin();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
assert(o.get_type() == sajson::TYPE_OBJECT);
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return json_const_iterator(o);
|
||||||
#else
|
#else
|
||||||
return o.begin();
|
return o.begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -2992,6 +3139,11 @@ json_const_iterator ObjectBegin(const json &o) {
|
|||||||
json_const_iterator ObjectEnd(const json &o) {
|
json_const_iterator ObjectEnd(const json &o) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return o.MemberEnd();
|
return o.MemberEnd();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
assert(o.get_type() == sajson::TYPE_OBJECT);
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return json_const_iterator(o);
|
||||||
#else
|
#else
|
||||||
return o.end();
|
return o.end();
|
||||||
#endif
|
#endif
|
||||||
@@ -3000,6 +3152,10 @@ json_const_iterator ObjectEnd(const json &o) {
|
|||||||
const char *GetKey(json_const_iterator &it) {
|
const char *GetKey(json_const_iterator &it) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return it->name.GetString();
|
return it->name.GetString();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
return it.key().c_str();
|
return it.key().c_str();
|
||||||
#endif
|
#endif
|
||||||
@@ -3012,6 +3168,10 @@ bool FindMember(const json &o, const char *member, json_const_iterator &it) {
|
|||||||
}
|
}
|
||||||
it = o.FindMember(member);
|
it = o.FindMember(member);
|
||||||
return it != o.MemberEnd();
|
return it != o.MemberEnd();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return false;
|
||||||
#else
|
#else
|
||||||
it = o.find(member);
|
it = o.find(member);
|
||||||
return it != o.end();
|
return it != o.end();
|
||||||
@@ -3021,6 +3181,10 @@ bool FindMember(const json &o, const char *member, json_const_iterator &it) {
|
|||||||
const json &GetValue(json_const_iterator &it) {
|
const json &GetValue(json_const_iterator &it) {
|
||||||
#ifdef TINYGLTF_USE_RAPIDJSON
|
#ifdef TINYGLTF_USE_RAPIDJSON
|
||||||
return it->value;
|
return it->value;
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// TODO(syoyo): Implement
|
||||||
|
assert(0);
|
||||||
|
return it.value();
|
||||||
#else
|
#else
|
||||||
return it.value();
|
return it.value();
|
||||||
#endif
|
#endif
|
||||||
@@ -3039,6 +3203,11 @@ std::string JsonToString(const json &o, int spacing = -1) {
|
|||||||
o.Accept(writer);
|
o.Accept(writer);
|
||||||
}
|
}
|
||||||
return buffer.GetString();
|
return buffer.GetString();
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// Serialize is not available for Sajson
|
||||||
|
(void)o;
|
||||||
|
(void)spacing;
|
||||||
|
return std::string();
|
||||||
#else
|
#else
|
||||||
return o.dump(spacing);
|
return o.dump(spacing);
|
||||||
#endif
|
#endif
|
||||||
@@ -3094,7 +3263,10 @@ static bool ParseJsonAsValue(Value *ret, const json &o) {
|
|||||||
break;
|
break;
|
||||||
// all types are covered, so no `case default`
|
// all types are covered, so no `case default`
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// TODO
|
||||||
|
assert(0);
|
||||||
|
#else // json.hpp
|
||||||
switch (o.type()) {
|
switch (o.type()) {
|
||||||
case json::value_t::object: {
|
case json::value_t::object: {
|
||||||
Value::Object value_object;
|
Value::Object value_object;
|
||||||
@@ -3177,6 +3349,11 @@ static bool ParseBooleanProperty(bool *ret, std::string *err, const json &o,
|
|||||||
if (isBoolean) {
|
if (isBoolean) {
|
||||||
boolValue = value.GetBool();
|
boolValue = value.GetBool();
|
||||||
}
|
}
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
isBoolean = value.is_boolean();
|
||||||
|
if (isBoolean) {
|
||||||
|
boolValue = value.get_boolean_value();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
isBoolean = value.is_boolean();
|
isBoolean = value.is_boolean();
|
||||||
if (isBoolean) {
|
if (isBoolean) {
|
||||||
@@ -3266,6 +3443,11 @@ static bool ParseUnsignedProperty(size_t *ret, std::string *err, const json &o,
|
|||||||
uValue = value.GetUint64();
|
uValue = value.GetUint64();
|
||||||
isUValue = true;
|
isUValue = true;
|
||||||
}
|
}
|
||||||
|
#elif defined(TINYGLTF_USE_SAJSON)
|
||||||
|
isUValue = value.get_type() == sajson::TYPE_INTEGER;
|
||||||
|
if (isUValue) {
|
||||||
|
uValue = value.get_integer_value();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
isUValue = value.is_number_unsigned();
|
isUValue = value.is_number_unsigned();
|
||||||
if (isUValue) {
|
if (isUValue) {
|
||||||
@@ -6044,10 +6226,13 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
|
|||||||
// 19. Parse Extras
|
// 19. Parse Extras
|
||||||
ParseExtrasProperty(&model->extras, v);
|
ParseExtrasProperty(&model->extras, v);
|
||||||
|
|
||||||
|
#if !defined(TINYGLTF_USE_SAJSON)
|
||||||
|
// TODO(syoyo): Support SAJSON backend
|
||||||
if (store_original_json_for_extras_and_extensions_) {
|
if (store_original_json_for_extras_and_extensions_) {
|
||||||
model->extras_json_string = JsonToString(v["extras"]);
|
model->extras_json_string = JsonToString(v["extras"]);
|
||||||
model->extensions_json_string = JsonToString(v["extensions"]);
|
model->extensions_json_string = JsonToString(v["extensions"]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -6214,6 +6399,8 @@ bool TinyGLTF::LoadBinaryFromFile(Model *model, std::string *err,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// GLTF Serialization
|
// GLTF Serialization
|
||||||
///////////////////////
|
///////////////////////
|
||||||
@@ -7619,6 +7806,8 @@ bool TinyGLTF::WriteGltfSceneToFile(Model *model, const std::string &filename,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // TINYGLTF_ENABLE_SERIALIZER
|
||||||
|
|
||||||
} // namespace tinygltf
|
} // namespace tinygltf
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
|||||||
Reference in New Issue
Block a user