From a472a3fa0f9bbefe1d88b061d8d5b6e5cd1d212e Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Wed, 21 Aug 2019 14:23:00 +0900 Subject: [PATCH] Add Set/Get SerializeDefaultValues method(W.I.P.) --- tiny_gltf.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index a8dc6a4..ec6f0b9 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1078,6 +1078,9 @@ bool WriteWholeFile(std::string *err, const std::string &filepath, const std::vector &contents, void *); #endif +/// +/// glTF Parser/Serialier context. +/// class TinyGLTF { public: #ifdef __clang__ @@ -1162,6 +1165,22 @@ class TinyGLTF { /// void SetFsCallbacks(FsCallbacks callbacks); + + /// + /// Set serializing default values(default = false). + /// When true, default values are force serialized to .glTF. + /// This may be helpfull if you want to serialize a full description of glTF data. + /// + /// TODO(LTE): Supply parsing option as function arguments to `LoadASCIIFromFile()` and others, not by a class method + /// + void SetSerializeDefaultValues(const bool enabled) { + serialize_default_values_ = enabled; + } + + bool GetSerializeDefaultValues() const { + return serialize_default_values_; + } + private: /// /// Loads glTF asset from string(memory). @@ -1173,9 +1192,11 @@ class TinyGLTF { const char *str, const unsigned int length, const std::string &base_dir, unsigned int check_sections); - const unsigned char *bin_data_; - size_t bin_size_; - bool is_binary_; + const unsigned char *bin_data_ = nullptr; + size_t bin_size_ = 0; + bool is_binary_ = false; + + bool serialize_default_values_ = false; ///< Serialize default values? FsCallbacks fs = { #ifndef TINYGLTF_NO_FS