recenter on show
This commit is contained in:
@@ -97,7 +97,7 @@ where
|
||||
self.overlays.values_mut()
|
||||
}
|
||||
|
||||
pub fn show_hide(&mut self) {
|
||||
pub fn show_hide(&mut self, app: &mut AppState) {
|
||||
let any_shown = self
|
||||
.overlays
|
||||
.values()
|
||||
@@ -106,6 +106,9 @@ where
|
||||
self.overlays.values_mut().for_each(|o| {
|
||||
if o.state.show_hide {
|
||||
o.state.want_visible = !any_shown;
|
||||
if o.state.want_visible && app.session.recenter_on_show {
|
||||
o.state.reset(app, false);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -421,7 +421,6 @@ impl Pointer {
|
||||
grab_data.offset.z -= self.now.scroll * 0.05;
|
||||
}
|
||||
_ => {
|
||||
log::warn!("scale: {}", self.now.scroll);
|
||||
overlay.state.transform.matrix3 = overlay
|
||||
.state
|
||||
.transform
|
||||
@@ -433,7 +432,9 @@ impl Pointer {
|
||||
overlay.state.realign(hmd);
|
||||
overlay.state.dirty = true;
|
||||
} else {
|
||||
overlay.state.spawn_point = overlay.state.transform.translation.into();
|
||||
overlay.state.spawn_point = hmd
|
||||
.inverse()
|
||||
.transform_point3a(overlay.state.transform.translation);
|
||||
self.interaction.grabbed = None;
|
||||
log::info!("Hand {}: dropped {}", self.idx, overlay.state.name);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
.iter()
|
||||
.any(|p| p.now.show_hide && !p.before.show_hide)
|
||||
{
|
||||
overlays.show_hide();
|
||||
overlays.show_hide(&mut state);
|
||||
}
|
||||
|
||||
overlays
|
||||
|
||||
@@ -200,7 +200,7 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
.any(|p| p.now.show_hide && !p.before.show_hide)
|
||||
{
|
||||
if show_hide_counter.click() {
|
||||
overlays.show_hide();
|
||||
overlays.show_hide(&mut app_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,15 +103,20 @@ impl OverlayState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self, app: &mut AppState) {
|
||||
pub fn reset(&mut self, app: &mut AppState, reset_scale: bool) {
|
||||
let translation = app.input_state.hmd.transform_point3a(self.spawn_point);
|
||||
let scale = if reset_scale {
|
||||
self.spawn_scale
|
||||
} else {
|
||||
self.transform.x_axis.length()
|
||||
};
|
||||
self.transform = Affine3A::from_scale_rotation_translation(
|
||||
Vec3::ONE * self.spawn_scale,
|
||||
Vec3::ONE * scale,
|
||||
Quat::IDENTITY,
|
||||
translation.into(),
|
||||
);
|
||||
|
||||
self.realign(&app.input_state.hmd);
|
||||
self.dirty = true;
|
||||
}
|
||||
|
||||
pub fn realign(&mut self, hmd: &Affine3A) {
|
||||
@@ -160,7 +165,7 @@ where
|
||||
T: Default,
|
||||
{
|
||||
pub fn init(&mut self, app: &mut AppState) {
|
||||
self.state.reset(app);
|
||||
self.state.reset(app, true);
|
||||
self.backend.init(app);
|
||||
}
|
||||
pub fn render(&mut self, app: &mut AppState) {
|
||||
|
||||
Reference in New Issue
Block a user