From d459fe64b6ebb48d68feb12d775b8f598bcf26bd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jul 2024 22:12:21 -0700 Subject: [PATCH] model is supposed to be guaranteed to exist --- src/physics.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index 38d71ff..50d3361 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -249,8 +249,8 @@ impl PhysicsModels{ &model.transform ) } - fn model(&self,model_id:PhysicsModelId)->Option<&PhysicsModel>{ - self.models.get(&model_id) + fn model(&self,model_id:PhysicsModelId)->&PhysicsModel{ + &self.models[&model_id] } fn attr(&self,model_id:PhysicsModelId)->&PhysicsCollisionAttributes{ &self.attributes[&self.models[&model_id].attr_id] @@ -1242,7 +1242,7 @@ fn teleport(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,sty MoveState::Air } fn teleport_to_spawn(body:&mut Body,touching:&mut TouchingState,style:&StyleModifiers,hitbox_mesh:&HitboxMesh,mode:&gameplay_modes::Mode,models:&PhysicsModels,stage_id:gameplay_modes::StageId)->Option{ - let model=models.model(mode.get_spawn_model_id(stage_id)?.into()).unwrap(); + let model=models.model(mode.get_spawn_model_id(stage_id)?.into()); let point=model.transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16); Some(teleport(body,touching,models,style,hitbox_mesh,point)) } @@ -1298,8 +1298,8 @@ fn run_teleport_behaviour(wormhole:&Option,models } match wormhole{ &Some(gameplay_attributes::Wormhole{destination_model})=>{ - let origin_model=models.model(convex_mesh_id.model_id).unwrap(); - let destination_model=models.model(destination_model.into()).unwrap(); + let origin_model=models.model(convex_mesh_id.model_id); + let destination_model=models.model(destination_model.into()); //ignore the transform for now Some(teleport(body,touching,models,style,hitbox_mesh,body.position-origin_model.transform.vertex.translation+destination_model.transform.vertex.translation)) } @@ -1521,9 +1521,9 @@ fn run_teleport_behaviour(wormhole:&Option,models //it matters which of these runs first, but I have not thought it through yet as it doesn't matter yet state.mode_state.clear(); state.mode_state.set_stage_id(gameplay_modes::StageId::FIRST); - let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).and_then(|mode| + let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).map(|mode| //TODO: spawn at the bottom of the start zone plus the hitbox size - data.models.model(mode.get_start().into()).map(|model|model.transform.vertex.translation) + data.models.model(mode.get_start().into()).transform.vertex.translation ).unwrap_or(Planar64Vec3::ZERO); set_position(&mut state.body,&mut state.touching,spawn_point); set_velocity(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,Planar64Vec3::ZERO);