diff --git a/Cargo.toml b/Cargo.toml index 5b23d1f7..763ab3f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ exclude = [] base64 = "0.21" bitflags = "2" bytemuck = { version = "1", features = ["derive"] } -choir = { git = "https://github.com/kvark/choir", rev = "2d7c6ffb74a21a34c18c70aeb0b93a61a42eb04f" } +choir = "0.7" egui = "0.23" glam = { version = "0.24", features = ["mint"] } log = "0.4" diff --git a/blade-render/src/model/mod.rs b/blade-render/src/model/mod.rs index 5f73a9ea..96e166a2 100644 --- a/blade-render/src/model/mod.rs +++ b/blade-render/src/model/mod.rs @@ -318,8 +318,8 @@ impl TextureReference<'_> { Some(&TextureSource::Embedded(ref _task, ref sub_cooker)) => { self.embedded_data = Cow::Owned(sub_cooker.extract_embedded()); } - Some(&TextureSource::Path(ref relative)) => { - self.path = Cow::Owned(relative.as_bytes().to_owned()); + Some(&TextureSource::Path(ref full)) => { + self.path = Cow::Owned(full.as_bytes().to_owned()); } None => {} } @@ -376,6 +376,7 @@ impl Baker { &self, texture: gltf::texture::Texture, meta: super::texture::Meta, + parent_cooker: &blade_asset::Cooker, data_buffers: &[Vec], ) -> TextureSource { match texture.source().source() { @@ -412,10 +413,11 @@ impl Baker { } else { uri }; + let full = parent_cooker.base_path().join(relative); if PRELOAD_TEXTURES { - self.asset_textures.load(relative, meta); + self.asset_textures.load(&full, meta); } - TextureSource::Path(relative.to_string()) + TextureSource::Path(full.to_str().unwrap().to_string()) } } } @@ -505,6 +507,7 @@ impl blade_asset::Baker for Baker { Some(info) => sources.insert(self.cook_texture( info.texture(), META_BASE_COLOR, + &cooker, &buffers, )), None => !0, @@ -517,6 +520,7 @@ impl blade_asset::Baker for Baker { Some(info) => sources.insert(self.cook_texture( info.texture(), META_NORMAL, + &cooker, &buffers, )), None => !0, diff --git a/examples/scene/data/plane.glb b/examples/scene/data/plane.glb new file mode 100644 index 00000000..c9d3f391 Binary files /dev/null and b/examples/scene/data/plane.glb differ diff --git a/examples/scene/data/scene.ron b/examples/scene/data/scene.ron index 5245eade..8ef8c05b 100644 --- a/examples/scene/data/scene.ron +++ b/examples/scene/data/scene.ron @@ -9,7 +9,7 @@ average_luminocity: 0.3, objects: [ ( - path: "monkey.gltf", + path: "plane.glb", ), ], ) diff --git a/examples/scene/main.rs b/examples/scene/main.rs index e3ec764c..ae53a7ae 100644 --- a/examples/scene/main.rs +++ b/examples/scene/main.rs @@ -132,7 +132,7 @@ struct Example { need_picked_selection_frames: usize, gizmo_mode: egui_gizmo::GizmoMode, have_objects_changed: bool, - have_fallback_scene: bool, + scene_revision: usize, camera: blade_render::Camera, fly_speed: f32, debug: blade_render::DebugConfig, @@ -230,7 +230,7 @@ impl Example { need_picked_selection_frames: 0, gizmo_mode: egui_gizmo::GizmoMode::Translate, have_objects_changed: false, - have_fallback_scene: false, + scene_revision: 0, camera: blade_render::Camera { pos: mint::Vector3 { x: 0.0, @@ -440,12 +440,14 @@ impl Example { temp, ); self.have_objects_changed = false; - self.have_fallback_scene = true; + self.scene_revision += 1; } // We should be able to update TLAS and render content // even while it's still being loaded. - if self.scene_load_task.is_none() || (RENDER_WHILE_LOADING && self.have_fallback_scene) { + let do_render = + self.scene_load_task.is_none() || (RENDER_WHILE_LOADING && self.scene_revision != 0); + if do_render { self.renderer.prepare( command_encoder, &self.camera, @@ -481,7 +483,7 @@ impl Example { physical_size: (physical_size.width, physical_size.height), scale_factor, }; - if self.scene_load_task.is_none() { + if do_render { let mut debug_blit_array = [blade_render::DebugBlit::default()]; let debug_blits = match self.debug_blit { Some(ref blit) => { @@ -1026,6 +1028,7 @@ fn main() { let mut last_mouse_pos = [0i32; 2]; event_loop.run(move |event, _, control_flow| { + example.choir.check_panic(); *control_flow = winit::event_loop::ControlFlow::Poll; let delta = last_event.elapsed().as_secs_f32(); last_event = time::Instant::now(); @@ -1150,13 +1153,13 @@ fn main() { .draw_flags .set(blade_render::DebugDrawFlags::SPACE, false); } - winit::event::WindowEvent::DroppedFile(file_path) => { + winit::event::WindowEvent::DroppedFile(ref file_path) => { example.is_file_hovered = false; example .debug .draw_flags .set(blade_render::DebugDrawFlags::SPACE, false); - if !example.add_object(&file_path) { + if !example.add_object(file_path) { log::warn!( "Unable to drop {}, loading in progress", file_path.display() @@ -1204,7 +1207,7 @@ fn main() { }); //HACK: https://github.com/urholaukkarinen/egui-gizmo/issues/29 - if example.have_objects_changed { + if example.have_objects_changed && egui_ctx.wants_pointer_input() { drag_start = None; }