diff --git a/src/fighter/collision.rs b/src/fighter/collision.rs index 4ea1b55..f9eae3b 100644 --- a/src/fighter/collision.rs +++ b/src/fighter/collision.rs @@ -45,7 +45,7 @@ pub fn air_collide_with_stage( ecb: &FighterECB, stage_collision: &StageCollision, ignored_polys: &[usize], - ignore_soft_platforms: bool, + can_ignore_soft_platforms: bool, ) -> Option { let ray_segment = FGSegment2d::new( prev_translation.0 + prev_ecb.get_bottom_point(), @@ -58,7 +58,7 @@ pub fn air_collide_with_stage( .enumerate() .filter(|(poly_idx, poly)| { !ignored_polys.contains(poly_idx) - && !(ignore_soft_platforms && matches!(poly.poly_type, StagePolyType::Platform)) + && !(can_ignore_soft_platforms && matches!(poly.poly_type, StagePolyType::Platform)) }) .filter_map(|(poly_idx, poly)| { poly.intersect_ray(ray_segment).map(|intersect_result| { @@ -176,6 +176,21 @@ mod tests { true, ) .is_none()); + + assert_eq!( + air_collide_with_stage( + &previous_translation, + &translation, + &previous_ecb, + &ecb, + &stage_collision, + &[], + false, + ) + .expect("air dodges still collide with soft platforms") + .hit_position, + FGVec2::lit("0", "0") + ); } #[test] diff --git a/src/fighter/state/air.rs b/src/fighter/state/air.rs index a948a25..9f2b48f 100644 --- a/src/fighter/state/air.rs +++ b/src/fighter/state/air.rs @@ -115,8 +115,9 @@ pub fn update_standard_motion( pub fn collision_interrupt( ctx: &mut CollisionContext, landing_type: LandingType, + can_ignore_soft_platforms: bool, ) -> Option { - let res = ctx.air_collide_with_stage()?; + let res = ctx.air_collide_with_stage(can_ignore_soft_platforms)?; let diff = res.hit_position - ctx.translation.0; ctx.ecb.bottom -= diff; ctx.ecb.top -= diff; diff --git a/src/fighter/state/air_dodge.rs b/src/fighter/state/air_dodge.rs index 42165df..b894434 100644 --- a/src/fighter/state/air_dodge.rs +++ b/src/fighter/state/air_dodge.rs @@ -45,7 +45,7 @@ impl FighterStateImpl for AirDodgeState { &mut self, state_context: &mut CollisionContext, ) -> Option { - air::collision_interrupt(state_context, LandingType::Special) + air::collision_interrupt(state_context, LandingType::Special, false) } fn on_enter(&mut self, state_context: &mut EnterContext) { diff --git a/src/fighter/state/fall.rs b/src/fighter/state/fall.rs index 608ae82..e945184 100644 --- a/src/fighter/state/fall.rs +++ b/src/fighter/state/fall.rs @@ -38,6 +38,7 @@ impl FighterStateImpl for FallState { air::collision_interrupt( state_context, crate::fighter::state::land::LandingType::Normal, + true, ) } diff --git a/src/fighter/state/hitstun.rs b/src/fighter/state/hitstun.rs index 9849280..33cb905 100644 --- a/src/fighter/state/hitstun.rs +++ b/src/fighter/state/hitstun.rs @@ -114,7 +114,7 @@ impl FighterStateImpl for HitstunState { match &mut self.hitstop_kind { HitstopStateKind::Grounded => collision_interrupt(state_context, true), HitstopStateKind::Airborne => { - air::collision_interrupt(state_context, LandingType::Normal) + air::collision_interrupt(state_context, LandingType::Normal, false) } } } diff --git a/src/fighter/state/jump.rs b/src/fighter/state/jump.rs index 33e2119..77efb44 100644 --- a/src/fighter/state/jump.rs +++ b/src/fighter/state/jump.rs @@ -180,6 +180,7 @@ impl FighterStateImpl for JumpState { air::collision_interrupt( state_context, crate::fighter::state::land::LandingType::Normal, + true, ) } diff --git a/src/fighter/state/mod.rs b/src/fighter/state/mod.rs index 08bc6bf..64cd610 100644 --- a/src/fighter/state/mod.rs +++ b/src/fighter/state/mod.rs @@ -214,10 +214,11 @@ pub struct CollisionContext<'a> { impl CollisionContext<'_> { pub fn air_collide_with_stage( &self, + can_ignore_soft_platforms: bool, ) -> Option { let ignored_polys = self.surface.ignored_polygon_ids(); - let ignore_soft_platforms = - self.input.get_last_frame().movement.y <= -self.downward_stick_threshold; + let ignore_soft_platforms = can_ignore_soft_platforms + && self.input.get_last_frame().movement.y <= -self.downward_stick_threshold; crate::fighter::collision::air_collide_with_stage( self.prev_translation, self.translation, diff --git a/src/fighter/state/platform_pass.rs b/src/fighter/state/platform_pass.rs index ff172d1..81105ad 100644 --- a/src/fighter/state/platform_pass.rs +++ b/src/fighter/state/platform_pass.rs @@ -46,6 +46,7 @@ impl FighterStateImpl for PlatformPassState { air::collision_interrupt( state_context, crate::fighter::state::land::LandingType::Normal, + true, ) }