not-working
This commit is contained in:
parent
9b4b09798b
commit
b0d8f2e09a
@ -500,8 +500,6 @@ impl MoveState{
|
|||||||
},
|
},
|
||||||
_=>(),
|
_=>(),
|
||||||
}
|
}
|
||||||
//this fixes falling through the ground when walking
|
|
||||||
self.apply_to_body(body,touching,models,hitbox_mesh,style,camera,input_state);
|
|
||||||
}
|
}
|
||||||
//function to coerce &mut self into &self
|
//function to coerce &mut self into &self
|
||||||
fn apply_to_body(&self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
|
fn apply_to_body(&self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
|
||||||
@ -523,8 +521,8 @@ impl MoveState{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// changes the move state and then applies it to body
|
/// changes the move state
|
||||||
fn apply_input(&mut self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
|
fn apply_input(&mut self,body:&Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
|
||||||
match self{
|
match self{
|
||||||
MoveState::Fly
|
MoveState::Fly
|
||||||
|MoveState::Air
|
|MoveState::Air
|
||||||
@ -546,8 +544,6 @@ impl MoveState{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
//precalculate gravity???
|
|
||||||
self.apply_to_body(body,touching,models,hitbox_mesh,style,camera,input_state);
|
|
||||||
}
|
}
|
||||||
fn get_walk_state(&self)->Option<&ContactMoveState>{
|
fn get_walk_state(&self)->Option<&ContactMoveState>{
|
||||||
match self{
|
match self{
|
||||||
@ -957,10 +953,37 @@ impl PhysicsState {
|
|||||||
fn next_move_instruction(&self)->Option<TimedInstruction<PhysicsInstruction>>{
|
fn next_move_instruction(&self)->Option<TimedInstruction<PhysicsInstruction>>{
|
||||||
self.move_state.next_move_instruction(&self.style.strafe,self.time)
|
self.move_state.next_move_instruction(&self.style.strafe,self.time)
|
||||||
}
|
}
|
||||||
|
//lmao idk this is convenient
|
||||||
|
fn apply_enum_and_input_and_body(&mut self,data:&PhysicsData){
|
||||||
|
self.move_state.apply_enum(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
self.move_state.apply_input(&self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
self.move_state.apply_to_body(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
}
|
||||||
|
fn apply_enum_and_body(&mut self,data:&PhysicsData){
|
||||||
|
self.move_state.apply_enum(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
self.move_state.apply_to_body(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
}
|
||||||
|
fn apply_input_and_body(&mut self,data:&PhysicsData){
|
||||||
|
self.move_state.apply_input(&self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
self.move_state.apply_to_body(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
||||||
|
}
|
||||||
fn set_move_state(&mut self,data:&PhysicsData,move_state:MoveState){
|
fn set_move_state(&mut self,data:&PhysicsData,move_state:MoveState){
|
||||||
move_state.apply_enum(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
|
self.apply_enum_and_body(data);
|
||||||
self.move_state=move_state;
|
self.move_state=move_state;
|
||||||
}
|
}
|
||||||
|
fn cull_velocity(&mut self,data:&PhysicsData,velocity:Planar64Vec3){
|
||||||
|
//TODO: be more precise about contacts
|
||||||
|
if set_velocity_cull(&mut self.body,&mut self.touching,&data.models,&data.hitbox_mesh,velocity){
|
||||||
|
//TODO do better
|
||||||
|
match self.move_state.get_walk_state(){
|
||||||
|
//did you stop touching the thing you were walking on?
|
||||||
|
Some(walk_state)=>if !self.touching.contacts.contains(&walk_state.contact){
|
||||||
|
self.set_move_state(&data,MoveState::Air);
|
||||||
|
},
|
||||||
|
None=>self.apply_enum_and_body(data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//state mutated on collision:
|
//state mutated on collision:
|
||||||
//Accelerator
|
//Accelerator
|
||||||
@ -1351,10 +1374,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
//&gameplay_attributes::Booster::Affine(transform)=>v=transform.transform_point3(v),
|
//&gameplay_attributes::Booster::Affine(transform)=>v=transform.transform_point3(v),
|
||||||
&gameplay_attributes::Booster::Velocity(velocity)=>{
|
&gameplay_attributes::Booster::Velocity(velocity)=>{
|
||||||
let boosted_velocity=state.body.velocity+velocity;
|
let boosted_velocity=state.body.velocity+velocity;
|
||||||
if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,boosted_velocity){
|
state.cull_velocity(data,boosted_velocity);
|
||||||
//wrong!!!
|
|
||||||
state.set_move_state(&data,MoveState::Air);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
&gameplay_attributes::Booster::Energy{direction: _,energy: _}=>todo!(),
|
&gameplay_attributes::Booster::Energy{direction: _,energy: _}=>todo!(),
|
||||||
}
|
}
|
||||||
@ -1365,10 +1385,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
if let (Some(jump_settings),Some(walk_state))=(&state.style.jump,state.move_state.get_walk_state()){
|
if let (Some(jump_settings),Some(walk_state))=(&state.style.jump,state.move_state.get_walk_state()){
|
||||||
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
||||||
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
||||||
if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,jumped_velocity){
|
state.cull_velocity(data,jumped_velocity);
|
||||||
//wrong!!!
|
|
||||||
state.set_move_state(&data,MoveState::Air);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match &general.trajectory{
|
match &general.trajectory{
|
||||||
@ -1379,18 +1396,16 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
gameplay_attributes::SetTrajectory::TargetPointTime { target_point: _, time: _ }=>todo!(),
|
gameplay_attributes::SetTrajectory::TargetPointTime { target_point: _, time: _ }=>todo!(),
|
||||||
gameplay_attributes::SetTrajectory::TargetPointSpeed { target_point: _, speed: _, trajectory_choice: _ }=>todo!(),
|
gameplay_attributes::SetTrajectory::TargetPointSpeed { target_point: _, speed: _, trajectory_choice: _ }=>todo!(),
|
||||||
&gameplay_attributes::SetTrajectory::Velocity(velocity)=>{
|
&gameplay_attributes::SetTrajectory::Velocity(velocity)=>{
|
||||||
if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,velocity){
|
state.cull_velocity(data,velocity);
|
||||||
//wrong!!!
|
|
||||||
state.set_move_state(&data,MoveState::Air);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
gameplay_attributes::SetTrajectory::DotVelocity { direction: _, dot: _ }=>todo!(),
|
gameplay_attributes::SetTrajectory::DotVelocity { direction: _, dot: _ }=>todo!(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None=>(),
|
None=>(),
|
||||||
}
|
}
|
||||||
//just doing this to set the acceleration when surfing
|
//doing enum to set the acceleration when surfing
|
||||||
state.move_state.apply_enum(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,&state.style,&state.camera,&state.input_state);
|
//doing input_and_body to refresh the walk state if you hit a wall while accelerating
|
||||||
|
state.apply_enum_and_input_and_body(data);
|
||||||
},
|
},
|
||||||
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
||||||
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
||||||
@ -1407,13 +1422,14 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
(PhysicsCollisionAttributes::Contact{contacting:_,general:_},&Collision::Contact(contact))=>{
|
(PhysicsCollisionAttributes::Contact{contacting:_,general:_},&Collision::Contact(contact))=>{
|
||||||
state.touching.remove(&collision);//remove contact before calling contact_constrain_acceleration
|
state.touching.remove(&collision);//remove contact before calling contact_constrain_acceleration
|
||||||
//check ground
|
//check ground
|
||||||
//TODO lol
|
//TODO do better
|
||||||
|
//this is inner code from state.cull_velocity
|
||||||
match state.move_state.get_walk_state(){
|
match state.move_state.get_walk_state(){
|
||||||
//did you stop touching the thing you were walking on?
|
//did you stop touching the thing you were walking on?
|
||||||
Some(walk_state)=>if walk_state.contact==contact{
|
Some(walk_state)=>if walk_state.contact==contact{
|
||||||
state.set_move_state(&data,MoveState::Air);
|
state.set_move_state(&data,MoveState::Air);
|
||||||
},
|
},
|
||||||
None=>(),
|
None=>state.apply_enum_and_body(data),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(PhysicsCollisionAttributes::Intersect{intersecting: _,general:_},Collision::Intersect(_))=>{
|
(PhysicsCollisionAttributes::Intersect{intersecting: _,general:_},Collision::Intersect(_))=>{
|
||||||
@ -1431,13 +1447,10 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
let control_dir=state.style.get_control_dir(masked_controls);
|
let control_dir=state.style.get_control_dir(masked_controls);
|
||||||
if control_dir!=Planar64Vec3::ZERO{
|
if control_dir!=Planar64Vec3::ZERO{
|
||||||
let camera_mat=state.camera.simulate_move_rotation_y(state.input_state.lerp_delta(state.time).x);
|
let camera_mat=state.camera.simulate_move_rotation_y(state.input_state.lerp_delta(state.time).x);
|
||||||
if let Some(v)=strafe_settings.tick_velocity(state.body.velocity,(camera_mat*control_dir).with_length(Planar64::ONE)){
|
if let Some(ticked_velocity)=strafe_settings.tick_velocity(state.body.velocity,(camera_mat*control_dir).with_length(Planar64::ONE)){
|
||||||
//this is wrong but will work ig
|
//this is wrong but will work ig
|
||||||
//need to note which push planes activate in push solve and keep those
|
//need to note which push planes activate in push solve and keep those
|
||||||
if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,v){
|
state.cull_velocity(data,ticked_velocity);
|
||||||
//wrong!!!
|
|
||||||
state.set_move_state(&data,MoveState::Air);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1492,11 +1505,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
if let Some(jump_settings)=&state.style.jump{
|
if let Some(jump_settings)=&state.style.jump{
|
||||||
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
||||||
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
||||||
//TODO: be more precise about contacts
|
state.cull_velocity(&data,jumped_velocity);
|
||||||
if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,jumped_velocity){
|
|
||||||
//wrong!!!
|
|
||||||
state.set_move_state(&data,MoveState::Air);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1531,7 +1540,8 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
PhysicsInputInstruction::Idle=>{b_refresh_walk_target=false;},//literally idle!
|
PhysicsInputInstruction::Idle=>{b_refresh_walk_target=false;},//literally idle!
|
||||||
}
|
}
|
||||||
if b_refresh_walk_target{
|
if b_refresh_walk_target{
|
||||||
state.move_state.apply_input(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,&state.style,&state.camera,&state.input_state);
|
state.apply_input_and_body(data);
|
||||||
|
state.cull_velocity(data,state.body.velocity);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user