mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-07-05 03:45:10 +08:00
Do not serialize pbrMetallicRoughness when they have all default values. Fixes #204
This commit is contained in:
parent
14977937c2
commit
7e009041e3
@ -6314,8 +6314,16 @@ static void SerializeGltfMaterial(Material &material, json &o) {
|
|||||||
json pbrMetallicRoughness;
|
json pbrMetallicRoughness;
|
||||||
SerializeGltfPbrMetallicRoughness(material.pbrMetallicRoughness,
|
SerializeGltfPbrMetallicRoughness(material.pbrMetallicRoughness,
|
||||||
pbrMetallicRoughness);
|
pbrMetallicRoughness);
|
||||||
|
// Issue 204
|
||||||
|
// Do not serialize `pbrMetallicRoughness` if pbrMetallicRoughness has all
|
||||||
|
// default values(json is null). Otherwise it will serialize to
|
||||||
|
// `pbrMetallicRoughness : null`, which cannot be read by other glTF
|
||||||
|
// importers(and validators).
|
||||||
|
//
|
||||||
|
if (!JsonIsNull(pbrMetallicRoughness)) {
|
||||||
JsonAddMember(o, "pbrMetallicRoughness", std::move(pbrMetallicRoughness));
|
JsonAddMember(o, "pbrMetallicRoughness", std::move(pbrMetallicRoughness));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0 // legacy way. just for the record.
|
#if 0 // legacy way. just for the record.
|
||||||
if (material.values.size()) {
|
if (material.values.size()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user