use scale const instead of magic numbers

This commit is contained in:
Quaternions 2024-02-03 16:04:09 -08:00
parent 5ee826d948
commit f38d990a54

View File

@ -1,3 +1,5 @@
const VALVE_SCALE:i64=16;
use crate::integer::{Time,Ratio64,Planar64,Planar64Vec3}; use crate::integer::{Time,Ratio64,Planar64,Planar64Vec3};
pub struct StyleModifiers{ pub struct StyleModifiers{
@ -136,13 +138,13 @@ impl StyleModifiers{
air_accel_limit:Some(Planar64::raw(150<<28)*100), air_accel_limit:Some(Planar64::raw(150<<28)*100),
tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(), tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
}), }),
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)), jump_impulse:JumpImpulse::FromHeight(Planar64::int(52)/VALVE_SCALE),
jump_calculation:JumpCalculation::Linear, jump_calculation:JumpCalculation::Linear,
gravity:Planar64Vec3::raw(0,-800<<28,0), gravity:Planar64Vec3::int(0,-800,0)/VALVE_SCALE,
static_friction:Planar64::int(2),//? static_friction:Planar64::int(2),//?
kinetic_friction:Planar64::int(3),//? kinetic_friction:Planar64::int(3),//?
mass:Planar64::int(1), mass:Planar64::int(1),
mv:Planar64::raw(30<<28), mv:Planar64::raw(30)/VALVE_SCALE,
rocket_force:None, rocket_force:None,
walk_speed:Planar64::int(18),//? walk_speed:Planar64::int(18),//?
walk_accel:Planar64::int(90),//? walk_accel:Planar64::int(90),//?
@ -152,7 +154,7 @@ impl StyleModifiers{
swim_speed:Planar64::int(12),//? swim_speed:Planar64::int(12),//?
surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75 surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75
hitbox:Hitbox::source(), hitbox:Hitbox::source(),
camera_offset:Planar64Vec3::raw(0,(64<<28)-(73<<27),0), camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)/VALVE_SCALE,
} }
} }
fn source_surf()->Self{ fn source_surf()->Self{
@ -161,16 +163,16 @@ impl StyleModifiers{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN), controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
strafe:Some(StrafeSettings{ strafe:Some(StrafeSettings{
enable:EnableStrafe::Always, enable:EnableStrafe::Always,
air_accel_limit:Some(Planar64::raw(150<<28)*66), air_accel_limit:Some(Planar64::int(150)*66/VALVE_SCALE),
tick_rate:Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap(), tick_rate:Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap(),
}), }),
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)), jump_impulse:JumpImpulse::FromHeight(Planar64::int(52)/VALVE_SCALE),
jump_calculation:JumpCalculation::Linear, jump_calculation:JumpCalculation::Linear,
gravity:Planar64Vec3::raw(0,-800<<28,0), gravity:Planar64Vec3::int(0,-800,0)/VALVE_SCALE,
static_friction:Planar64::int(2),//? static_friction:Planar64::int(2),//?
kinetic_friction:Planar64::int(3),//? kinetic_friction:Planar64::int(3),//?
mass:Planar64::int(1), mass:Planar64::int(1),
mv:Planar64::raw(30<<28), mv:Planar64::int(30)/VALVE_SCALE,
rocket_force:None, rocket_force:None,
walk_speed:Planar64::int(18),//? walk_speed:Planar64::int(18),//?
walk_accel:Planar64::int(90),//? walk_accel:Planar64::int(90),//?
@ -180,7 +182,7 @@ impl StyleModifiers{
swim_speed:Planar64::int(12),//? swim_speed:Planar64::int(12),//?
surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75 surf_slope:Some(Planar64::raw(3787805118)),// normal.y=0.75
hitbox:Hitbox::source(), hitbox:Hitbox::source(),
camera_offset:Planar64Vec3::raw(0,(64<<28)-(73<<27),0), camera_offset:(Planar64Vec3::int(0,64,0)-Planar64Vec3::int(0,73,0)/2)/VALVE_SCALE,
} }
} }
fn roblox_rocket()->Self{ fn roblox_rocket()->Self{
@ -261,7 +263,7 @@ impl Hitbox{
} }
fn source()->Self{ fn source()->Self{
Self{ Self{
halfsize:Planar64Vec3::raw(33,73,33)/16/2, halfsize:Planar64Vec3::raw(33,73,33)/2/VALVE_SCALE,
mesh:HitboxMesh::Box, mesh:HitboxMesh::Box,
} }
} }