laser colors, improve scaling (wip)
This commit is contained in:
@@ -21,6 +21,7 @@ static AUTO_INCREMENT: AtomicUsize = AtomicUsize::new(1);
|
||||
pub(super) struct LinePool {
|
||||
lines: IdMap<usize, OverlayData<OpenVrOverlayData>>,
|
||||
view: Arc<ImageView>,
|
||||
colors: [Vec4; 4],
|
||||
}
|
||||
|
||||
impl LinePool {
|
||||
@@ -46,6 +47,12 @@ impl LinePool {
|
||||
LinePool {
|
||||
lines: IdMap::new(),
|
||||
view,
|
||||
colors: [
|
||||
Vec4::new(1., 1., 1., 1.),
|
||||
Vec4::new(0., 0.375, 0.5, 1.),
|
||||
Vec4::new(0.69, 0.188, 0., 1.),
|
||||
Vec4::new(0.375, 0., 0.5, 1.),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +63,7 @@ impl LinePool {
|
||||
state: OverlayState {
|
||||
name: Arc::from(format!("wlx-line{}", id)),
|
||||
show_hide: true,
|
||||
width: 0.002,
|
||||
spawn_scale: 0.002,
|
||||
size: (0, 0),
|
||||
..Default::default()
|
||||
},
|
||||
@@ -77,13 +84,15 @@ impl LinePool {
|
||||
id
|
||||
}
|
||||
|
||||
pub fn draw_from(&mut self, id: usize, mut from: Affine3A, len: f32, color: Vec4) {
|
||||
pub fn draw_from(&mut self, id: usize, mut from: Affine3A, len: f32, color: usize) {
|
||||
let rotation = Affine3A::from_axis_angle(Vec3::X, -PI * 0.5);
|
||||
|
||||
from.translation = from.translation + from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
|
||||
let transform = from * rotation * Affine3A::from_scale(Vec3::new(1., len / 0.002, 1.));
|
||||
|
||||
self.draw_transform(id, transform, color);
|
||||
debug_assert!(color < self.colors.len());
|
||||
|
||||
self.draw_transform(id, transform, self.colors[color]);
|
||||
}
|
||||
|
||||
fn draw_transform(&mut self, id: usize, transform: Affine3A, color: Vec4) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use glam::Vec4;
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
sync::{
|
||||
@@ -143,13 +142,17 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
input_source.update(&mut input_mngr, &mut system_mngr, &mut state);
|
||||
state.input_state.post_update();
|
||||
|
||||
overlays
|
||||
.iter_mut()
|
||||
.for_each(|o| o.state.auto_movement(&mut state));
|
||||
|
||||
let pointer_lengths = interact(&mut overlays, &mut state);
|
||||
for (idx, len) in pointer_lengths.iter().enumerate() {
|
||||
lines.draw_from(
|
||||
pointer_lines[idx],
|
||||
state.input_state.pointers[idx].pose,
|
||||
*len,
|
||||
Vec4::ONE,
|
||||
state.input_state.pointers[idx].interaction.mode as usize + 1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ use crate::{
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
const WIDTH: f32 = 1.0;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct OpenVrOverlayData {
|
||||
handle: Option<OverlayHandle>,
|
||||
@@ -118,12 +120,12 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn upload_width(&self, overlay: &mut OverlayManager) {
|
||||
fn upload_width(&self, overlay: &mut OverlayManager) {
|
||||
let Some(handle) = self.data.handle else {
|
||||
log::debug!("{}: No overlay handle", self.state.name);
|
||||
return;
|
||||
};
|
||||
if let Err(e) = overlay.set_width(handle, self.state.width) {
|
||||
if let Err(e) = overlay.set_width(handle, WIDTH) {
|
||||
panic!("Failed to set overlay width: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user