mirror of https://github.com/wayvr-org/wayvr.git
space gravity: floor level
This commit is contained in:
parent
51f3126cae
commit
7e2033edd7
|
|
@ -115,6 +115,8 @@
|
||||||
"SPACE_GRAVITY_GRAVITY_HELP": "Amount of downwards force. 0.0 - no gravity",
|
"SPACE_GRAVITY_GRAVITY_HELP": "Amount of downwards force. 0.0 - no gravity",
|
||||||
"SPACE_GRAVITY_GROUND_FRICTION": "Ground friction",
|
"SPACE_GRAVITY_GROUND_FRICTION": "Ground friction",
|
||||||
"SPACE_GRAVITY_GROUND_FRICTION_HELP": "Amount of friction slowing you down if you're touching the ground.\n0.0 - no friction (just like on ice), 1.0 - rough surface",
|
"SPACE_GRAVITY_GROUND_FRICTION_HELP": "Amount of friction slowing you down if you're touching the ground.\n0.0 - no friction (just like on ice), 1.0 - rough surface",
|
||||||
|
"SPACE_GRAVITY_FLOOR_HEIGHT": "Floor height",
|
||||||
|
"SPACE_GRAVITY_FLOOR_HEIGHT_HELP": "The Y position where the floor is. Gravity stops when you reach this height.",
|
||||||
"SPACE_ROTATE_UNLOCKED": "Allow space rotate on all axes",
|
"SPACE_ROTATE_UNLOCKED": "Allow space rotate on all axes",
|
||||||
"TROUBLESHOOTING": "Troubleshooting",
|
"TROUBLESHOOTING": "Troubleshooting",
|
||||||
"UI_GRADIENT_INTENSITY": "UI Gradient intensity",
|
"UI_GRADIENT_INTENSITY": "UI Gradient intensity",
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,7 @@ enum SettingType {
|
||||||
SpaceGravityFlingStrength,
|
SpaceGravityFlingStrength,
|
||||||
SpaceGravityGravity,
|
SpaceGravityGravity,
|
||||||
SpaceGravityGroundFriction,
|
SpaceGravityGroundFriction,
|
||||||
|
SpaceGravityFloorHeight,
|
||||||
SpaceRotateUnlocked,
|
SpaceRotateUnlocked,
|
||||||
UiAnimationSpeed,
|
UiAnimationSpeed,
|
||||||
UiGradientIntensity,
|
UiGradientIntensity,
|
||||||
|
|
@ -369,6 +370,7 @@ impl SettingType {
|
||||||
Self::SpaceGravityFlingStrength => &mut config.space_gravity_fling_strength,
|
Self::SpaceGravityFlingStrength => &mut config.space_gravity_fling_strength,
|
||||||
Self::SpaceGravityGravity => &mut config.space_gravity_gravity,
|
Self::SpaceGravityGravity => &mut config.space_gravity_gravity,
|
||||||
Self::SpaceGravityGroundFriction => &mut config.space_gravity_ground_friction,
|
Self::SpaceGravityGroundFriction => &mut config.space_gravity_ground_friction,
|
||||||
|
Self::SpaceGravityFloorHeight => &mut config.space_gravity_floor_height,
|
||||||
Self::UiAnimationSpeed => &mut config.ui_animation_speed,
|
Self::UiAnimationSpeed => &mut config.ui_animation_speed,
|
||||||
Self::UiGradientIntensity => &mut config.ui_gradient_intensity,
|
Self::UiGradientIntensity => &mut config.ui_gradient_intensity,
|
||||||
Self::UiRoundMultiplier => &mut config.ui_round_multiplier,
|
Self::UiRoundMultiplier => &mut config.ui_round_multiplier,
|
||||||
|
|
@ -475,6 +477,7 @@ impl SettingType {
|
||||||
Self::SpaceGravityFlingStrength => Ok("APP_SETTINGS.SPACE_GRAVITY_FLING_STRENGTH"),
|
Self::SpaceGravityFlingStrength => Ok("APP_SETTINGS.SPACE_GRAVITY_FLING_STRENGTH"),
|
||||||
Self::SpaceGravityGravity => Ok("APP_SETTINGS.SPACE_GRAVITY_GRAVITY"),
|
Self::SpaceGravityGravity => Ok("APP_SETTINGS.SPACE_GRAVITY_GRAVITY"),
|
||||||
Self::SpaceGravityGroundFriction => Ok("APP_SETTINGS.SPACE_GRAVITY_GROUND_FRICTION"),
|
Self::SpaceGravityGroundFriction => Ok("APP_SETTINGS.SPACE_GRAVITY_GROUND_FRICTION"),
|
||||||
|
Self::SpaceGravityFloorHeight => Ok("APP_SETTINGS.SPACE_GRAVITY_FLOOR_HEIGHT"),
|
||||||
Self::SpaceRotateUnlocked => Ok("APP_SETTINGS.SPACE_ROTATE_UNLOCKED"),
|
Self::SpaceRotateUnlocked => Ok("APP_SETTINGS.SPACE_ROTATE_UNLOCKED"),
|
||||||
Self::UiAnimationSpeed => Ok("APP_SETTINGS.ANIMATION_SPEED"),
|
Self::UiAnimationSpeed => Ok("APP_SETTINGS.ANIMATION_SPEED"),
|
||||||
Self::UiGradientIntensity => Ok("APP_SETTINGS.UI_GRADIENT_INTENSITY"),
|
Self::UiGradientIntensity => Ok("APP_SETTINGS.UI_GRADIENT_INTENSITY"),
|
||||||
|
|
@ -505,6 +508,7 @@ impl SettingType {
|
||||||
Self::ScreenRenderDown => Some("APP_SETTINGS.SCREEN_RENDER_DOWN_HELP"),
|
Self::ScreenRenderDown => Some("APP_SETTINGS.SCREEN_RENDER_DOWN_HELP"),
|
||||||
Self::SpaceGravityDamping => Some("APP_SETTINGS.SPACE_GRAVITY_DAMPING_HELP"),
|
Self::SpaceGravityDamping => Some("APP_SETTINGS.SPACE_GRAVITY_DAMPING_HELP"),
|
||||||
Self::SpaceGravityFlingStrength => Some("APP_SETTINGS.SPACE_GRAVITY_FLING_STRENGTH_HELP"),
|
Self::SpaceGravityFlingStrength => Some("APP_SETTINGS.SPACE_GRAVITY_FLING_STRENGTH_HELP"),
|
||||||
|
Self::SpaceGravityFloorHeight => Some("APP_SETTINGS.SPACE_GRAVITY_FLOOR_HEIGHT_HELP"),
|
||||||
Self::SpaceGravityGravity => Some("APP_SETTINGS.SPACE_GRAVITY_GRAVITY_HELP"),
|
Self::SpaceGravityGravity => Some("APP_SETTINGS.SPACE_GRAVITY_GRAVITY_HELP"),
|
||||||
Self::SpaceGravityGroundFriction => Some("APP_SETTINGS.SPACE_GRAVITY_GROUND_FRICTION_HELP"),
|
Self::SpaceGravityGroundFriction => Some("APP_SETTINGS.SPACE_GRAVITY_GROUND_FRICTION_HELP"),
|
||||||
Self::UprightScreenFix => Some("APP_SETTINGS.UPRIGHT_SCREEN_FIX_HELP"),
|
Self::UprightScreenFix => Some("APP_SETTINGS.UPRIGHT_SCREEN_FIX_HELP"),
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,14 @@ impl State {
|
||||||
1.0,
|
1.0,
|
||||||
0.01,
|
0.01,
|
||||||
)?;
|
)?;
|
||||||
|
options_slider_f32(
|
||||||
|
par.mp,
|
||||||
|
id_space_gravity_parent,
|
||||||
|
SettingType::SpaceGravityFloorHeight,
|
||||||
|
-5.0,
|
||||||
|
5.0,
|
||||||
|
0.1,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if par.feats.monado {
|
if par.feats.monado {
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,7 @@ impl PlayspaceMover {
|
||||||
dt: app.delta_time,
|
dt: app.delta_time,
|
||||||
dragging: self.drag.is_some(),
|
dragging: self.drag.is_some(),
|
||||||
config: &app.session.config,
|
config: &app.session.config,
|
||||||
|
floor_height: app.session.config.space_gravity_floor_height,
|
||||||
}) {
|
}) {
|
||||||
apply_offset(
|
apply_offset(
|
||||||
Affine3A::from_translation(res.playspace_pos.into()),
|
Affine3A::from_translation(res.playspace_pos.into()),
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ pub struct SpaceGravityUpdateParams<'a> {
|
||||||
pub dt: f32,
|
pub dt: f32,
|
||||||
pub dragging: bool,
|
pub dragging: bool,
|
||||||
pub config: &'a GeneralConfig,
|
pub config: &'a GeneralConfig,
|
||||||
|
pub floor_height: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SpaceGravity {
|
pub struct SpaceGravity {
|
||||||
|
|
@ -78,10 +79,10 @@ impl SpaceGravity {
|
||||||
|
|
||||||
self.space_pos += self.velocity * par.dt;
|
self.space_pos += self.velocity * par.dt;
|
||||||
|
|
||||||
self.space_pos.y = self.space_pos.y.min(0.0);
|
self.space_pos.y = self.space_pos.y.min(par.floor_height);
|
||||||
|
|
||||||
if self.space_pos.y >= 0.0
|
if self.space_pos.y >= par.floor_height
|
||||||
/* at zero or below ground level */
|
/* at floor height or below */
|
||||||
{
|
{
|
||||||
// apply ground friction
|
// apply ground friction
|
||||||
self.velocity *= 1.0 - par.config.space_gravity_ground_friction * par.dt * 10.0;
|
self.velocity *= 1.0 - par.config.space_gravity_ground_friction * par.dt * 10.0;
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@ pub struct AutoSettings {
|
||||||
pub space_gravity_fling_strength: f32,
|
pub space_gravity_fling_strength: f32,
|
||||||
pub space_gravity_gravity: f32,
|
pub space_gravity_gravity: f32,
|
||||||
pub space_gravity_ground_friction: f32,
|
pub space_gravity_ground_friction: f32,
|
||||||
|
pub space_gravity_floor_height: f32,
|
||||||
pub space_rotate_unlocked: bool,
|
pub space_rotate_unlocked: bool,
|
||||||
pub clock_12h: bool,
|
pub clock_12h: bool,
|
||||||
pub hide_username: bool,
|
pub hide_username: bool,
|
||||||
|
|
@ -230,6 +231,7 @@ pub fn save_settings(config: &GeneralConfig) -> anyhow::Result<()> {
|
||||||
space_gravity_fling_strength: config.space_gravity_fling_strength,
|
space_gravity_fling_strength: config.space_gravity_fling_strength,
|
||||||
space_gravity_gravity: config.space_gravity_gravity,
|
space_gravity_gravity: config.space_gravity_gravity,
|
||||||
space_gravity_ground_friction: config.space_gravity_ground_friction,
|
space_gravity_ground_friction: config.space_gravity_ground_friction,
|
||||||
|
space_gravity_floor_height: config.space_gravity_floor_height,
|
||||||
space_rotate_unlocked: config.space_rotate_unlocked,
|
space_rotate_unlocked: config.space_rotate_unlocked,
|
||||||
clock_12h: config.clock_12h,
|
clock_12h: config.clock_12h,
|
||||||
hide_username: config.hide_username,
|
hide_username: config.hide_username,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ use wgui::{
|
||||||
self, CustomAttribsInfoOwned, Fetchable, ParseDocumentExtra, ParserState, parse_color_hex,
|
self, CustomAttribsInfoOwned, Fetchable, ParseDocumentExtra, ParserState, parse_color_hex,
|
||||||
},
|
},
|
||||||
renderer_vk::{context::Context as WguiContext, text::custom_glyph::CustomGlyphData},
|
renderer_vk::{context::Context as WguiContext, text::custom_glyph::CustomGlyphData},
|
||||||
taffy,
|
|
||||||
widget::{
|
widget::{
|
||||||
EventResult, image::WidgetImage, label::WidgetLabel, rectangle::WidgetRectangle,
|
EventResult, image::WidgetImage, label::WidgetLabel, rectangle::WidgetRectangle,
|
||||||
sprite::WidgetSprite,
|
sprite::WidgetSprite,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
use glam::{Affine3A, Quat, Vec3};
|
use glam::{Affine3A, Quat, Vec3};
|
||||||
use std::sync::{Arc, LazyLock};
|
use std::sync::{Arc, LazyLock};
|
||||||
use wgui::event::{EventAlterables, StyleSetRequest};
|
use wgui::event::EventAlterables;
|
||||||
use wgui::parser::Fetchable;
|
use wgui::parser::Fetchable;
|
||||||
use wgui::taffy;
|
|
||||||
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||||
|
|
||||||
use crate::gui::panel::GuiPanel;
|
use crate::gui::panel::GuiPanel;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use wgui::{event::StyleSetRequest, parser::Fetchable, taffy};
|
use wgui::parser::Fetchable;
|
||||||
use wlx_common::{common::LeftRight, windowing::Positioning};
|
use wlx_common::{common::LeftRight, windowing::Positioning};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ use glam::{Affine3A, Quat, Vec3, vec3};
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::button::ComponentButton,
|
components::button::ComponentButton,
|
||||||
event::StyleSetRequest,
|
|
||||||
parser::{Fetchable, ParseDocumentParams},
|
parser::{Fetchable, ParseDocumentParams},
|
||||||
taffy,
|
|
||||||
};
|
};
|
||||||
use wlx_common::{
|
use wlx_common::{
|
||||||
common::LeftRight,
|
common::LeftRight,
|
||||||
|
|
|
||||||
|
|
@ -118,13 +118,19 @@
|
||||||
#space_rotate_unlocked: false
|
#space_rotate_unlocked: false
|
||||||
|
|
||||||
## Space gravity: downward acceleration speed
|
## Space gravity: downward acceleration speed
|
||||||
#space_drag_gravity: 2.0
|
#space_gravity_gravity: 2.0
|
||||||
|
|
||||||
## Space gravity: velocity damping (0.98 = gentle slowdown, 0.5 = heavy drag)
|
## Space gravity: velocity damping (0.98 = gentle slowdown, 0.5 = heavy drag)
|
||||||
#space_drag_damping: 0.98
|
#space_gravity_damping: 0.98
|
||||||
|
|
||||||
## Space gravity: multiplier for "throwing" yourself via space drag momentum
|
## Space gravity: multiplier for "throwing" yourself via space drag momentum
|
||||||
#space_drag_fling_strength: 1.0
|
#space_gravity_fling_strength: 1.0
|
||||||
|
|
||||||
|
## Space gravity: floor height (Y position where gravity stops)
|
||||||
|
#space_gravity_floor_height: 0.0
|
||||||
|
|
||||||
|
## Space gravity: ground friction when touching the floor
|
||||||
|
#space_gravity_ground_friction: 1.0
|
||||||
|
|
||||||
## Monado/WiVRn only. Use passthrough camera if the headset supports it.
|
## Monado/WiVRn only. Use passthrough camera if the headset supports it.
|
||||||
## If disabled, the skybox will be shown.
|
## If disabled, the skybox will be shown.
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,10 @@ const fn def_point3() -> f32 {
|
||||||
0.3
|
0.3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn def_zero() -> f32 {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
|
||||||
const fn def_osc_port() -> u16 {
|
const fn def_osc_port() -> u16 {
|
||||||
9000
|
9000
|
||||||
}
|
}
|
||||||
|
|
@ -351,6 +355,9 @@ pub struct GeneralConfig {
|
||||||
#[serde(default = "def_one")]
|
#[serde(default = "def_one")]
|
||||||
pub space_gravity_ground_friction: f32,
|
pub space_gravity_ground_friction: f32,
|
||||||
|
|
||||||
|
#[serde(default = "def_zero")]
|
||||||
|
pub space_gravity_floor_height: f32,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub alt_click_down: Vec<String>,
|
pub alt_click_down: Vec<String>,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue