diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index 092ac7d..cfe4c56 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -28,6 +28,7 @@ pub enum InternalInstruction{ CollisionStart(Collision,model_physics::GigaTime), CollisionEnd(Collision,model_physics::GigaTime), StrafeTick, + // TODO: add GigaTime to ReachWalkTargetVelocity ReachWalkTargetVelocity, // Water, } @@ -1675,17 +1676,14 @@ fn collision_end_intersect( } fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<InternalInstruction,Time>){ state.time=ins.time; - let (should_advance_body,goober_time)=match ins.instruction{ + match ins.instruction{ + // collisions advance the body precisely InternalInstruction::CollisionStart(_,dt) - |InternalInstruction::CollisionEnd(_,dt)=>(true,Some(dt)), - InternalInstruction::StrafeTick - |InternalInstruction::ReachWalkTargetVelocity=>(true,None), - }; - if should_advance_body{ - match goober_time{ - Some(dt)=>state.body.advance_time_ratio_dt(dt), - None=>state.body.advance_time(state.time), - } + |InternalInstruction::CollisionEnd(_,dt)=>state.body.advance_time_ratio_dt(dt), + // this advances imprecisely + InternalInstruction::ReachWalkTargetVelocity=>state.body.advance_time(state.time), + // strafe tick decides for itself whether to advance the body. + InternalInstruction::StrafeTick=>(), } match ins.instruction{ InternalInstruction::CollisionStart(collision,_)=>{ @@ -1732,6 +1730,8 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim let masked_controls=strafe_settings.mask(controls); let control_dir=state.style.get_control_dir(masked_controls); if control_dir!=vec3::ZERO{ + // manually advance time + state.body.advance_time(state.time); let camera_mat=state.camera.simulate_move_rotation_y(state.input_state.lerp_delta(state.time).x); if let Some(ticked_velocity)=strafe_settings.tick_velocity(state.body.velocity,(camera_mat*control_dir).with_length(Planar64::ONE).divide().wrap_1()){ //this is wrong but will work ig