|
|
|
|
@@ -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,
|
|
|
|
|
}
|
|
|
|
|
@@ -827,7 +828,7 @@ impl TouchingState{
|
|
|
|
|
//detect face slide off
|
|
|
|
|
let model_mesh=models.contact_mesh(convex_mesh_id);
|
|
|
|
|
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh());
|
|
|
|
|
collector.collect(minkowski.predict_collision_face_out(&relative_body,start_time..collector.time(),*face_id).map(|(_face,time)|{
|
|
|
|
|
collector.collect(minkowski.predict_collision_face_out(&relative_body,start_time..=collector.time(),*face_id).map(|(_face,time)|{
|
|
|
|
|
TimedInstruction{
|
|
|
|
|
time:relative_body.time+time.into(),
|
|
|
|
|
instruction:InternalInstruction::CollisionEnd(
|
|
|
|
|
@@ -841,7 +842,7 @@ impl TouchingState{
|
|
|
|
|
//detect model collision in reverse
|
|
|
|
|
let model_mesh=models.intersect_mesh(convex_mesh_id);
|
|
|
|
|
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh());
|
|
|
|
|
collector.collect(minkowski.predict_collision_out(&relative_body,start_time..collector.time()).map(|(_face,time)|{
|
|
|
|
|
collector.collect(minkowski.predict_collision_out(&relative_body,start_time..=collector.time()).map(|(_face,time)|{
|
|
|
|
|
TimedInstruction{
|
|
|
|
|
time:relative_body.time+time.into(),
|
|
|
|
|
instruction:InternalInstruction::CollisionEnd(
|
|
|
|
|
@@ -1188,7 +1189,7 @@ impl<'a> PhysicsContext<'a>{
|
|
|
|
|
//JUST POLLING!!! NO MUTATION
|
|
|
|
|
let mut collector=instruction::InstructionCollector::new(time_limit);
|
|
|
|
|
|
|
|
|
|
collector.collect(state.next_move_instruction());
|
|
|
|
|
// collector.collect(state.next_move_instruction());
|
|
|
|
|
|
|
|
|
|
//check for collision ends
|
|
|
|
|
state.touching.predict_collision_end(&mut collector,&data.models,&data.hitbox_mesh,&state.body,state.time);
|
|
|
|
|
@@ -1206,7 +1207,7 @@ impl<'a> PhysicsContext<'a>{
|
|
|
|
|
//no checks are needed because of the time limits.
|
|
|
|
|
let model_mesh=data.models.mesh(*convex_mesh_id);
|
|
|
|
|
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh());
|
|
|
|
|
collector.collect(minkowski.predict_collision_in(relative_body,state.time..collector.time())
|
|
|
|
|
collector.collect(minkowski.predict_collision_in(relative_body,state.time..=collector.time())
|
|
|
|
|
.map(|(face,dt)|
|
|
|
|
|
TimedInstruction{
|
|
|
|
|
time:relative_body.time+dt.into(),
|
|
|
|
|
@@ -1735,17 +1736,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,_)=>{
|
|
|
|
|
@@ -1792,6 +1790,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
|
|
|
|
|
|