From 83ccb9f28dab56ebe1eee79dd65df6c2ba6cfbe4 Mon Sep 17 00:00:00 2001 From: DingboDingboDingbo <51836582+DingboDingboDingbo@users.noreply.github.com> Date: Thu, 29 Aug 2019 18:49:15 -0400 Subject: [PATCH 1/4] GetTypeSizeInBytes not returning Type Size In Bytes Changed name to be less misleading. --- tiny_gltf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 62c466d..27de815 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -195,7 +195,7 @@ static inline int32_t GetComponentSizeInBytes(uint32_t componentType) { } } -static inline int32_t GetTypeSizeInBytes(uint32_t ty) { +static inline int32_t GetNumComponentsInType(uint32_t ty) { if (ty == TINYGLTF_TYPE_SCALAR) { return 1; } else if (ty == TINYGLTF_TYPE_VEC2) { @@ -745,7 +745,7 @@ struct Accessor { return -1; } - int typeSizeInBytes = GetTypeSizeInBytes(static_cast(type)); + int typeSizeInBytes = GetNumComponentsInType(static_cast(type)); if (typeSizeInBytes <= 0) { return -1; } From 81d75df48a42a13e80f1b86fdf9d028aaef8afea Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Fri, 30 Aug 2019 19:19:52 +0900 Subject: [PATCH 2/4] Rename typeSizeInBytes to numComponents. --- tiny_gltf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 27de815..54389cd 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -745,12 +745,12 @@ struct Accessor { return -1; } - int typeSizeInBytes = GetNumComponentsInType(static_cast(type)); - if (typeSizeInBytes <= 0) { + int numComponents = GetNumComponentsInType(static_cast(type)); + if (numComponents <= 0) { return -1; } - return componentSizeInBytes * typeSizeInBytes; + return componentSizeInBytes * numComponents; } else { // Check if byteStride is a mulple of the size of the accessor's component // type. From 6143c6662b1696bf3abd792148d4b16234bc1549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Schmith=C3=BCsen?= Date: Mon, 2 Sep 2019 13:41:59 +0200 Subject: [PATCH 3/4] don't fail if a scene has no nodes property (which is not required) --- tiny_gltf.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 62c466d..67ed245 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -4563,9 +4563,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn, } const json &o = it->get(); std::vector nodes; - if (!ParseIntegerArrayProperty(&nodes, err, o, "nodes", false)) { - return false; - } + ParseIntegerArrayProperty(&nodes, err, o, "nodes", false)); Scene scene; scene.nodes = std::move(nodes); From ce25385eab64fa29da300aee602101db24b11c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Schmith=C3=BCsen?= Date: Mon, 2 Sep 2019 13:43:24 +0200 Subject: [PATCH 4/4] remove extra parenthesis --- tiny_gltf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 67ed245..0719dd9 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -4563,7 +4563,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn, } const json &o = it->get(); std::vector nodes; - ParseIntegerArrayProperty(&nodes, err, o, "nodes", false)); + ParseIntegerArrayProperty(&nodes, err, o, "nodes", false); Scene scene; scene.nodes = std::move(nodes);