fix: anchor at wrong position
This commit is contained in:
@@ -100,9 +100,9 @@ where
|
|||||||
impl OverlayState {
|
impl OverlayState {
|
||||||
pub fn parent_transform(&self, app: &AppState) -> Option<Affine3A> {
|
pub fn parent_transform(&self, app: &AppState) -> Option<Affine3A> {
|
||||||
match self.relative_to {
|
match self.relative_to {
|
||||||
RelativeTo::None => None,
|
|
||||||
RelativeTo::Head => Some(app.input_state.hmd),
|
RelativeTo::Head => Some(app.input_state.hmd),
|
||||||
RelativeTo::Hand(idx) => Some(app.input_state.pointers[idx].pose),
|
RelativeTo::Hand(idx) => Some(app.input_state.pointers[idx].pose),
|
||||||
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,19 +201,21 @@ where
|
|||||||
.arc_get(self.state.name.as_ref())
|
.arc_get(self.state.name.as_ref())
|
||||||
.copied();
|
.copied();
|
||||||
|
|
||||||
let hard_reset;
|
if matches!(self.state.relative_to, RelativeTo::None) {
|
||||||
if let Some(transform) = app
|
let hard_reset;
|
||||||
.session
|
if let Some(transform) = app
|
||||||
.config
|
.session
|
||||||
.transform_values
|
.config
|
||||||
.arc_get(self.state.name.as_ref())
|
.transform_values
|
||||||
{
|
.arc_get(self.state.name.as_ref())
|
||||||
self.state.saved_transform = Some(*transform);
|
{
|
||||||
hard_reset = false;
|
self.state.saved_transform = Some(*transform);
|
||||||
} else {
|
hard_reset = false;
|
||||||
hard_reset = true;
|
} else {
|
||||||
|
hard_reset = true;
|
||||||
|
}
|
||||||
|
self.state.reset(app, hard_reset);
|
||||||
}
|
}
|
||||||
self.state.reset(app, hard_reset);
|
|
||||||
self.backend.init(app)
|
self.backend.init(app)
|
||||||
}
|
}
|
||||||
pub fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> {
|
pub fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> {
|
||||||
@@ -267,10 +269,15 @@ impl OverlayRenderer for FallbackRenderer {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub enum RelativeTo {
|
pub enum RelativeTo {
|
||||||
|
/// Stays in place unless rencentered
|
||||||
#[default]
|
#[default]
|
||||||
None,
|
None,
|
||||||
|
/// Stays in position relative to HMD
|
||||||
Head,
|
Head,
|
||||||
|
/// Stays in position relative to hand
|
||||||
Hand(usize),
|
Hand(usize),
|
||||||
|
/// Stays in place, no recentering
|
||||||
|
Stage,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SplitOverlayBackend {
|
pub struct SplitOverlayBackend {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use glam::Vec3A;
|
|||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::backend::overlay::{OverlayData, OverlayState};
|
use crate::backend::overlay::{OverlayData, OverlayState, RelativeTo};
|
||||||
use crate::config::{load_known_yaml, ConfigType};
|
use crate::config::{load_known_yaml, ConfigType};
|
||||||
use crate::gui::modular::{modular_canvas, ModularUiConfig};
|
use crate::gui::modular::{modular_canvas, ModularUiConfig};
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
@@ -24,6 +24,7 @@ where
|
|||||||
z_order: 67,
|
z_order: 67,
|
||||||
spawn_scale: config.width,
|
spawn_scale: config.width,
|
||||||
spawn_point: Vec3A::NEG_Z * 0.5,
|
spawn_point: Vec3A::NEG_Z * 0.5,
|
||||||
|
relative_to: RelativeTo::Stage,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
backend: Box::new(modular_canvas(&config.size, &config.elements, state)?),
|
backend: Box::new(modular_canvas(&config.size, &config.elements, state)?),
|
||||||
|
|||||||
Reference in New Issue
Block a user