From c3353e1acd5f0d7544fc9181fe7b33051000b161 Mon Sep 17 00:00:00 2001 From: Selmar Kok Date: Fri, 18 Oct 2019 18:22:35 +0200 Subject: [PATCH] set default values for baseColorFactor so that it has correct values when parsing a material without a pbrMetallicRoughness struct --- tiny_gltf.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 01a5278..f80ee84 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -739,7 +739,7 @@ struct PbrMetallicRoughness { Value extras; ExtensionMap extensions; - PbrMetallicRoughness() : metallicFactor(1.0), roughnessFactor(1.0) {} + PbrMetallicRoughness() : baseColorFactor(std::vector{ 1.0,1.0,1.0,1.0 }), metallicFactor(1.0), roughnessFactor(1.0) {} PbrMetallicRoughness(const PbrMetallicRoughness &) = default; PbrMetallicRoughness &operator=(const PbrMetallicRoughness &) = default; PbrMetallicRoughness(PbrMetallicRoughness &&rhs) noexcept @@ -4412,11 +4412,8 @@ static bool ParsePbrMetallicRoughness(PbrMetallicRoughness *pbr, } return false; } - } else { - // fill with default values - baseColorFactor = {1.0, 1.0, 1.0, 1.0}; + pbr->baseColorFactor = baseColorFactor; } - pbr->baseColorFactor = baseColorFactor; { json_const_iterator it;