Skip to content

Commit

Permalink
Check if sky texture exists before accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyuu17 committed Jun 28, 2024
1 parent 3e31e8c commit c3a11d7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/SWBF2/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ namespace SWBF2
{
godot::Sky *sky = memnew(godot::Sky);
{
auto &texture = Native::SWBF2::m_tex[Native::SWBF2::m_skyDome.m_texture].m_formats[0].m_faceLevels[0].m_gdTexture;
godot::ProceduralSkyMaterial *procSkyMaterial = memnew(godot::ProceduralSkyMaterial);
procSkyMaterial->set_sky_cover(texture);
const auto &textureName = Native::SWBF2::m_skyDome.m_texture;

sky->set_material(procSkyMaterial);
if (Native::SWBF2::m_tex.contains(textureName))
{
auto &texture = Native::SWBF2::m_tex[textureName].m_formats[0].m_faceLevels[0].m_gdTexture;
godot::ProceduralSkyMaterial *procSkyMaterial = memnew(godot::ProceduralSkyMaterial);
procSkyMaterial->set_sky_cover(texture);

sky->set_material(procSkyMaterial);
}
}

env->set_background(godot::Environment::BG_SKY);
Expand Down

0 comments on commit c3a11d7

Please sign in to comment.