move camera_offset to StyleModifiers & PhysicsOutputState
This commit is contained in:
parent
873c6ab935
commit
9592f82c4e
@ -186,7 +186,6 @@ impl Default for PhysicsModels{
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PhysicsCamera{
|
pub struct PhysicsCamera{
|
||||||
offset: Planar64Vec3,
|
|
||||||
//punch: Planar64Vec3,
|
//punch: Planar64Vec3,
|
||||||
//punch_velocity: Planar64Vec3,
|
//punch_velocity: Planar64Vec3,
|
||||||
sensitivity:Ratio64Vec2,//dots to Angle32 ratios
|
sensitivity:Ratio64Vec2,//dots to Angle32 ratios
|
||||||
@ -204,16 +203,6 @@ pub struct PhysicsCamera {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PhysicsCamera {
|
impl PhysicsCamera {
|
||||||
pub fn from_offset(offset:Planar64Vec3) -> Self {
|
|
||||||
Self{
|
|
||||||
offset,
|
|
||||||
sensitivity:Ratio64Vec2::ONE*200_000,
|
|
||||||
mouse:MouseState::default(),//t=0 does not cause divide by zero because it's immediately replaced
|
|
||||||
clamped_mouse_pos:glam::IVec2::ZERO,
|
|
||||||
angle_pitch_lower_limit:-Angle32::FRAC_PI_2,
|
|
||||||
angle_pitch_upper_limit:Angle32::FRAC_PI_2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn move_mouse(&mut self,mouse_pos:glam::IVec2){
|
pub fn move_mouse(&mut self,mouse_pos:glam::IVec2){
|
||||||
let mut unclamped_mouse_pos=self.clamped_mouse_pos+mouse_pos-self.mouse.pos;
|
let mut unclamped_mouse_pos=self.clamped_mouse_pos+mouse_pos-self.mouse.pos;
|
||||||
unclamped_mouse_pos.y=unclamped_mouse_pos.y.clamp(
|
unclamped_mouse_pos.y=unclamped_mouse_pos.y.clamp(
|
||||||
@ -247,7 +236,6 @@ impl PhysicsCamera {
|
|||||||
impl std::default::Default for PhysicsCamera{
|
impl std::default::Default for PhysicsCamera{
|
||||||
fn default()->Self{
|
fn default()->Self{
|
||||||
Self{
|
Self{
|
||||||
offset:Planar64Vec3::ZERO,//TODO: delete this from PhysicsCamera, it should be GraphicsCamera only
|
|
||||||
sensitivity:Ratio64Vec2::ONE*200_000,
|
sensitivity:Ratio64Vec2::ONE*200_000,
|
||||||
mouse:MouseState::default(),//t=0 does not cause divide by zero because it's immediately replaced
|
mouse:MouseState::default(),//t=0 does not cause divide by zero because it's immediately replaced
|
||||||
clamped_mouse_pos:glam::IVec2::ZERO,
|
clamped_mouse_pos:glam::IVec2::ZERO,
|
||||||
@ -313,6 +301,7 @@ struct StyleModifiers{
|
|||||||
rocket_force:Option<Planar64>,
|
rocket_force:Option<Planar64>,
|
||||||
gravity:Planar64Vec3,
|
gravity:Planar64Vec3,
|
||||||
hitbox_halfsize:Planar64Vec3,
|
hitbox_halfsize:Planar64Vec3,
|
||||||
|
camera_offset:Planar64Vec3,
|
||||||
}
|
}
|
||||||
impl std::default::Default for StyleModifiers{
|
impl std::default::Default for StyleModifiers{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@ -354,6 +343,7 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
||||||
swim_speed:Planar64::int(12),
|
swim_speed:Planar64::int(12),
|
||||||
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
||||||
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +368,7 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
||||||
swim_speed:Planar64::int(12),
|
swim_speed:Planar64::int(12),
|
||||||
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
||||||
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn roblox_surf()->Self{
|
fn roblox_surf()->Self{
|
||||||
@ -401,11 +392,11 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
||||||
swim_speed:Planar64::int(12),
|
swim_speed:Planar64::int(12),
|
||||||
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
||||||
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source_bhop()->Self{
|
fn source_bhop()->Self{
|
||||||
//camera_offset=vec3(0,64/16-73/16/2,0),
|
|
||||||
Self{
|
Self{
|
||||||
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
||||||
controls_held:0,
|
controls_held:0,
|
||||||
@ -426,6 +417,7 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),//?
|
ladder_dot:(Planar64::int(1)/2).sqrt(),//?
|
||||||
swim_speed:Planar64::int(12),//?
|
swim_speed:Planar64::int(12),//?
|
||||||
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
|
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
|
||||||
|
camera_offset:Planar64Vec3::raw(0,(64<<28)-(73<<27),0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn source_surf()->Self{
|
fn source_surf()->Self{
|
||||||
@ -450,6 +442,7 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),//?
|
ladder_dot:(Planar64::int(1)/2).sqrt(),//?
|
||||||
swim_speed:Planar64::int(12),//?
|
swim_speed:Planar64::int(12),//?
|
||||||
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
|
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
|
||||||
|
camera_offset:Planar64Vec3::raw(0,(64<<28)-(73<<27),0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn roblox_rocket()->Self{
|
fn roblox_rocket()->Self{
|
||||||
@ -473,6 +466,7 @@ impl StyleModifiers{
|
|||||||
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
||||||
swim_speed:Planar64::int(12),
|
swim_speed:Planar64::int(12),
|
||||||
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
||||||
|
camera_offset:Planar64Vec3::int(0,2,0),//4.5-2.5=2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,12 +572,13 @@ pub struct PhysicsState{
|
|||||||
}
|
}
|
||||||
#[derive(Clone,Default)]
|
#[derive(Clone,Default)]
|
||||||
pub struct PhysicsOutputState{
|
pub struct PhysicsOutputState{
|
||||||
camera:PhysicsCamera,
|
|
||||||
body:Body,
|
body:Body,
|
||||||
|
camera:PhysicsCamera,
|
||||||
|
camera_offset:Planar64Vec3,
|
||||||
}
|
}
|
||||||
impl PhysicsOutputState{
|
impl PhysicsOutputState{
|
||||||
pub fn extrapolate(&self,mouse_pos:glam::IVec2,time:Time)->(glam::Vec3,glam::Vec2){
|
pub fn extrapolate(&self,mouse_pos:glam::IVec2,time:Time)->(glam::Vec3,glam::Vec2){
|
||||||
((self.body.extrapolated_position(time)+self.camera.offset).into(),self.camera.simulate_move_angles(mouse_pos))
|
((self.body.extrapolated_position(time)+self.camera_offset).into(),self.camera.simulate_move_angles(mouse_pos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +747,7 @@ impl Default for PhysicsState{
|
|||||||
models:PhysicsModels::default(),
|
models:PhysicsModels::default(),
|
||||||
bvh:crate::bvh::BvhNode::default(),
|
bvh:crate::bvh::BvhNode::default(),
|
||||||
move_state: MoveState::Air,
|
move_state: MoveState::Air,
|
||||||
camera: PhysicsCamera::from_offset(Planar64Vec3::int(0,2,0)),//4.5-2.5=2
|
camera:PhysicsCamera::default(),
|
||||||
next_mouse:MouseState::default(),
|
next_mouse:MouseState::default(),
|
||||||
controls:0,
|
controls:0,
|
||||||
world:WorldState{},
|
world:WorldState{},
|
||||||
@ -774,6 +769,7 @@ impl PhysicsState {
|
|||||||
PhysicsOutputState{
|
PhysicsOutputState{
|
||||||
body:self.body.clone(),
|
body:self.body.clone(),
|
||||||
camera:self.camera.clone(),
|
camera:self.camera.clone(),
|
||||||
|
camera_offset:self.style.camera_offset.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user