recenter on show

This commit is contained in:
galister
2024-02-04 02:11:32 +01:00
parent e384e96939
commit b5d970e5fd
8 changed files with 32 additions and 13 deletions

View File

@@ -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) {