mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-04 00:04:03 -04:00
Raise a warning when encountering emissiveFactor with array length
of 4 instead of aborting the model loading Submitted upstream as https://github.com/syoyo/tinygltf/pull/445
This commit is contained in:
parent
0ffb24005a
commit
b35988e412
14
external/tinygltf/tiny_gltf.h
vendored
14
external/tinygltf/tiny_gltf.h
vendored
@ -5192,7 +5192,7 @@ static bool ParsePbrMetallicRoughness(
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseMaterial(Material *material, std::string *err,
|
||||
static bool ParseMaterial(Material *material, std::string *err, std::string *warn,
|
||||
const detail::json &o,
|
||||
bool store_original_json_for_extras_and_extensions) {
|
||||
ParseStringProperty(&material->name, err, o, "name", /* required */ false);
|
||||
@ -5200,7 +5200,15 @@ static bool ParseMaterial(Material *material, std::string *err,
|
||||
if (ParseNumberArrayProperty(&material->emissiveFactor, err, o,
|
||||
"emissiveFactor",
|
||||
/* required */ false)) {
|
||||
if (material->emissiveFactor.size() != 3) {
|
||||
if (material->emissiveFactor.size() == 4) {
|
||||
if (warn) {
|
||||
(*warn) +=
|
||||
"Array length of `emissiveFactor` parameter in "
|
||||
"material must be 3, but got 4\n";
|
||||
}
|
||||
material->emissiveFactor.resize(3);
|
||||
}
|
||||
else if (material->emissiveFactor.size() != 3) {
|
||||
if (err) {
|
||||
(*err) +=
|
||||
"Array length of `emissiveFactor` parameter in "
|
||||
@ -6198,7 +6206,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
|
||||
Material material;
|
||||
ParseStringProperty(&material.name, err, o, "name", false);
|
||||
|
||||
if (!ParseMaterial(&material, err, o,
|
||||
if (!ParseMaterial(&material, err, warn, o,
|
||||
store_original_json_for_extras_and_extensions_)) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user