mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-29 18:48:50 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acf1e8a2b1 | ||
|
|
8c85d5e387 | ||
|
|
02e8b8da1e | ||
|
|
ddc76f7724 | ||
|
|
8e9aadf569 | ||
|
|
0eaa23fbfc | ||
|
|
2a5dc852cc |
@@ -109,6 +109,7 @@ WASI build example is located in [wasm](wasm) .
|
||||
* [SanityEngine](https://github.com/DethRaid/SanityEngine) - A C++/D3D12 renderer focused on the personal and professional development of its developer
|
||||
* [Open3D](http://www.open3d.org/) - A Modern Library for 3D Data Processing
|
||||
* [Supernova Engine](https://github.com/supernovaengine/supernova) - Game engine for 2D and 3D projects with Lua or C++ in data oriented design.
|
||||
* [Wicked Engine<img src="https://github.com/turanszkij/WickedEngine/blob/master/Content/logo_small.png" width="28px" align="center"/>](https://github.com/turanszkij/WickedEngine) - 3D engine with modern graphics
|
||||
* Your projects here! (Please send PR)
|
||||
|
||||
## TODOs
|
||||
|
||||
40
tiny_gltf.h
40
tiny_gltf.h
@@ -195,6 +195,11 @@ typedef enum {
|
||||
OBJECT_TYPE
|
||||
} Type;
|
||||
|
||||
typedef enum {
|
||||
PERMISSIVE,
|
||||
STRICT
|
||||
} ParseStrictness;
|
||||
|
||||
static inline int32_t GetComponentSizeInBytes(uint32_t componentType) {
|
||||
if (componentType == TINYGLTF_COMPONENT_TYPE_BYTE) {
|
||||
return 1;
|
||||
@@ -1463,6 +1468,11 @@ class TinyGLTF {
|
||||
bool embedImages, bool embedBuffers,
|
||||
bool prettyPrint, bool writeBinary);
|
||||
|
||||
///
|
||||
/// Sets the parsing strictness.
|
||||
///
|
||||
void SetParseStrictness(ParseStrictness strictness);
|
||||
|
||||
///
|
||||
/// Set callback to use for loading image data
|
||||
///
|
||||
@@ -1552,6 +1562,8 @@ class TinyGLTF {
|
||||
size_t bin_size_ = 0;
|
||||
bool is_binary_ = false;
|
||||
|
||||
ParseStrictness strictness_ = ParseStrictness::STRICT;
|
||||
|
||||
bool serialize_default_values_ = false; ///< Serialize default values?
|
||||
|
||||
bool store_original_json_for_extras_and_extensions_ = false;
|
||||
@@ -2553,6 +2565,10 @@ static bool LoadExternalFile(std::vector<unsigned char> *out, std::string *err,
|
||||
return true;
|
||||
}
|
||||
|
||||
void TinyGLTF::SetParseStrictness(ParseStrictness strictness) {
|
||||
strictness_ = strictness;
|
||||
}
|
||||
|
||||
void TinyGLTF::SetImageLoader(LoadImageDataFunction func, void *user_data) {
|
||||
LoadImageData = func;
|
||||
load_image_user_data_ = user_data;
|
||||
@@ -5192,15 +5208,24 @@ static bool ParsePbrMetallicRoughness(
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseMaterial(Material *material, std::string *err,
|
||||
static bool ParseMaterial(Material *material, std::string *err, std::string *warn,
|
||||
const detail::json &o,
|
||||
bool store_original_json_for_extras_and_extensions) {
|
||||
bool store_original_json_for_extras_and_extensions,
|
||||
ParseStrictness strictness) {
|
||||
ParseStringProperty(&material->name, err, o, "name", /* required */ false);
|
||||
|
||||
if (ParseNumberArrayProperty(&material->emissiveFactor, err, o,
|
||||
"emissiveFactor",
|
||||
/* required */ false)) {
|
||||
if (material->emissiveFactor.size() != 3) {
|
||||
if (strictness==ParseStrictness::PERMISSIVE && material->emissiveFactor.size() == 4) {
|
||||
if (warn) {
|
||||
(*warn) +=
|
||||
"Array length of `emissiveFactor` parameter in "
|
||||
"material must be 3, but got 4\n";
|
||||
}
|
||||
material->emissiveFactor.resize(3);
|
||||
}
|
||||
else if (material->emissiveFactor.size() != 3) {
|
||||
if (err) {
|
||||
(*err) +=
|
||||
"Array length of `emissiveFactor` parameter in "
|
||||
@@ -6198,8 +6223,9 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
|
||||
Material material;
|
||||
ParseStringProperty(&material.name, err, o, "name", false);
|
||||
|
||||
if (!ParseMaterial(&material, err, o,
|
||||
store_original_json_for_extras_and_extensions_)) {
|
||||
if (!ParseMaterial(&material, err, warn, o,
|
||||
store_original_json_for_extras_and_extensions_,
|
||||
strictness_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6644,8 +6670,8 @@ bool TinyGLTF::LoadBinaryFromMemory(Model *model, std::string *err,
|
||||
if (err) {
|
||||
(*err) =
|
||||
"Insufficient storage space for Chunk1(BIN data). At least Chunk1 "
|
||||
"Must have 4 bytes or more bytes, but got " +
|
||||
std::to_string((header_and_json_size + 12ull) - uint64_t(length)) +
|
||||
"Must have 4 or more bytes, but got " +
|
||||
std::to_string((header_and_json_size + 8ull) - uint64_t(length)) +
|
||||
".\n";
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user