Support booleans in glTF extras

This commit is contained in:
Nikita Lisitsa 2024-08-02 16:56:15 +03:00
parent c1c9e304da
commit 0718282dda
2 changed files with 5 additions and 3 deletions

View file

@ -19,7 +19,7 @@ namespace psemek::gfx
struct gltf_asset struct gltf_asset
{ {
using extra = std::variant<float, std::vector<float>, std::string>; using extra = std::variant<bool, float, std::vector<float>, std::string>;
using extras_map = util::hash_map<util::hstring, extra>; using extras_map = util::hash_map<util::hstring, extra>;
struct node struct node

View file

@ -90,7 +90,9 @@ namespace psemek::gfx
bool error = false; bool error = false;
if (extra.value.IsNumber()) if (extra.value.IsBool())
value = extra.value.GetBool();
else if (extra.value.IsNumber())
value = extra.value.GetFloat(); value = extra.value.GetFloat();
else if (extra.value.IsString()) else if (extra.value.IsString())
value = extra.value.GetString(); value = extra.value.GetString();
@ -110,7 +112,7 @@ namespace psemek::gfx
error = true; error = true;
if (error) if (error)
log::warning() << "every 'extras' value must be either a number, an array of numbers, or a string (while parting glTF)"; log::warning() << "every 'extras' value must be either a boolean, a number, an array of numbers, or a string (while parsing glTF)";
else else
result[name] = std::move(value); result[name] = std::move(value);
} }