Check for draw order
This commit is contained in:
parent
d989cdaa86
commit
188420c4ce
2 changed files with 31 additions and 55 deletions
|
@ -62,6 +62,7 @@ struct LaserSettings {
|
||||||
latency_points: u32,
|
latency_points: u32,
|
||||||
frame_hz: u32,
|
frame_hz: u32,
|
||||||
enable_optimisations: bool,
|
enable_optimisations: bool,
|
||||||
|
enable_draw_reorder: bool,
|
||||||
distance_per_point: f32,
|
distance_per_point: f32,
|
||||||
blank_delay_points: u32,
|
blank_delay_points: u32,
|
||||||
radians_per_point: f32,
|
radians_per_point: f32,
|
||||||
|
@ -81,6 +82,7 @@ impl Default for LaserSettings {
|
||||||
) * 4,
|
) * 4,
|
||||||
frame_hz: 35, //stream::DEFAULT_FRAME_HZ,
|
frame_hz: 35, //stream::DEFAULT_FRAME_HZ,
|
||||||
enable_optimisations: true,
|
enable_optimisations: true,
|
||||||
|
enable_draw_reorder: true,
|
||||||
distance_per_point: InterpolationConfig::DEFAULT_DISTANCE_PER_POINT,
|
distance_per_point: InterpolationConfig::DEFAULT_DISTANCE_PER_POINT,
|
||||||
blank_delay_points: InterpolationConfig::DEFAULT_BLANK_DELAY_POINTS,
|
blank_delay_points: InterpolationConfig::DEFAULT_BLANK_DELAY_POINTS,
|
||||||
radians_per_point: InterpolationConfig::DEFAULT_RADIANS_PER_POINT,
|
radians_per_point: InterpolationConfig::DEFAULT_RADIANS_PER_POINT,
|
||||||
|
@ -158,9 +160,9 @@ fn zmq_receive(model: &mut GuiModel) {
|
||||||
for (_dac, stream_config) in (&model.laser_streams).into_iter() {
|
for (_dac, stream_config) in (&model.laser_streams).into_iter() {
|
||||||
// let lines = get_laser_lines(version);
|
// let lines = get_laser_lines(version);
|
||||||
let lines_for_laser: RenderableLines = lines.clone();
|
let lines_for_laser: RenderableLines = lines.clone();
|
||||||
let sending = stream_config.stream.send(move |laser| {
|
let sending = stream_config.stream.send(move |laser_model: &mut LaserModel| {
|
||||||
let laser_lines: RenderableLines = lines_for_laser;
|
let laser_lines: RenderableLines = lines_for_laser;
|
||||||
laser.current_lines = laser_lines;
|
laser_model.current_lines = laser_lines;
|
||||||
});
|
});
|
||||||
if let Err(e) = sending {
|
if let Err(e) = sending {
|
||||||
println!("Error sending to laser! {e:?}");
|
println!("Error sending to laser! {e:?}");
|
||||||
|
@ -391,6 +393,7 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
.detected_dac(dac.clone())
|
.detected_dac(dac.clone())
|
||||||
.build()
|
.build()
|
||||||
.expect("failed to establish stream with newly detected DAC");
|
.expect("failed to establish stream with newly detected DAC");
|
||||||
|
// dbg!(stream.enable_draw_reorder());
|
||||||
model.laser_streams.insert(dac.id(), StreamConfig{ stream, config: config.clone() });
|
model.laser_streams.insert(dac.id(), StreamConfig{ stream, config: config.clone() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +435,10 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
.build()
|
.build()
|
||||||
{
|
{
|
||||||
Err(err) => eprintln!("failed to restart stream: {}", err),
|
Err(err) => eprintln!("failed to restart stream: {}", err),
|
||||||
Ok(stream) => {model.laser_streams.insert(dac_id, StreamConfig{stream, config: stream_config.config});},
|
Ok(stream) => {
|
||||||
|
println!("Reinsert stream. {:?}", dac_id);
|
||||||
|
model.laser_streams.insert(dac_id, StreamConfig{stream, config: stream_config.config});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,8 +523,23 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add_enabled(laser_settings.enable_optimisations,
|
||||||
|
egui::Checkbox::new(&mut laser_settings.enable_draw_reorder,"Reorder paths")
|
||||||
|
)
|
||||||
|
// .checkbox(&mut laser_settings.enable_draw_reorder, "Reorder paths")
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
for (_dac_id, stream_config) in laser_streams.iter() {
|
||||||
|
stream_config.stream
|
||||||
|
.enable_draw_reorder(laser_settings.enable_draw_reorder)
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ui
|
||||||
|
.add_enabled(laser_settings.enable_optimisations,
|
||||||
egui::Slider::new(&mut laser_settings.distance_per_point, 0.01..=1.0)
|
egui::Slider::new(&mut laser_settings.distance_per_point, 0.01..=1.0)
|
||||||
.text("Distance Per Point"),
|
.text("Distance Per Point"),
|
||||||
)
|
)
|
||||||
|
@ -530,7 +551,7 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add_enabled(laser_settings.enable_optimisations,
|
||||||
egui::Slider::new(&mut laser_settings.blank_delay_points, 0..=32)
|
egui::Slider::new(&mut laser_settings.blank_delay_points, 0..=32)
|
||||||
.text("Blank Delay (Points)"),
|
.text("Blank Delay (Points)"),
|
||||||
)
|
)
|
||||||
|
@ -543,7 +564,9 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
}
|
}
|
||||||
let mut degrees = rad_to_deg(laser_settings.radians_per_point);
|
let mut degrees = rad_to_deg(laser_settings.radians_per_point);
|
||||||
if ui
|
if ui
|
||||||
.add(egui::Slider::new(&mut degrees, 1.0..=180.0).text("Degrees Per Point"))
|
.add_enabled(laser_settings.enable_optimisations,
|
||||||
|
egui::Slider::new(&mut degrees, 1.0..=180.0).text("Degrees Per Point")
|
||||||
|
)
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
let radians = deg_to_rad(degrees);
|
let radians = deg_to_rad(degrees);
|
||||||
|
@ -631,53 +654,6 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ui.heading("Connected DACs");
|
|
||||||
|
|
||||||
// if laser_streams.is_empty() {
|
|
||||||
// ui.label("no streams");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (_dac_id, stream_config) in laser_streams.iter_mut() {
|
|
||||||
// let dac: laser::DetectedDac = stream_config.stream
|
|
||||||
// .dac()
|
|
||||||
// .expect("`dac` returned `None` even though one was specified during stream creation");
|
|
||||||
// ui.add(egui::Label::new(format!("{:?}", dac.id())));
|
|
||||||
|
|
||||||
// if ui
|
|
||||||
// // todo : from custom dac config:
|
|
||||||
// .add(egui::Slider::new(&mut stream_config.config.filters.dim.intensity, 0.0..=1.).text("Dimming"))
|
|
||||||
// .changed()
|
|
||||||
// {
|
|
||||||
// for (_dac_id, laser_stream) in laser_streams.iter() {
|
|
||||||
// let factor = model.laser_model.dimming;
|
|
||||||
// // let lines = get_laser_lines(version);
|
|
||||||
// laser_stream.stream.send(move |laser| {
|
|
||||||
// // laser: LaserModel
|
|
||||||
// laser.config.filters.dim.intensity = factor;
|
|
||||||
// // laser.dimming = factor;
|
|
||||||
// }).unwrap();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
//if egui::ComboBox::from_label("Homography")
|
|
||||||
// .selected_text(format!("{radio:?}"))
|
|
||||||
// .show_ui(ui, |ui| {
|
|
||||||
// ui.selectable_value(radio, Enum::First, "First");
|
|
||||||
// ui.selectable_value(radio, Enum::Second, "Second");
|
|
||||||
// ui.selectable_value(radio, Enum::Third, "Third");
|
|
||||||
// })
|
|
||||||
// .changed() {
|
|
||||||
// let sending = laser_stream.send(move |laser| {
|
|
||||||
// let laser_lines: RenderableLines = lines_for_laser;
|
|
||||||
// laser.current_lines = laser_lines;
|
|
||||||
// });
|
|
||||||
// if let Err(e) = sending {
|
|
||||||
// println!("Error sending to laser! {e:?}");
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
} else {
|
} else {
|
||||||
ui.label("Select a DAC");
|
ui.label("Select a DAC");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn apply_homography_matrix(h: Mat3, p: &[f32; 2]) -> [f32; 2]{
|
||||||
pub struct LaserModel{
|
pub struct LaserModel{
|
||||||
pub t: Instant, // register start time, so that animations can be moving
|
pub t: Instant, // register start time, so that animations can be moving
|
||||||
pub current_lines: RenderableLines,
|
pub current_lines: RenderableLines,
|
||||||
pub dimming: f32,
|
// pub dimming: f32,
|
||||||
pub config: DacConfig, // per dac configuration
|
pub config: DacConfig, // per dac configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ impl LaserModel{
|
||||||
Self{
|
Self{
|
||||||
t: Instant::now(),
|
t: Instant::now(),
|
||||||
current_lines: RenderableLines::new(),
|
current_lines: RenderableLines::new(),
|
||||||
dimming: 0.3,
|
// dimming: 0.3,
|
||||||
config: DacConfig::default(),
|
config: DacConfig::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue