From ab32e71854c2207602b12496feae767323e43a49 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 7 Nov 2023 22:14:41 -0800 Subject: [PATCH 1/2] Improve the grabbing hack --- examples/scene/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/scene/main.rs b/examples/scene/main.rs index e3ec764c..f2dbfdec 100644 --- a/examples/scene/main.rs +++ b/examples/scene/main.rs @@ -1150,13 +1150,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 +1204,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; } From 060bc9d8765852b354c4a223e2e281f76084af9e Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 10 Nov 2023 00:14:21 -0800 Subject: [PATCH 2/2] Assorted fixes: panic detection, gltf texture paths, example plane --- Cargo.toml | 2 +- blade-render/src/model/mod.rs | 12 ++++++++---- examples/scene/data/plane.glb | Bin 0 -> 1300 bytes examples/scene/data/scene.ron | 2 +- examples/scene/main.rs | 13 ++++++++----- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 examples/scene/data/plane.glb 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 0000000000000000000000000000000000000000..c9d3f391d482891ca986817206f92de3f8846ff1 GIT binary patch literal 1300 zcmb7E?QWYe6lLx9277?WzbP{xX#;Ny(!}vN2Clw+^K_v<*lu||okzAkveOn36 zc+p7#(z(qkOQ`4!KZTvGYk5`|BNJ_@C^F6<*|9L%nW%`N019xkDp0Vf5F=~wp_z`E zi1CD~0Djs%9jpqiX|dAKCjTKPP)k)JIp7zzXF0BG-{3CxUAO1n_~xrznr2NT6&cCv z9VNVsayrWrnxH_6lEOafO^%y93u7C&H<1`qN%B04r@Ty8j22L#LJ=wGfahG?lUS>@ zz*Z0I%eH+7`;KqE#$$s5>xQ5$1>%X8YwxqVJEfM=NQ<{uwN+^&vUMi2Z4)I@iYzLn zGAr~D&W7`0IMMRX@4gShaQfv3MuBajNjM$%M<{S$d>Ko!SV3H%YLo!XPD@B)2o+q^ z5=P~6NyTGEf9j$!UvD_0OwOM-Fs!caT$?E7C4*z-sbas>1Wjz}jx#tiiz{VbDO+j` zdb}IBaEL(NquQ{;|I|L9oinua2J|^MsBq4$ow_gRu;HE!`lJ37sRh!1Lt~JkHl# literal 0 HcmV?d00001 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 f2dbfdec..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();