|
|
|
@ -28,9 +28,9 @@ use gameplay::ModeState;
|
|
|
|
|
// or the only bots which fail are ones exploiting a surgically patched bug.
|
|
|
|
|
#[derive(Clone,Copy,Hash,Debug,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
|
|
|
|
pub struct PhysicsVersion(u32);
|
|
|
|
|
pub const VERSION:PhysicsVersion=PhysicsVersion(0);
|
|
|
|
|
pub const VERSION:PhysicsVersion=PhysicsVersion(1);
|
|
|
|
|
const LATEST_COMPATIBLE_VERSION:[u32;1+VERSION.0 as usize]=const{
|
|
|
|
|
let compat=[0];
|
|
|
|
|
let compat=[0,1];
|
|
|
|
|
|
|
|
|
|
let mut input_version=0;
|
|
|
|
|
while input_version<compat.len(){
|
|
|
|
@ -200,17 +200,17 @@ fn ground_things(walk_settings:&gameplay_style::WalkSettings,contact:&ContactCol
|
|
|
|
|
let normal=contact_normal(models,hitbox_mesh,contact);
|
|
|
|
|
let gravity=touching.base_acceleration(models,style,camera,input_state);
|
|
|
|
|
let control_dir=style.get_y_control_dir(camera,input_state.controls);
|
|
|
|
|
let mut target_velocity=walk_settings.get_walk_target_velocity(control_dir,normal);
|
|
|
|
|
touching.constrain_velocity(models,hitbox_mesh,&mut target_velocity);
|
|
|
|
|
(gravity,target_velocity)
|
|
|
|
|
let target_velocity=walk_settings.get_walk_target_velocity(control_dir,normal);
|
|
|
|
|
let target_velocity_clipped=touching.constrain_velocity(models,hitbox_mesh,target_velocity);
|
|
|
|
|
(gravity,target_velocity_clipped)
|
|
|
|
|
}
|
|
|
|
|
fn ladder_things(ladder_settings:&gameplay_style::LadderSettings,contact:&ContactCollision,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState)->(Planar64Vec3,Planar64Vec3){
|
|
|
|
|
let normal=contact_normal(models,hitbox_mesh,contact);
|
|
|
|
|
let gravity=touching.base_acceleration(models,style,camera,input_state);
|
|
|
|
|
let control_dir=style.get_y_control_dir(camera,input_state.controls);
|
|
|
|
|
let mut target_velocity=ladder_settings.get_ladder_target_velocity(control_dir,normal);
|
|
|
|
|
touching.constrain_velocity(models,hitbox_mesh,&mut target_velocity);
|
|
|
|
|
(gravity,target_velocity)
|
|
|
|
|
let target_velocity=ladder_settings.get_ladder_target_velocity(control_dir,normal);
|
|
|
|
|
let target_velocity_clipped=touching.constrain_velocity(models,hitbox_mesh,target_velocity);
|
|
|
|
|
(gravity,target_velocity_clipped)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
@ -807,8 +807,8 @@ impl TouchingState{
|
|
|
|
|
//TODO: add water
|
|
|
|
|
a
|
|
|
|
|
}
|
|
|
|
|
fn constrain_velocity(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,velocity:&mut Planar64Vec3){
|
|
|
|
|
let contacts=self.contacts.iter().map(|contact|{
|
|
|
|
|
fn constrain_velocity(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,velocity:Planar64Vec3)->Planar64Vec3{
|
|
|
|
|
let contacts:Vec<_>=self.contacts.iter().map(|contact|{
|
|
|
|
|
let n=contact_normal(models,hitbox_mesh,contact);
|
|
|
|
|
crate::push_solve::Contact{
|
|
|
|
|
position:vec3::ZERO,
|
|
|
|
@ -816,10 +816,10 @@ impl TouchingState{
|
|
|
|
|
normal:n,
|
|
|
|
|
}
|
|
|
|
|
}).collect();
|
|
|
|
|
*velocity=crate::push_solve::push_solve(&contacts,*velocity);
|
|
|
|
|
crate::push_solve::push_solve(&contacts,velocity)
|
|
|
|
|
}
|
|
|
|
|
fn constrain_acceleration(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,acceleration:&mut Planar64Vec3){
|
|
|
|
|
let contacts=self.contacts.iter().map(|contact|{
|
|
|
|
|
fn constrain_acceleration(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,acceleration:Planar64Vec3)->Planar64Vec3{
|
|
|
|
|
let contacts:Vec<_>=self.contacts.iter().map(|contact|{
|
|
|
|
|
let n=contact_normal(models,hitbox_mesh,contact);
|
|
|
|
|
crate::push_solve::Contact{
|
|
|
|
|
position:vec3::ZERO,
|
|
|
|
@ -827,7 +827,7 @@ impl TouchingState{
|
|
|
|
|
normal:n,
|
|
|
|
|
}
|
|
|
|
|
}).collect();
|
|
|
|
|
*acceleration=crate::push_solve::push_solve(&contacts,*acceleration);
|
|
|
|
|
crate::push_solve::push_solve(&contacts,acceleration)
|
|
|
|
|
}
|
|
|
|
|
fn predict_collision_end(&self,collector:&mut instruction::InstructionCollector<InternalInstruction,TimeInner>,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,body:&Body,start_time:Time){
|
|
|
|
|
// let relative_body=crate::body::VirtualBody::relative(&Body::ZERO,body).body(time);
|
|
|
|
@ -1294,7 +1294,7 @@ fn set_velocity_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsM
|
|
|
|
|
let mut culled=false;
|
|
|
|
|
touching.contacts.retain(|contact|{
|
|
|
|
|
let n=contact_normal(models,hitbox_mesh,contact);
|
|
|
|
|
let r=n.dot(v).is_positive();
|
|
|
|
|
let r=(n.dot(v)>>52).is_positive();
|
|
|
|
|
if r{
|
|
|
|
|
culled=true;
|
|
|
|
|
}
|
|
|
|
@ -1303,9 +1303,8 @@ fn set_velocity_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsM
|
|
|
|
|
set_velocity(body,touching,models,hitbox_mesh,v);
|
|
|
|
|
culled
|
|
|
|
|
}
|
|
|
|
|
fn set_velocity(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,mut v:Planar64Vec3){
|
|
|
|
|
touching.constrain_velocity(models,hitbox_mesh,&mut v);
|
|
|
|
|
body.velocity=v;
|
|
|
|
|
fn set_velocity(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,v:Planar64Vec3){
|
|
|
|
|
body.velocity=touching.constrain_velocity(models,hitbox_mesh,v);;
|
|
|
|
|
}
|
|
|
|
|
fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,a:Planar64Vec3)->bool{
|
|
|
|
|
//This is not correct but is better than what I have
|
|
|
|
@ -1321,9 +1320,8 @@ fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&Phys
|
|
|
|
|
set_acceleration(body,touching,models,hitbox_mesh,a);
|
|
|
|
|
culled
|
|
|
|
|
}
|
|
|
|
|
fn set_acceleration(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,mut a:Planar64Vec3){
|
|
|
|
|
touching.constrain_acceleration(models,hitbox_mesh,&mut a);
|
|
|
|
|
body.acceleration=a;
|
|
|
|
|
fn set_acceleration(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,a:Planar64Vec3){
|
|
|
|
|
body.acceleration=touching.constrain_acceleration(models,hitbox_mesh,a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn teleport(
|
|
|
|
@ -1562,6 +1560,21 @@ fn collision_start_contact(
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
match &attr.general.trajectory{
|
|
|
|
|
Some(trajectory)=>{
|
|
|
|
|
match trajectory{
|
|
|
|
|
gameplay_attributes::SetTrajectory::AirTime(_)=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::Height(_)=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::TargetPointTime{..}=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::TargetPointSpeed{..}=>todo!(),
|
|
|
|
|
&gameplay_attributes::SetTrajectory::Velocity(velocity)=>{
|
|
|
|
|
move_state.cull_velocity(velocity,body,touching,models,hitbox_mesh,style,camera,input_state);
|
|
|
|
|
},
|
|
|
|
|
gameplay_attributes::SetTrajectory::DotVelocity{..}=>todo!(),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
None=>(),
|
|
|
|
|
}
|
|
|
|
|
//I love making functions with 10 arguments to dodge the borrow checker
|
|
|
|
|
if allow_run_teleport_behaviour{
|
|
|
|
|
run_teleport_behaviour(model_id,attr.general.wormhole.as_ref(),mode,move_state,body,touching,run,mode_state,models,hitbox_mesh,bvh,style,camera,input_state,time);
|
|
|
|
@ -1589,21 +1602,6 @@ fn collision_start_contact(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
match &attr.general.trajectory{
|
|
|
|
|
Some(trajectory)=>{
|
|
|
|
|
match trajectory{
|
|
|
|
|
gameplay_attributes::SetTrajectory::AirTime(_)=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::Height(_)=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::TargetPointTime { target_point: _, time: _ }=>todo!(),
|
|
|
|
|
gameplay_attributes::SetTrajectory::TargetPointSpeed { target_point: _, speed: _, trajectory_choice: _ }=>todo!(),
|
|
|
|
|
&gameplay_attributes::SetTrajectory::Velocity(velocity)=>{
|
|
|
|
|
move_state.cull_velocity(velocity,body,touching,models,hitbox_mesh,style,camera,input_state);
|
|
|
|
|
},
|
|
|
|
|
gameplay_attributes::SetTrajectory::DotVelocity { direction: _, dot: _ }=>todo!(),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
None=>(),
|
|
|
|
|
}
|
|
|
|
|
//doing enum to set the acceleration when surfing
|
|
|
|
|
//doing input_and_body to refresh the walk state if you hit a wall while accelerating
|
|
|
|
|
move_state.apply_enum_and_input_and_body(body,touching,models,hitbox_mesh,style,camera,input_state);
|
|
|
|
@ -1845,7 +1843,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|
|
|
|
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
|
|
|
|
let booster_option=data.models.contact_attr(walk_state.contact.model_id).general.booster.as_ref();
|
|
|
|
|
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity,booster_option);
|
|
|
|
|
state.cull_velocity(&data,jumped_velocity);
|
|
|
|
|
state.cull_velocity(data,jumped_velocity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
b_refresh_walk_target=false;
|
|
|
|
@ -2267,7 +2265,7 @@ mod test{
|
|
|
|
|
// spawn threads
|
|
|
|
|
println!("spawning up to {thread_limit} threads...");
|
|
|
|
|
let mut active_thread_count=0;
|
|
|
|
|
for _ in 0..thread_limit{
|
|
|
|
|
while active_thread_count<thread_limit{
|
|
|
|
|
if let Some(dir_entry_result)=read_dir.next(){
|
|
|
|
|
if let Some(file_path)=get_file_path(dir_entry_result?)?{
|
|
|
|
|
active_thread_count+=1;
|
|
|
|
|