From 4ebd6368fbcdf3bb7b4066674dde0b9d9dc705fc Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Thu, 15 Aug 2019 12:25:50 +0900 Subject: [PATCH] Fix inequality of texture index check when serializing texture of material. Texture info was written even if it have invalid index(-1). Fixes #189 --- tiny_gltf.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index b18aed9..36226c1 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -5382,13 +5382,13 @@ static void SerializeGltfPbrMetallicRoughness(PbrMetallicRoughness &pbr, SerializeNumberProperty("roughnessFactor", pbr.roughnessFactor, o); } - if (pbr.baseColorTexture.index >= -1) { + if (pbr.baseColorTexture.index > -1) { json texinfo; SerializeGltfTextureInfo(pbr.baseColorTexture, texinfo); o["baseColorTexture"] = texinfo; } - if (pbr.metallicRoughnessTexture.index >= -1) { + if (pbr.metallicRoughnessTexture.index > -1) { json texinfo; SerializeGltfTextureInfo(pbr.metallicRoughnessTexture, texinfo); o["metallicRoughnessTexture"] = texinfo; @@ -5418,19 +5418,19 @@ static void SerializeGltfMaterial(Material &material, json &o) { o["doubleSided"] = json(material.doubleSided); - if (material.normalTexture.index >= -1) { + if (material.normalTexture.index > -1) { json texinfo; SerializeGltfNormalTextureInfo(material.normalTexture, texinfo); o["normalTexture"] = texinfo; } - if (material.occlusionTexture.index >= -1) { + if (material.occlusionTexture.index > -1) { json texinfo; SerializeGltfOcclusionTextureInfo(material.occlusionTexture, texinfo); o["occlusionTexture"] = texinfo; } - if (material.emissiveTexture.index >= -1) { + if (material.emissiveTexture.index > -1) { json texinfo; SerializeGltfTextureInfo(material.emissiveTexture, texinfo); o["emissiveTexture"] = texinfo;