tiny_gltf.h - use member initialization
This commit is contained in:
Thomas Gamper 2023-11-22 15:59:13 +01:00
parent fd6c7855e7
commit 1f42c963e6

View File

@ -735,7 +735,7 @@ struct OcclusionTextureInfo {
// pbrMetallicRoughness class defined in glTF 2.0 spec. // pbrMetallicRoughness class defined in glTF 2.0 spec.
struct PbrMetallicRoughness { 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; TextureInfo baseColorTexture;
double metallicFactor{1.0}; // default 1 double metallicFactor{1.0}; // default 1
double roughnessFactor{1.0}; // default 1 double roughnessFactor{1.0}; // default 1
@ -748,9 +748,9 @@ struct PbrMetallicRoughness {
std::string extras_json_string; std::string extras_json_string;
std::string extensions_json_string; std::string extensions_json_string;
PbrMetallicRoughness() PbrMetallicRoughness() = default;
: baseColorFactor(std::vector<double>{1.0, 1.0, 1.0, 1.0}) {}
DEFAULT_METHODS(PbrMetallicRoughness) DEFAULT_METHODS(PbrMetallicRoughness)
bool operator==(const PbrMetallicRoughness &) const; bool operator==(const PbrMetallicRoughness &) const;
}; };
@ -760,10 +760,10 @@ struct PbrMetallicRoughness {
struct Material { struct Material {
std::string name; std::string name;
std::vector<double> emissiveFactor; // length 3. default [0, 0, 0] std::vector<double> emissiveFactor{0.0, 0.0, 0.0}; // length 3. default [0, 0, 0]
std::string alphaMode; // default "OPAQUE" std::string alphaMode{"OPAQUE"}; // default "OPAQUE"
double alphaCutoff{0.5}; // default 0.5 double alphaCutoff{0.5}; // default 0.5
bool doubleSided{false}; // default false; bool doubleSided{false}; // default false
PbrMetallicRoughness pbrMetallicRoughness; PbrMetallicRoughness pbrMetallicRoughness;
@ -783,9 +783,7 @@ struct Material {
std::string extras_json_string; std::string extras_json_string;
std::string extensions_json_string; std::string extensions_json_string;
Material() Material() = default;
: emissiveFactor(std::vector<double>{0.0, 0.0, 0.0}), alphaMode("OPAQUE")
{}
DEFAULT_METHODS(Material) DEFAULT_METHODS(Material)
bool operator==(const Material &) const; bool operator==(const Material &) const;