mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-07-25 09:44:25 +08:00
tiny_gltf.h - register MSFT_lod with the model's used extensions
This commit is contained in:
parent
b132612307
commit
b274b34972
26
tiny_gltf.h
26
tiny_gltf.h
@ -8334,6 +8334,32 @@ static void SerializeGltfModel(const Model *model, detail::json &o) {
|
||||
}
|
||||
}
|
||||
|
||||
// MSFT_lod
|
||||
|
||||
// Look if there is a node that employs MSFT_lod
|
||||
auto msft_lod_nodes_it = std::find_if(
|
||||
model->nodes.begin(), model->nodes.end(),
|
||||
[](const Node& node) { return !node.lods.empty(); });
|
||||
|
||||
// Look if there is a material that employs MSFT_lod
|
||||
auto msft_lod_materials_it = std::find_if(
|
||||
model->materials.begin(), model->materials.end(),
|
||||
[](const Material& material) {return !material.lods.empty(); });
|
||||
|
||||
// If either a node or a material employ MSFT_lod, then we need
|
||||
// to add MSFT_lod to the list of used extensions.
|
||||
if (msft_lod_nodes_it != model->nodes.end() || msft_lod_materials_it != model->materials.end()) {
|
||||
// First check if MSFT_lod is already registered as used extension
|
||||
auto has_msft_lod = std::find_if(
|
||||
extensionsUsed.begin(), extensionsUsed.end(),
|
||||
[](const std::string &s) { return (s.compare("MSFT_lod") == 0); });
|
||||
|
||||
// If MSFT_lod is not registered yet, add it
|
||||
if (has_msft_lod == extensionsUsed.end()) {
|
||||
extensionsUsed.push_back("MSFT_lod");
|
||||
}
|
||||
}
|
||||
|
||||
// Extensions used
|
||||
if (extensionsUsed.size()) {
|
||||
SerializeStringArrayProperty("extensionsUsed", extensionsUsed, o);
|
||||
|
Loading…
x
Reference in New Issue
Block a user