Skip to content

Commit

Permalink
bugfix scene loader for missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
beaumanvienna committed Oct 13, 2024
1 parent d1770ad commit 2038197
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions engine/scene/sceneLoaderDeserializeJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ namespace GfxRenderEngine
m_SceneDescriptionFile.m_GltfFiles.m_GltfFilesFromScene;
for (auto& gltfInfo : gltfInfoVector)
{
if (!gltfInfo.m_LoadFuture.get())
if (!gltfInfo.m_LoadFuture.has_value())
{
// file was not loaded (probably not found on disk)
continue;
}
auto& loadFuture = gltfInfo.m_LoadFuture.value();
if (!loadFuture.get())
{
LOG_CORE_CRITICAL("gltf file did not load properly: {0}", gltfInfo.m_GltfFile.m_Filename);
continue;
Expand Down Expand Up @@ -212,7 +218,7 @@ namespace GfxRenderEngine
LOG_CORE_INFO("loading {0} gltf files (fastgltf)", gltfFileCount);
}

std::vector<GltfInfo> gltfInfoVector;
std::vector<GltfInfo> gltfInfoVector{};
gltfInfoVector.resize(gltfFileCount);

{
Expand All @@ -230,7 +236,13 @@ namespace GfxRenderEngine

for (auto& gltfInfo : gltfInfoVector)
{
if (!gltfInfo.m_LoadFuture.get())
if (!gltfInfo.m_LoadFuture.has_value())
{
// file was not loaded (probably not found on disk)
continue;
}
auto& loadFuture = gltfInfo.m_LoadFuture.value();
if (!loadFuture.get())
{
LOG_CORE_CRITICAL("gltf file did not load properly: {0}", gltfInfo.m_GltfFile.m_Filename);
continue;
Expand Down Expand Up @@ -749,7 +761,13 @@ namespace GfxRenderEngine
{
for (auto& terrainInfo : m_TerrainInfos)
{
if (!terrainInfo.m_LoadFuture.get())
if (!terrainInfo.m_LoadFuture.has_value())
{
// file was not loaded (probably not found on disk)
continue;
}
auto& loadFuture = terrainInfo.m_LoadFuture.value();
if (!loadFuture.get())
{
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions engine/scene/sceneLoaderJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ namespace GfxRenderEngine

struct GltfInfo
{
std::future<bool> m_LoadFuture;
std::optional<std::future<bool>> m_LoadFuture{std::nullopt};
Gltf::GltfFile m_GltfFile;
int m_InstanceCount{0};
std::vector<TransformComponent> m_InstanceTransforms;
};

struct TerrainInfo
{
std::future<bool> m_LoadFuture;
std::optional<std::future<bool>> m_LoadFuture{std::nullopt};
std::string m_Filename;
int m_InstanceCount{0};
std::vector<TransformComponent> m_InstanceTransforms;
Expand Down

0 comments on commit 2038197

Please sign in to comment.