Skip to content

Commit

Permalink
Improve the stability of the loading sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Nov 4, 2023
1 parent 958ca5c commit 1ef7198
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions examples/scene/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct Example {
need_picked_selection_frames: usize,
gizmo_mode: egui_gizmo::GizmoMode,
have_objects_changed: bool,
have_fallback_scene: bool,
camera: blade_render::Camera,
fly_speed: f32,
debug: blade_render::DebugConfig,
Expand Down Expand Up @@ -228,6 +229,7 @@ impl Example {
need_picked_selection_frames: 0,
gizmo_mode: egui_gizmo::GizmoMode::Translate,
have_objects_changed: false,
have_fallback_scene: false,
camera: blade_render::Camera {
pos: mint::Vector3 {
x: 0.0,
Expand Down Expand Up @@ -428,22 +430,23 @@ impl Example {
}
}

// 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 {
if self.scene_load_task.is_none() && self.have_objects_changed {
assert_eq!(self.objects.len(), self.object_extras.len());
if self.have_objects_changed {
self.renderer.build_scene(
command_encoder,
&self.objects,
self.environment_map,
&self.asset_hub,
&self.context,
temp,
);
self.have_objects_changed = false;
}
self.renderer.build_scene(
command_encoder,
&self.objects,
self.environment_map,
&self.asset_hub,
&self.context,
temp,
);
self.have_objects_changed = false;
self.have_fallback_scene = true;
}

// 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) {
self.renderer.prepare(
command_encoder,
&self.camera,
Expand Down Expand Up @@ -588,7 +591,7 @@ impl Example {
});
ui.add(egui::Slider::new(&mut self.camera.fov_y, 0.5f32..=2.0f32).text("FOV"));
ui.add(
egui::Slider::new(&mut self.fly_speed, 1f32..=10000f32)
egui::Slider::new(&mut self.fly_speed, 1f32..=100000f32)
.text("Fly speed")
.logarithmic(true),
);
Expand Down

0 comments on commit 1ef7198

Please sign in to comment.