basic wormholes (no velocity or camera transformation)

This commit is contained in:
Quaternions 2023-10-18 16:15:42 -07:00
parent 6e5de4aa46
commit cbcf047c3f

View File

@ -1342,7 +1342,7 @@ fn teleport(body:&mut Body,touching:&mut TouchingState,style:&StyleModifiers,poi
//touching.recalculate(body); //touching.recalculate(body);
} }
fn run_teleport_behaviour(teleport_behaviour:&Option<crate::model::TeleportBehaviour>,game:&mut GameMechanicsState,models:&PhysicsModels,modes:&Modes,style:&StyleModifiers,touching:&mut TouchingState,body:&mut Body)->Option<MoveState>{ fn run_teleport_behaviour(teleport_behaviour:&Option<crate::model::TeleportBehaviour>,game:&mut GameMechanicsState,models:&PhysicsModels,modes:&Modes,style:&StyleModifiers,touching:&mut TouchingState,body:&mut Body,model:&ModelPhysics)->Option<MoveState>{
match teleport_behaviour{ match teleport_behaviour{
Some(crate::model::TeleportBehaviour::StageElement(stage_element))=>{ Some(crate::model::TeleportBehaviour::StageElement(stage_element))=>{
if stage_element.force||game.stage_id<stage_element.stage_id{ if stage_element.force||game.stage_id<stage_element.stage_id{
@ -1362,8 +1362,10 @@ fn run_teleport_behaviour(teleport_behaviour:&Option<crate::model::TeleportBehav
} }
}, },
Some(crate::model::TeleportBehaviour::Wormhole(wormhole))=>{ Some(crate::model::TeleportBehaviour::Wormhole(wormhole))=>{
//telefart let origin_model=model;
None let destination_model=models.get_wormhole_model(wormhole.destination_model_id)?;
//ignore the transform for now
Some(teleport(body,touching,style,body.position-origin_model.transform.translation+destination_model.transform.translation))
} }
None=>None, None=>None,
} }
@ -1423,7 +1425,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
//check ground //check ground
self.touching.insert_contact(c.model,c); self.touching.insert_contact(c.model,c);
//I love making functions with 10 arguments to dodge the borrow checker //I love making functions with 10 arguments to dodge the borrow checker
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body); run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model);
//flatten v //flatten v
self.touching.constrain_velocity(&self.models,&mut v); self.touching.constrain_velocity(&self.models,&mut v);
match &general.booster{ match &general.booster{
@ -1460,7 +1462,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
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 //I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
self.touching.insert_intersect(c.model,c); 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); run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model);
}, },
} }
}, },