walk edits
This commit is contained in:
parent
d292993c16
commit
59348f8cbe
@ -16,17 +16,13 @@ pub struct StyleModifiers{
|
|||||||
//flying
|
//flying
|
||||||
//jumping is allowed
|
//jumping is allowed
|
||||||
pub jump:Option<JumpSettings>,
|
pub jump:Option<JumpSettings>,
|
||||||
//sliding
|
//standing & walking is allowed
|
||||||
pub static_friction:Planar64,
|
|
||||||
pub kinetic_friction:Planar64,
|
|
||||||
//walking is allowed
|
|
||||||
pub walk:Option<WalkSettings>,
|
pub walk:Option<WalkSettings>,
|
||||||
//laddering is allowed
|
//laddering is allowed
|
||||||
pub ladder:Option<LadderSettings>,
|
pub ladder:Option<LadderSettings>,
|
||||||
//water propulsion
|
//water propulsion
|
||||||
pub swim:Option<PropulsionSettings>,
|
pub swim:Option<PropulsionSettings>,
|
||||||
//maximum slope before sloped surfaces become frictionless
|
//maximum slope before sloped surfaces become frictionless
|
||||||
pub surf_slope:Option<Planar64>,
|
|
||||||
pub gravity:Planar64Vec3,
|
pub gravity:Planar64Vec3,
|
||||||
//hitbox
|
//hitbox
|
||||||
pub hitbox:Hitbox,
|
pub hitbox:Hitbox,
|
||||||
@ -180,20 +176,19 @@ impl StrafeSettings{
|
|||||||
pub fn next_tick(&self,time:Time)->Time{
|
pub fn next_tick(&self,time:Time)->Time{
|
||||||
Time::from_nanos(self.tick_rate.rhs_div_int(self.tick_rate.mul_int(time.nanos())+1))
|
Time::from_nanos(self.tick_rate.rhs_div_int(self.tick_rate.mul_int(time.nanos())+1))
|
||||||
}
|
}
|
||||||
pub const fn allow_strafe(&self,controls:Controls)->bool{
|
pub const fn activates(&self,controls:Controls)->bool{
|
||||||
self.enable.activates(controls)
|
self.enable.activates(controls)
|
||||||
}
|
}
|
||||||
|
pub const fn mask(&self,controls:Controls)->Controls{
|
||||||
|
self.enable.mask(controls)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PropulsionSettings{
|
pub struct PropulsionSettings{
|
||||||
enable:ControlsActivation,
|
|
||||||
magnitude:Planar64,
|
magnitude:Planar64,
|
||||||
}
|
}
|
||||||
impl PropulsionSettings{
|
impl PropulsionSettings{
|
||||||
pub const fn activates(&self,controls:Controls)->bool{
|
|
||||||
self.enable.activates(controls)
|
|
||||||
}
|
|
||||||
pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{
|
pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{
|
||||||
control_dir*self.magnitude
|
control_dir*self.magnitude
|
||||||
}
|
}
|
||||||
@ -226,18 +221,78 @@ pub struct AccelerateSettings{
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WalkSettings{
|
pub struct WalkSettings{
|
||||||
enable:ControlsActivation,
|
|
||||||
accelerate:AccelerateSettings,
|
accelerate:AccelerateSettings,
|
||||||
|
static_friction:Planar64,
|
||||||
|
kinetic_friction:Planar64,
|
||||||
|
//if a surf slope angle does not exist, then everything is slippery and walking is impossible
|
||||||
|
surf_dot:Planar64,//surf_dot<n.dot(up)/n.length()
|
||||||
|
}
|
||||||
|
impl WalkSettings{
|
||||||
|
pub fn get_walk_target_velocity(&self,control_dir:Planar64Vec3,normal:Planar64Vec3)->Planar64Vec3{
|
||||||
|
if control_dir==Planar64Vec3::ZERO{
|
||||||
|
return control_dir;
|
||||||
|
}
|
||||||
|
let n=normal.length();
|
||||||
|
let m=control_dir.length();
|
||||||
|
let d=normal.dot(control_dir)/m;
|
||||||
|
if d<n{
|
||||||
|
let cr=normal.cross(control_dir);
|
||||||
|
if cr==Planar64Vec3::ZERO{
|
||||||
|
Planar64Vec3::ZERO
|
||||||
|
}else{
|
||||||
|
cr.cross(normal)*(self.accelerate.topspeed/(n*(n*n-d*d).sqrt()*m))
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Planar64Vec3::ZERO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_slope_walkable(&self,normal:Planar64Vec3,up:Planar64Vec3)->bool{
|
||||||
|
//normal is not guaranteed to be unit length
|
||||||
|
let ny=normal.dot(up);
|
||||||
|
let h=normal.length();
|
||||||
|
//remember this is a normal vector
|
||||||
|
Planar64::ZERO<ny&&h*self.surf_dot<ny
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LadderSettings{
|
pub struct LadderSettings{
|
||||||
enable:ControlsActivation,
|
|
||||||
accelerate:AccelerateSettings,
|
accelerate:AccelerateSettings,
|
||||||
//how close to pushing directly into/out of the ladder normal
|
//how close to pushing directly into/out of the ladder normal
|
||||||
//does your input need to be to redirect straight up/down the ladder
|
//does your input need to be to redirect straight up/down the ladder
|
||||||
dot:Planar64,
|
dot:Planar64,
|
||||||
}
|
}
|
||||||
|
impl LadderSettings{
|
||||||
|
pub fn get_ladder_target_velocity(&self,mut control_dir:Planar64Vec3,normal:Planar64Vec3)->Planar64Vec3{
|
||||||
|
if control_dir==Planar64Vec3::ZERO{
|
||||||
|
return control_dir;
|
||||||
|
}
|
||||||
|
let n=normal.length();
|
||||||
|
let m=control_dir.length();
|
||||||
|
let mut d=normal.dot(control_dir)/m;
|
||||||
|
if d< -self.dot*n{
|
||||||
|
control_dir=Planar64Vec3::Y*m;
|
||||||
|
d=normal.y();
|
||||||
|
}else if self.dot*n<d{
|
||||||
|
control_dir=Planar64Vec3::NEG_Y*m;
|
||||||
|
d=-normal.y();
|
||||||
|
}
|
||||||
|
//n=d if you are standing on top of a ladder and press E.
|
||||||
|
//two fixes:
|
||||||
|
//- ladder movement is not allowed on walkable surfaces
|
||||||
|
//- fix the underlying issue
|
||||||
|
if d.get().unsigned_abs()<n.get().unsigned_abs(){
|
||||||
|
let cr=normal.cross(control_dir);
|
||||||
|
if cr==Planar64Vec3::ZERO{
|
||||||
|
Planar64Vec3::ZERO
|
||||||
|
}else{
|
||||||
|
cr.cross(normal)*(self.accelerate.topspeed/(n*(n*n-d*d).sqrt()))
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Planar64Vec3::ZERO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum HitboxMesh{
|
pub enum HitboxMesh{
|
||||||
@ -289,19 +344,18 @@ impl StyleModifiers{
|
|||||||
calculation:JumpCalculation::Energy,
|
calculation:JumpCalculation::Energy,
|
||||||
}),
|
}),
|
||||||
gravity:Planar64Vec3::int(0,-80,0),
|
gravity:Planar64Vec3::int(0,-80,0),
|
||||||
static_friction:Planar64::int(2),
|
|
||||||
kinetic_friction:Planar64::int(3),//unrealistic: kinetic friction is typically lower than static
|
|
||||||
mass:Planar64::int(1),
|
mass:Planar64::int(1),
|
||||||
rocket:None,
|
rocket:None,
|
||||||
walk:Some(WalkSettings{
|
walk:Some(WalkSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(16),
|
topspeed:Planar64::int(16),
|
||||||
accel:Planar64::int(80),
|
accel:Planar64::int(80),
|
||||||
},
|
},
|
||||||
|
static_friction:Planar64::int(2),
|
||||||
|
kinetic_friction:Planar64::int(3),//unrealistic: kinetic friction is typically lower than static
|
||||||
|
surf_dot:Planar64::int(3)/4,
|
||||||
}),
|
}),
|
||||||
ladder:Some(LadderSettings{
|
ladder:Some(LadderSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(16),
|
topspeed:Planar64::int(16),
|
||||||
accel:Planar64::int(160),
|
accel:Planar64::int(160),
|
||||||
@ -309,10 +363,8 @@ impl StyleModifiers{
|
|||||||
dot:(Planar64::int(1)/2).sqrt(),
|
dot:(Planar64::int(1)/2).sqrt(),
|
||||||
}),
|
}),
|
||||||
swim:Some(PropulsionSettings{
|
swim:Some(PropulsionSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
magnitude:Planar64::int(12),
|
magnitude:Planar64::int(12),
|
||||||
}),
|
}),
|
||||||
surf_slope:Some(Planar64::raw(7)/8),
|
|
||||||
hitbox:Hitbox::roblox(),
|
hitbox:Hitbox::roblox(),
|
||||||
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
@ -333,19 +385,18 @@ impl StyleModifiers{
|
|||||||
calculation:JumpCalculation::Capped,
|
calculation:JumpCalculation::Capped,
|
||||||
}),
|
}),
|
||||||
gravity:Planar64Vec3::int(0,-100,0),
|
gravity:Planar64Vec3::int(0,-100,0),
|
||||||
static_friction:Planar64::int(2),
|
|
||||||
kinetic_friction:Planar64::int(3),//unrealistic: kinetic friction is typically lower than static
|
|
||||||
mass:Planar64::int(1),
|
mass:Planar64::int(1),
|
||||||
rocket:None,
|
rocket:None,
|
||||||
walk:Some(WalkSettings{
|
walk:Some(WalkSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),
|
topspeed:Planar64::int(18),
|
||||||
accel:Planar64::int(90),
|
accel:Planar64::int(90),
|
||||||
},
|
},
|
||||||
|
static_friction:Planar64::int(2),
|
||||||
|
kinetic_friction:Planar64::int(3),//unrealistic: kinetic friction is typically lower than static
|
||||||
|
surf_dot:Planar64::int(3)/4,// normal.y=0.75
|
||||||
}),
|
}),
|
||||||
ladder:Some(LadderSettings{
|
ladder:Some(LadderSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),
|
topspeed:Planar64::int(18),
|
||||||
accel:Planar64::int(180),
|
accel:Planar64::int(180),
|
||||||
@ -353,10 +404,8 @@ impl StyleModifiers{
|
|||||||
dot:(Planar64::int(1)/2).sqrt(),
|
dot:(Planar64::int(1)/2).sqrt(),
|
||||||
}),
|
}),
|
||||||
swim:Some(PropulsionSettings{
|
swim:Some(PropulsionSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
magnitude:Planar64::int(12),
|
magnitude:Planar64::int(12),
|
||||||
}),
|
}),
|
||||||
surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75
|
|
||||||
hitbox:Hitbox::roblox(),
|
hitbox:Hitbox::roblox(),
|
||||||
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
@ -371,7 +420,6 @@ impl StyleModifiers{
|
|||||||
Self{
|
Self{
|
||||||
strafe:None,
|
strafe:None,
|
||||||
rocket:Some(PropulsionSettings{
|
rocket:Some(PropulsionSettings{
|
||||||
enable:ControlsActivation::full_3d(),
|
|
||||||
magnitude:Planar64::int(200),
|
magnitude:Planar64::int(200),
|
||||||
}),
|
}),
|
||||||
..Self::roblox_bhop()
|
..Self::roblox_bhop()
|
||||||
@ -380,7 +428,7 @@ impl StyleModifiers{
|
|||||||
|
|
||||||
pub fn source_bhop()->Self{
|
pub fn source_bhop()->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_mask:Controls::all(),
|
controls_mask:Controls::all()-Controls::MoveUp-Controls::MoveDown,
|
||||||
controls_mask_state:Controls::all(),
|
controls_mask_state:Controls::all(),
|
||||||
strafe:Some(StrafeSettings{
|
strafe:Some(StrafeSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
enable:ControlsActivation::full_2d(),
|
||||||
@ -393,19 +441,18 @@ impl StyleModifiers{
|
|||||||
calculation:JumpCalculation::Linear,
|
calculation:JumpCalculation::Linear,
|
||||||
}),
|
}),
|
||||||
gravity:Planar64Vec3::int(0,-800,0)*VALVE_SCALE,
|
gravity:Planar64Vec3::int(0,-800,0)*VALVE_SCALE,
|
||||||
static_friction:Planar64::int(2),//?
|
|
||||||
kinetic_friction:Planar64::int(3),//?
|
|
||||||
mass:Planar64::int(1),
|
mass:Planar64::int(1),
|
||||||
rocket:None,
|
rocket:None,
|
||||||
walk:Some(WalkSettings{
|
walk:Some(WalkSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),//?
|
topspeed:Planar64::int(18),//?
|
||||||
accel:Planar64::int(90),//?
|
accel:Planar64::int(90),//?
|
||||||
},
|
},
|
||||||
|
static_friction:Planar64::int(2),//?
|
||||||
|
kinetic_friction:Planar64::int(3),//?
|
||||||
|
surf_dot:Planar64::int(3)/4,// normal.y=0.75
|
||||||
}),
|
}),
|
||||||
ladder:Some(LadderSettings{
|
ladder:Some(LadderSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),//?
|
topspeed:Planar64::int(18),//?
|
||||||
accel:Planar64::int(180),//?
|
accel:Planar64::int(180),//?
|
||||||
@ -413,17 +460,15 @@ impl StyleModifiers{
|
|||||||
dot:(Planar64::int(1)/2).sqrt(),//?
|
dot:(Planar64::int(1)/2).sqrt(),//?
|
||||||
}),
|
}),
|
||||||
swim:Some(PropulsionSettings{
|
swim:Some(PropulsionSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
magnitude:Planar64::int(12),//?
|
magnitude:Planar64::int(12),//?
|
||||||
}),
|
}),
|
||||||
surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75
|
|
||||||
hitbox:Hitbox::source(),
|
hitbox:Hitbox::source(),
|
||||||
camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)*VALVE_SCALE,
|
camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)*VALVE_SCALE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn source_surf()->Self{
|
pub fn source_surf()->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_mask:Controls::all(),
|
controls_mask:Controls::all()-Controls::MoveUp-Controls::MoveDown,
|
||||||
controls_mask_state:Controls::all(),
|
controls_mask_state:Controls::all(),
|
||||||
strafe:Some(StrafeSettings{
|
strafe:Some(StrafeSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
enable:ControlsActivation::full_2d(),
|
||||||
@ -436,19 +481,18 @@ impl StyleModifiers{
|
|||||||
calculation:JumpCalculation::Linear,
|
calculation:JumpCalculation::Linear,
|
||||||
}),
|
}),
|
||||||
gravity:Planar64Vec3::int(0,-800,0)*VALVE_SCALE,
|
gravity:Planar64Vec3::int(0,-800,0)*VALVE_SCALE,
|
||||||
static_friction:Planar64::int(2),//?
|
|
||||||
kinetic_friction:Planar64::int(3),//?
|
|
||||||
mass:Planar64::int(1),
|
mass:Planar64::int(1),
|
||||||
rocket:None,
|
rocket:None,
|
||||||
walk:Some(WalkSettings{
|
walk:Some(WalkSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),//?
|
topspeed:Planar64::int(18),//?
|
||||||
accel:Planar64::int(90),//?
|
accel:Planar64::int(90),//?
|
||||||
},
|
},
|
||||||
|
static_friction:Planar64::int(2),//?
|
||||||
|
kinetic_friction:Planar64::int(3),//?
|
||||||
|
surf_dot:Planar64::int(3)/4,// normal.y=0.75
|
||||||
}),
|
}),
|
||||||
ladder:Some(LadderSettings{
|
ladder:Some(LadderSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
accelerate:AccelerateSettings{
|
accelerate:AccelerateSettings{
|
||||||
topspeed:Planar64::int(18),//?
|
topspeed:Planar64::int(18),//?
|
||||||
accel:Planar64::int(180),//?
|
accel:Planar64::int(180),//?
|
||||||
@ -456,10 +500,8 @@ impl StyleModifiers{
|
|||||||
dot:(Planar64::int(1)/2).sqrt(),//?
|
dot:(Planar64::int(1)/2).sqrt(),//?
|
||||||
}),
|
}),
|
||||||
swim:Some(PropulsionSettings{
|
swim:Some(PropulsionSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
|
||||||
magnitude:Planar64::int(12),//?
|
magnitude:Planar64::int(12),//?
|
||||||
}),
|
}),
|
||||||
surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75
|
|
||||||
hitbox:Hitbox::source(),
|
hitbox:Hitbox::source(),
|
||||||
camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)*VALVE_SCALE,
|
camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)*VALVE_SCALE,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user