|
|
|
@ -291,7 +291,7 @@ enum JumpImpulse{
|
|
|
|
|
struct StyleModifiers{
|
|
|
|
|
controls_mask:u32,//controls which are unable to be activated
|
|
|
|
|
controls_held:u32,//controls which must be active to be able to strafe
|
|
|
|
|
strafe_tick_rate:Ratio64,
|
|
|
|
|
strafe_tick_rate:Option<Ratio64>,
|
|
|
|
|
jump_impulse:JumpImpulse,
|
|
|
|
|
jump_calculation:JumpCalculation,
|
|
|
|
|
static_friction:Planar64,
|
|
|
|
@ -305,6 +305,7 @@ struct StyleModifiers{
|
|
|
|
|
mass:Planar64,
|
|
|
|
|
mv:Planar64,
|
|
|
|
|
air_accel_limit:Option<Planar64>,
|
|
|
|
|
rocket_force:Option<Planar64>,
|
|
|
|
|
gravity:Planar64Vec3,
|
|
|
|
|
hitbox_halfsize:Planar64Vec3,
|
|
|
|
|
}
|
|
|
|
@ -331,7 +332,7 @@ impl StyleModifiers{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:Ratio64::new(128,Time::ONE_SECOND.nanos() as u64).unwrap(),
|
|
|
|
|
strafe_tick_rate:Some(Ratio64::new(128,Time::ONE_SECOND.nanos() as u64).unwrap()),
|
|
|
|
|
jump_impulse:JumpImpulse::FromEnergy(Planar64::int(512)),
|
|
|
|
|
jump_calculation:JumpCalculation::Energy,
|
|
|
|
|
gravity:Planar64Vec3::int(0,-80,0),
|
|
|
|
@ -340,6 +341,7 @@ impl StyleModifiers{
|
|
|
|
|
mass:Planar64::int(1),
|
|
|
|
|
mv:Planar64::int(2),
|
|
|
|
|
air_accel_limit:None,
|
|
|
|
|
rocket_force:None,
|
|
|
|
|
walk_speed:Planar64::int(16),
|
|
|
|
|
walk_accel:Planar64::int(80),
|
|
|
|
|
ladder_speed:Planar64::int(16),
|
|
|
|
@ -354,7 +356,7 @@ impl StyleModifiers{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
|
|
|
|
|
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
|
|
|
|
|
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
|
|
|
|
|
jump_calculation:JumpCalculation::Capped,
|
|
|
|
|
gravity:Planar64Vec3::int(0,-100,0),
|
|
|
|
@ -363,6 +365,7 @@ impl StyleModifiers{
|
|
|
|
|
mass:Planar64::int(1),
|
|
|
|
|
mv:Planar64::int(27)/10,
|
|
|
|
|
air_accel_limit:None,
|
|
|
|
|
rocket_force:None,
|
|
|
|
|
walk_speed:Planar64::int(18),
|
|
|
|
|
walk_accel:Planar64::int(90),
|
|
|
|
|
ladder_speed:Planar64::int(18),
|
|
|
|
@ -376,7 +379,7 @@ impl StyleModifiers{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
|
|
|
|
|
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
|
|
|
|
|
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
|
|
|
|
|
jump_calculation:JumpCalculation::Capped,
|
|
|
|
|
gravity:Planar64Vec3::int(0,-50,0),
|
|
|
|
@ -385,6 +388,7 @@ impl StyleModifiers{
|
|
|
|
|
mass:Planar64::int(1),
|
|
|
|
|
mv:Planar64::int(27)/10,
|
|
|
|
|
air_accel_limit:None,
|
|
|
|
|
rocket_force:None,
|
|
|
|
|
walk_speed:Planar64::int(18),
|
|
|
|
|
walk_accel:Planar64::int(90),
|
|
|
|
|
ladder_speed:Planar64::int(18),
|
|
|
|
@ -400,7 +404,7 @@ impl StyleModifiers{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
|
|
|
|
|
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
|
|
|
|
|
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)),
|
|
|
|
|
jump_calculation:JumpCalculation::Linear,
|
|
|
|
|
gravity:Planar64Vec3::raw(0,-800<<28,0),
|
|
|
|
@ -409,6 +413,7 @@ impl StyleModifiers{
|
|
|
|
|
mass:Planar64::int(1),
|
|
|
|
|
mv:Planar64::raw(30<<28),
|
|
|
|
|
air_accel_limit:Some(Planar64::raw(150<<28)*66),
|
|
|
|
|
rocket_force:None,
|
|
|
|
|
walk_speed:Planar64::int(18),//?
|
|
|
|
|
walk_accel:Planar64::int(90),//?
|
|
|
|
|
ladder_speed:Planar64::int(18),//?
|
|
|
|
@ -423,7 +428,7 @@ impl StyleModifiers{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap(),
|
|
|
|
|
strafe_tick_rate:Some(Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap()),
|
|
|
|
|
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)),
|
|
|
|
|
jump_calculation:JumpCalculation::Linear,
|
|
|
|
|
gravity:Planar64Vec3::raw(0,-800<<28,0),
|
|
|
|
@ -432,6 +437,7 @@ impl StyleModifiers{
|
|
|
|
|
mass:Planar64::int(1),
|
|
|
|
|
mv:Planar64::raw(30<<28),
|
|
|
|
|
air_accel_limit:Some(Planar64::raw(150<<28)*66),
|
|
|
|
|
rocket_force:None,
|
|
|
|
|
walk_speed:Planar64::int(18),//?
|
|
|
|
|
walk_accel:Planar64::int(90),//?
|
|
|
|
|
ladder_speed:Planar64::int(18),//?
|
|
|
|
@ -441,6 +447,29 @@ impl StyleModifiers{
|
|
|
|
|
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fn roblox_rocket()->Self{
|
|
|
|
|
Self{
|
|
|
|
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
|
|
|
|
controls_held:0,
|
|
|
|
|
strafe_tick_rate:None,
|
|
|
|
|
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
|
|
|
|
|
jump_calculation:JumpCalculation::Capped,
|
|
|
|
|
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),
|
|
|
|
|
mv:Planar64::int(27)/10,
|
|
|
|
|
air_accel_limit:None,
|
|
|
|
|
rocket_force:Some(Planar64::int(200)),
|
|
|
|
|
walk_speed:Planar64::int(18),
|
|
|
|
|
walk_accel:Planar64::int(90),
|
|
|
|
|
ladder_speed:Planar64::int(18),
|
|
|
|
|
ladder_accel:Planar64::int(180),
|
|
|
|
|
ladder_dot:(Planar64::int(1)/2).sqrt(),
|
|
|
|
|
swim_speed:Planar64::int(12),
|
|
|
|
|
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_control(&self,control:u32,controls:u32)->bool{
|
|
|
|
|
controls&self.controls_mask&control==control
|
|
|
|
@ -508,10 +537,9 @@ impl StyleModifiers{
|
|
|
|
|
// return cross(cross(Normal,ControlDir),Normal)/sqrt(1-d*d)
|
|
|
|
|
control_dir*self.walk_speed
|
|
|
|
|
}
|
|
|
|
|
fn get_propulsion_target_velocity(&self,camera:&PhysicsCamera,controls:u32,next_mouse:&MouseState,time:Time)->Planar64Vec3{
|
|
|
|
|
fn get_propulsion_control_dir(&self,camera:&PhysicsCamera,controls:u32,next_mouse:&MouseState,time:Time)->Planar64Vec3{
|
|
|
|
|
let camera_mat=camera.simulate_move_rotation(camera.mouse.lerp(&next_mouse,time));
|
|
|
|
|
let control_dir=camera_mat*self.get_control_dir(controls);
|
|
|
|
|
control_dir*self.walk_speed
|
|
|
|
|
camera_mat*self.get_control_dir(controls)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -856,11 +884,13 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
|
|
|
|
return Some(TimedInstruction{
|
|
|
|
|
time:Time::from_nanos(self.style.strafe_tick_rate.rhs_div_int(self.style.strafe_tick_rate.mul_int(self.time.nanos())+1)),
|
|
|
|
|
//only poll the physics if there is a before and after mouse event
|
|
|
|
|
instruction:PhysicsInstruction::StrafeTick
|
|
|
|
|
});
|
|
|
|
|
self.style.strafe_tick_rate.as_ref().map(|strafe_tick_rate|{
|
|
|
|
|
TimedInstruction{
|
|
|
|
|
time:Time::from_nanos(strafe_tick_rate.rhs_div_int(strafe_tick_rate.mul_int(self.time.nanos())+1)),
|
|
|
|
|
//only poll the physics if there is a before and after mouse event
|
|
|
|
|
instruction:PhysicsInstruction::StrafeTick
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//state mutated on collision:
|
|
|
|
@ -894,16 +924,20 @@ impl PhysicsState {
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
fn refresh_walk_target(&mut self){
|
|
|
|
|
fn refresh_walk_target(&mut self)->Option<Planar64Vec3>{
|
|
|
|
|
match &mut self.move_state{
|
|
|
|
|
MoveState::Air|MoveState::Water=>(),
|
|
|
|
|
MoveState::Air|MoveState::Water=>None,
|
|
|
|
|
MoveState::Walk(WalkState{normal,state})=>{
|
|
|
|
|
let n=normal;
|
|
|
|
|
(*state,self.body.acceleration)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_walk_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
|
|
|
|
|
let a;
|
|
|
|
|
(*state,a)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_walk_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
|
|
|
|
|
Some(a)
|
|
|
|
|
},
|
|
|
|
|
MoveState::Ladder(WalkState{normal,state})=>{
|
|
|
|
|
let n=normal;
|
|
|
|
|
(*state,self.body.acceleration)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_ladder_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
|
|
|
|
|
let a;
|
|
|
|
|
(*state,a)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_ladder_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
|
|
|
|
|
Some(a)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -941,7 +975,8 @@ impl PhysicsState {
|
|
|
|
|
//collect x
|
|
|
|
|
match collision_data.face {
|
|
|
|
|
TreyMeshFace::Top|TreyMeshFace::Back|TreyMeshFace::Bottom|TreyMeshFace::Front=>{
|
|
|
|
|
for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -954,7 +989,8 @@ impl PhysicsState {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -986,7 +1022,8 @@ impl PhysicsState {
|
|
|
|
|
//collect y
|
|
|
|
|
match collision_data.face {
|
|
|
|
|
TreyMeshFace::Left|TreyMeshFace::Back|TreyMeshFace::Right|TreyMeshFace::Front=>{
|
|
|
|
|
for t in zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -999,7 +1036,8 @@ impl PhysicsState {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -1031,7 +1069,8 @@ impl PhysicsState {
|
|
|
|
|
//collect z
|
|
|
|
|
match collision_data.face {
|
|
|
|
|
TreyMeshFace::Left|TreyMeshFace::Bottom|TreyMeshFace::Right|TreyMeshFace::Top=>{
|
|
|
|
|
for t in zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -1044,7 +1083,8 @@ impl PhysicsState {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//negative t = back in time
|
|
|
|
|
//must be moving towards surface to collide
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
@ -1074,7 +1114,7 @@ impl PhysicsState {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
//generate instruction
|
|
|
|
|
if let Some(face) = exit_face{
|
|
|
|
|
if let Some(_face) = exit_face{
|
|
|
|
|
return Some(TimedInstruction {
|
|
|
|
|
time: best_time,
|
|
|
|
|
instruction: PhysicsInstruction::CollisionEnd(collision_data.clone())
|
|
|
|
@ -1090,7 +1130,8 @@ impl PhysicsState {
|
|
|
|
|
let mut best_time=time_limit;
|
|
|
|
|
let mut best_face:Option<TreyMeshFace>=None;
|
|
|
|
|
//collect x
|
|
|
|
|
for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1106,7 +1147,8 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1123,7 +1165,8 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//collect y
|
|
|
|
|
for t in zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1139,7 +1182,8 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1156,7 +1200,8 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//collect z
|
|
|
|
|
for t in zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1172,7 +1217,8 @@ impl PhysicsState {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for t in zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2) {
|
|
|
|
|
let (roots,nroots)=zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2);
|
|
|
|
|
for &t in &roots[0..nroots]{
|
|
|
|
|
//must collide now or in the future
|
|
|
|
|
//must beat the current soonest collision time
|
|
|
|
|
//must be moving towards surface
|
|
|
|
@ -1331,7 +1377,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
match booster{
|
|
|
|
|
&crate::model::GameMechanicBooster::Affine(transform)=>v=transform.transform_point3(v),
|
|
|
|
|
&crate::model::GameMechanicBooster::Velocity(velocity)=>v+=velocity,
|
|
|
|
|
&crate::model::GameMechanicBooster::Energy{direction,energy}=>todo!(),
|
|
|
|
|
&crate::model::GameMechanicBooster::Energy{direction: _,energy: _}=>todo!(),
|
|
|
|
|
}
|
|
|
|
|
self.touching.constrain_velocity(&self.models,&mut v);
|
|
|
|
|
},
|
|
|
|
@ -1342,10 +1388,10 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
match trajectory{
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::AirTime(_) => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::Height(_) => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::TargetPointTime { target_point, time } => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::TrajectoryTargetPoint { target_point, speed, trajectory_choice } => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::TargetPointTime { target_point: _, time: _ } => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::TrajectoryTargetPoint { target_point: _, speed: _, trajectory_choice: _ } => todo!(),
|
|
|
|
|
&crate::model::GameMechanicSetTrajectory::Velocity(velocity)=>v=velocity,
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::DotVelocity { direction, dot } => todo!(),
|
|
|
|
|
crate::model::GameMechanicSetTrajectory::DotVelocity { direction: _, dot: _ } => todo!(),
|
|
|
|
|
}
|
|
|
|
|
self.touching.constrain_velocity(&self.models,&mut v);
|
|
|
|
|
},
|
|
|
|
@ -1355,9 +1401,11 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
if self.style.get_control(StyleModifiers::CONTROL_JUMP,self.controls){
|
|
|
|
|
self.jump();
|
|
|
|
|
}
|
|
|
|
|
self.refresh_walk_target();
|
|
|
|
|
if let Some(a)=self.refresh_walk_target(){
|
|
|
|
|
self.body.acceleration=a;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
PhysicsCollisionAttributes::Intersect{intersecting,general}=>{
|
|
|
|
|
PhysicsCollisionAttributes::Intersect{intersecting: _,general}=>{
|
|
|
|
|
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
|
|
|
|
self.touching.insert_intersect(c.model,c);
|
|
|
|
|
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model);
|
|
|
|
@ -1367,9 +1415,12 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
PhysicsInstruction::CollisionEnd(c) => {
|
|
|
|
|
let model=c.model(&self.models).unwrap();
|
|
|
|
|
match &model.attributes{
|
|
|
|
|
PhysicsCollisionAttributes::Contact{contacting,general}=>{
|
|
|
|
|
PhysicsCollisionAttributes::Contact{contacting: _,general: _}=>{
|
|
|
|
|
self.touching.remove_contact(c.model);//remove contact before calling contact_constrain_acceleration
|
|
|
|
|
let mut a=self.style.gravity;
|
|
|
|
|
if let Some(rocket_force)=self.style.rocket_force{
|
|
|
|
|
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
|
|
|
|
|
}
|
|
|
|
|
self.touching.constrain_acceleration(&self.models,&mut a);
|
|
|
|
|
self.body.acceleration=a;
|
|
|
|
|
//check ground
|
|
|
|
@ -1379,10 +1430,12 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
//TODO: make this more advanced checking contacts
|
|
|
|
|
self.move_state=MoveState::Air;
|
|
|
|
|
},
|
|
|
|
|
_=>self.refresh_walk_target(),
|
|
|
|
|
_=>if let Some(a)=self.refresh_walk_target(){
|
|
|
|
|
self.body.acceleration=a;
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
PhysicsCollisionAttributes::Intersect{intersecting,general}=>{
|
|
|
|
|
PhysicsCollisionAttributes::Intersect{intersecting: _,general: _}=>{
|
|
|
|
|
self.touching.remove_intersect(c.model);
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
@ -1456,7 +1509,14 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|
|
|
|
PhysicsInputInstruction::Idle => {refresh_walk_target=false;},//literally idle!
|
|
|
|
|
}
|
|
|
|
|
if refresh_walk_target{
|
|
|
|
|
self.refresh_walk_target();
|
|
|
|
|
if let Some(a)=self.refresh_walk_target(){
|
|
|
|
|
self.body.acceleration=a;
|
|
|
|
|
}else if let Some(rocket_force)=self.style.rocket_force{
|
|
|
|
|
let mut a=self.style.gravity;
|
|
|
|
|
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
|
|
|
|
|
self.touching.constrain_acceleration(&self.models,&mut a);
|
|
|
|
|
self.body.acceleration=a;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|