Skip to content

Commit

Permalink
hackish pause/unpause to simplify visualizing everything that goes on…
Browse files Browse the repository at this point in the history
… in there
  • Loading branch information
teh-cmc committed Mar 9, 2023
1 parent 7ec31a2 commit c643bcf
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions crates/re_renderer/examples/outlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use re_renderer::{
renderer::{MeshInstance, OutlineConfig},
view_builder::{Projection, TargetConfiguration, ViewBuilder},
};
use winit::event::{ElementState, VirtualKeyCode};

mod framework;

struct Outlines {
is_paused: bool,
seconds_since_startup: f32,
model_mesh_instances: Vec<MeshInstance>,
}

Expand All @@ -23,6 +26,8 @@ impl framework::Example for Outlines {

fn new(re_ctx: &mut re_renderer::RenderContext) -> Self {
Outlines {
is_paused: false,
seconds_since_startup: 0.0,
model_mesh_instances: crate::framework::load_rerun_mesh(re_ctx),
}
}
Expand All @@ -31,12 +36,15 @@ impl framework::Example for Outlines {
&mut self,
re_ctx: &mut re_renderer::RenderContext,
resolution: [u32; 2],
time: &framework::Time,
_time: &framework::Time,
pixels_from_point: f32,
) -> Vec<framework::ViewDrawResult> {
let mut view_builder = ViewBuilder::default();

let seconds_since_startup = time.seconds_since_startup();
if !self.is_paused {
self.seconds_since_startup += 0.3 / 1000.0;
}
let seconds_since_startup = self.seconds_since_startup;
// TODO(#1426): unify camera logic between examples.
// let camera_position = glam::vec3(
// (seconds_since_startup * 0.5).sin() * 10.0,
Expand Down Expand Up @@ -135,7 +143,15 @@ impl framework::Example for Outlines {
}]
}

fn on_keyboard_input(&mut self, _input: winit::event::KeyboardInput) {}
fn on_keyboard_input(&mut self, input: winit::event::KeyboardInput) {
#[allow(clippy::single_match)]
match (input.state, input.virtual_keycode) {
(ElementState::Pressed, Some(VirtualKeyCode::Space)) => {
self.is_paused ^= true;
}
_ => {}
}
}
}

fn main() {
Expand Down

0 comments on commit c643bcf

Please sign in to comment.