Skip to content

Commit 581287a

Browse files
committed
🐛 Check optionals before access
1 parent 7895bfd commit 581287a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/scene/src/gltf_loader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ Material to_material(gltf::Material const& material) {
5858
ret->roughness = material.pbr.roughness_factor;
5959
ret->alpha_mode = material.alpha_mode;
6060
ret->alpha_cutoff = material.alpha_cutoff;
61-
ret->base_colour = material.pbr.base_colour_texture->texture;
62-
ret->roughness_metallic = material.pbr.metallic_roughness_texture->texture;
63-
ret->emissive = material.emissive_texture->texture;
61+
if (material.pbr.base_colour_texture) { ret->base_colour = material.pbr.base_colour_texture->texture; }
62+
if (material.pbr.metallic_roughness_texture) { ret->roughness_metallic = material.pbr.metallic_roughness_texture->texture; }
63+
if (material.emissive_texture) { ret->emissive = material.emissive_texture->texture; }
6464
ret->emissive_factor = material.emissive_factor;
6565
return {std::move(ret)};
6666
}

0 commit comments

Comments
 (0)