From 1f42c963e620d958e11b450ffa925fd061034936 Mon Sep 17 00:00:00 2001 From: Thomas Gamper Date: Wed, 22 Nov 2023 15:59:13 +0100 Subject: [PATCH] fix #459 tiny_gltf.h - use member initialization --- tiny_gltf.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 6b0b75c..7991303 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -735,7 +735,7 @@ struct OcclusionTextureInfo { // pbrMetallicRoughness class defined in glTF 2.0 spec. struct PbrMetallicRoughness { - std::vector baseColorFactor; // len = 4. default [1,1,1,1] + std::vector baseColorFactor{1.0, 1.0, 1.0, 1.0}; // len = 4. default [1,1,1,1] TextureInfo baseColorTexture; double metallicFactor{1.0}; // default 1 double roughnessFactor{1.0}; // default 1 @@ -748,9 +748,9 @@ struct PbrMetallicRoughness { std::string extras_json_string; std::string extensions_json_string; - PbrMetallicRoughness() - : baseColorFactor(std::vector{1.0, 1.0, 1.0, 1.0}) {} + PbrMetallicRoughness() = default; DEFAULT_METHODS(PbrMetallicRoughness) + bool operator==(const PbrMetallicRoughness &) const; }; @@ -760,10 +760,10 @@ struct PbrMetallicRoughness { struct Material { std::string name; - std::vector emissiveFactor; // length 3. default [0, 0, 0] - std::string alphaMode; // default "OPAQUE" - double alphaCutoff{0.5}; // default 0.5 - bool doubleSided{false}; // default false; + std::vector emissiveFactor{0.0, 0.0, 0.0}; // length 3. default [0, 0, 0] + std::string alphaMode{"OPAQUE"}; // default "OPAQUE" + double alphaCutoff{0.5}; // default 0.5 + bool doubleSided{false}; // default false PbrMetallicRoughness pbrMetallicRoughness; @@ -783,9 +783,7 @@ struct Material { std::string extras_json_string; std::string extensions_json_string; - Material() - : emissiveFactor(std::vector{0.0, 0.0, 0.0}), alphaMode("OPAQUE") - {} + Material() = default; DEFAULT_METHODS(Material) bool operator==(const Material &) const;