From a5dc3596844f9816897acd05e2fa690a991c4215 Mon Sep 17 00:00:00 2001 From: cohaereo Date: Fri, 10 Jan 2025 21:53:05 +0100 Subject: [PATCH] renderer: Gracefully handle missing ao buffer when loading MapStaticAO --- crates/alkahest-renderer/src/ecs/map.rs | 4 +++- crates/alkahest-renderer/src/loaders/map.rs | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/alkahest-renderer/src/ecs/map.rs b/crates/alkahest-renderer/src/ecs/map.rs index a8c06db..1f79195 100644 --- a/crates/alkahest-renderer/src/ecs/map.rs +++ b/crates/alkahest-renderer/src/ecs/map.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use alkahest_data::map::{SMapAtmosphere, SStaticAmbientOcclusion}; +use anyhow::Context; use bevy_ecs::{prelude::Component, system::Resource}; use destiny_pkg::TagHash; use glam::Vec3; @@ -138,7 +139,8 @@ pub struct MapStaticAO { impl MapStaticAO { pub fn from_tag(gpu: &GpuContext, tag: &SStaticAmbientOcclusion) -> anyhow::Result { - let ao_buffer = load_vertex_buffer(gpu, tag.ao0.buffer)?; + let ao_buffer = + load_vertex_buffer(gpu, tag.ao0.buffer).context("Failed to load AO vertex buffer")?; let offset_map = tag .ao0 .mappings diff --git a/crates/alkahest-renderer/src/loaders/map.rs b/crates/alkahest-renderer/src/loaders/map.rs index af66a68..5fa8867 100644 --- a/crates/alkahest-renderer/src/loaders/map.rs +++ b/crates/alkahest-renderer/src/loaders/map.rs @@ -779,10 +779,12 @@ fn load_datatable_into_scene( } }; - scene.insert_resource( - MapStaticAO::from_tag(&renderer.gpu, &static_ao) - .context("Failed to load static AO")?, - ); + match MapStaticAO::from_tag(&renderer.gpu, &static_ao) { + Ok(o) => scene.insert_resource(o), + Err(e) => { + error!(error=?e, tag=%tag, "Failed to load static AO"); + } + } } 0x80806a63 => { table_data