Skip to content

Commit

Permalink
renderer: Gracefully handle missing ao buffer when loading MapStaticAO
Browse files Browse the repository at this point in the history
  • Loading branch information
cohaereo committed Jan 10, 2025
1 parent 70aeb43 commit a5dc359
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/alkahest-renderer/src/ecs/map.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -138,7 +139,8 @@ pub struct MapStaticAO {

impl MapStaticAO {
pub fn from_tag(gpu: &GpuContext, tag: &SStaticAmbientOcclusion) -> anyhow::Result<Self> {
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
Expand Down
10 changes: 6 additions & 4 deletions crates/alkahest-renderer/src/loaders/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,12 @@ fn load_datatable_into_scene<R: Read + Seek>(
}
};

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
Expand Down

0 comments on commit a5dc359

Please sign in to comment.