Skip to content

Commit

Permalink
fix #459
Browse files Browse the repository at this point in the history
tiny_gltf.h - use member initialization
  • Loading branch information
ptc-tgamper committed Nov 22, 2023
1 parent fd6c785 commit 1f42c96
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ struct OcclusionTextureInfo {

// pbrMetallicRoughness class defined in glTF 2.0 spec.
struct PbrMetallicRoughness {
std::vector<double> baseColorFactor; // len = 4. default [1,1,1,1]
std::vector<double> 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
Expand All @@ -748,9 +748,9 @@ struct PbrMetallicRoughness {
std::string extras_json_string;
std::string extensions_json_string;

PbrMetallicRoughness()
: baseColorFactor(std::vector<double>{1.0, 1.0, 1.0, 1.0}) {}
PbrMetallicRoughness() = default;
DEFAULT_METHODS(PbrMetallicRoughness)

bool operator==(const PbrMetallicRoughness &) const;
};

Expand All @@ -760,10 +760,10 @@ struct PbrMetallicRoughness {
struct Material {
std::string name;

std::vector<double> 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<double> 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;

Expand All @@ -783,9 +783,7 @@ struct Material {
std::string extras_json_string;
std::string extensions_json_string;

Material()
: emissiveFactor(std::vector<double>{0.0, 0.0, 0.0}), alphaMode("OPAQUE")
{}
Material() = default;
DEFAULT_METHODS(Material)

bool operator==(const Material &) const;
Expand Down

0 comments on commit 1f42c96

Please sign in to comment.