mirror of https://github.com/wayvr-org/wayvr.git
space reset & gravity conflict bugfix, add ground friction slider
This commit is contained in:
parent
2f6131f8d0
commit
f6d6ff067f
|
|
@ -108,6 +108,7 @@
|
|||
"SPACE_DRAG_DAMPING": "Damping",
|
||||
"SPACE_DRAG_GRAVITY": "Gravity",
|
||||
"SPACE_DRAG_MULTIPLIER": "Space drag multiplier",
|
||||
"SPACE_DRAG_GROUND_FRICTION": "Ground friction",
|
||||
"SPACE_DRAG_UNLOCKED": "Allow space drag on all axes",
|
||||
"SPACE_ROTATE_UNLOCKED": "Allow space rotate on all axes",
|
||||
"TROUBLESHOOTING": "Troubleshooting",
|
||||
|
|
|
|||
|
|
@ -295,8 +295,8 @@ impl AppList {
|
|||
state: &Rc<RefCell<State>>,
|
||||
parser_state: &mut ParserState,
|
||||
) -> anyhow::Result<()> {
|
||||
// load 4 entries for a single frame at most
|
||||
for _ in 0..4 {
|
||||
// load 30 entries for a single frame at most
|
||||
for _ in 0..30 {
|
||||
if let Some(entry) = self.entries_to_mount.pop_front() {
|
||||
let globals = frontend.layout.state.globals.clone();
|
||||
let button = self.mount_entry(frontend, parser_state, &doc_params(globals.clone()), &entry)?;
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ enum SettingType {
|
|||
SpaceDragDamping,
|
||||
SpaceDragGravity,
|
||||
SpaceDragMultiplier,
|
||||
SpaceDragGroundFriction,
|
||||
SpaceDragUnlocked,
|
||||
SpaceRotateUnlocked,
|
||||
UiAnimationSpeed,
|
||||
|
|
@ -349,6 +350,7 @@ impl SettingType {
|
|||
Self::SpaceDragDamping => &mut config.space_drag_damping,
|
||||
Self::SpaceDragGravity => &mut config.space_drag_gravity,
|
||||
Self::SpaceDragMultiplier => &mut config.space_drag_multiplier,
|
||||
Self::SpaceDragGroundFriction => &mut config.space_drag_ground_friction,
|
||||
Self::PointerLerpFactor => &mut config.pointer_lerp_factor,
|
||||
Self::GridOpacity => &mut config.grid_opacity,
|
||||
Self::WatchViewAngleMax => &mut config.watch_view_angle_max,
|
||||
|
|
@ -449,6 +451,7 @@ impl SettingType {
|
|||
Self::SpaceDragDamping => Ok("APP_SETTINGS.SPACE_DRAG_DAMPING"),
|
||||
Self::SpaceDragGravity => Ok("APP_SETTINGS.SPACE_DRAG_GRAVITY"),
|
||||
Self::SpaceDragMultiplier => Ok("APP_SETTINGS.SPACE_DRAG_MULTIPLIER"),
|
||||
Self::SpaceDragGroundFriction => Ok("APP_SETTINGS.SPACE_DRAG_GROUND_FRICTION"),
|
||||
Self::SpaceDragUnlocked => Ok("APP_SETTINGS.SPACE_DRAG_UNLOCKED"),
|
||||
Self::SpaceRotateUnlocked => Ok("APP_SETTINGS.SPACE_ROTATE_UNLOCKED"),
|
||||
Self::UiAnimationSpeed => Ok("APP_SETTINGS.ANIMATION_SPEED"),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ impl State {
|
|||
options_slider_f32(par.mp, c, SettingType::SpaceDragGravity, 0.0, 10.0, 0.5)?;
|
||||
options_slider_f32(par.mp, c, SettingType::SpaceDragDamping, 0.1, 1.0, 0.01)?;
|
||||
options_slider_f32(par.mp, c, SettingType::SpaceDragFlingStrength, 0.0, 3.0, 0.1)?;
|
||||
options_slider_f32(par.mp, c, SettingType::SpaceDragGroundFriction, 0.0, 1.0, 0.01)?;
|
||||
}
|
||||
if par.feats.monado {
|
||||
// openvr can only ever rotate yaw
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ impl PlayspaceMover {
|
|||
let _ = monado
|
||||
.set_reference_space_offset(ReferenceSpaceType::Stage, pose)
|
||||
.inspect_err(|e| log::warn!("Could not recenter due to libmonado error: {e:?}"));
|
||||
|
||||
self.gravity.reset();
|
||||
}
|
||||
|
||||
pub fn reset_offset(&mut self, monado: &mut Monado) {
|
||||
|
|
@ -260,6 +262,7 @@ impl PlayspaceMover {
|
|||
self.rotate = None;
|
||||
}
|
||||
|
||||
self.gravity.reset();
|
||||
apply_offset(Affine3A::IDENTITY, monado);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ impl SpaceGravity {
|
|||
self.space_pos = space_pos;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.velocity = Vec3A::default();
|
||||
self.space_pos = Vec3A::default();
|
||||
}
|
||||
|
||||
pub fn update(&mut self, par: SpaceGravityUpdateParams) -> Option<SpaceGravityUpdateResult> {
|
||||
if par.dragging {
|
||||
return None;
|
||||
|
|
@ -66,10 +71,18 @@ impl SpaceGravity {
|
|||
self.velocity.y = self.velocity.y.min(200.0);
|
||||
|
||||
self.velocity *= (par.config.space_drag_damping).powf(par.dt * 10.0);
|
||||
|
||||
self.space_pos += self.velocity * par.dt;
|
||||
|
||||
self.space_pos.y = self.space_pos.y.min(0.0);
|
||||
|
||||
if self.space_pos.y >= 0.0
|
||||
/* at zero or below ground level */
|
||||
{
|
||||
// apply ground friction
|
||||
self.velocity *= 1.0 - par.config.space_drag_ground_friction * par.dt * 10.0;
|
||||
}
|
||||
|
||||
if self.velocity.length_squared() > 0.00003 {
|
||||
// Space position changed
|
||||
return Some(SpaceGravityUpdateResult {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ pub struct AutoSettings {
|
|||
pub space_drag_gravity: f32,
|
||||
pub space_drag_damping: f32,
|
||||
pub space_drag_fling_strength: f32,
|
||||
pub space_drag_ground_friction: f32,
|
||||
pub clock_12h: bool,
|
||||
pub hide_username: bool,
|
||||
pub opaque_background: bool,
|
||||
|
|
@ -227,6 +228,7 @@ pub fn save_settings(config: &GeneralConfig) -> anyhow::Result<()> {
|
|||
space_drag_gravity: config.space_drag_gravity,
|
||||
space_drag_damping: config.space_drag_damping,
|
||||
space_drag_fling_strength: config.space_drag_fling_strength,
|
||||
space_drag_ground_friction: config.space_drag_ground_friction,
|
||||
clock_12h: config.clock_12h,
|
||||
hide_username: config.hide_username,
|
||||
opaque_background: config.opaque_background,
|
||||
|
|
|
|||
|
|
@ -165,10 +165,6 @@ const fn def_point3() -> f32 {
|
|||
0.3
|
||||
}
|
||||
|
||||
const fn def_point98() -> f32 {
|
||||
0.98
|
||||
}
|
||||
|
||||
const fn def_osc_port() -> u16 {
|
||||
9000
|
||||
}
|
||||
|
|
@ -343,12 +339,15 @@ pub struct GeneralConfig {
|
|||
#[serde(default = "def_one")]
|
||||
pub space_drag_gravity: f32,
|
||||
|
||||
#[serde(default = "def_point98")]
|
||||
#[serde(default = "def_one")]
|
||||
pub space_drag_damping: f32,
|
||||
|
||||
#[serde(default = "def_one")]
|
||||
pub space_drag_fling_strength: f32,
|
||||
|
||||
#[serde(default = "def_one")]
|
||||
pub space_drag_ground_friction: f32,
|
||||
|
||||
#[serde(default)]
|
||||
pub alt_click_down: Vec<String>,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue