Initial work on ledge & improved baking of root motion. (#90)
Reviewed-on: #90 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #90.
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
use crate::fighter::ecb::FighterPreviousECB;
|
||||
use crate::fighter::{FighterECB, FighterPreviousTranslation, FighterTranslation};
|
||||
use crate::math::rect::FGRect;
|
||||
use crate::math::segment::FGSegment2d;
|
||||
use crate::math::vec::FGVec2;
|
||||
use crate::stage::line::{StageCollision, StageLineID, StagePolyType};
|
||||
use crate::stage::line::{StageCollision, StageLineID, StagePolyType, StageVertexID};
|
||||
/*
|
||||
pub fn collide_fighter_with_scene(
|
||||
fighters: Query<(&FighterECB, &mut FighterVelocity, &mut FighterTranslation)>,
|
||||
@@ -83,6 +84,20 @@ pub fn air_collide_with_stage(
|
||||
.map(|(result, _)| result)
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AirCollisionWithLedgeResult {
|
||||
pub ledge: StageVertexID,
|
||||
}
|
||||
|
||||
pub fn air_collide_with_ledges(
|
||||
ledge_box: &FGRect,
|
||||
stage_collision: &StageCollision,
|
||||
) -> Option<AirCollisionWithLedgeResult> {
|
||||
stage_collision.intersect_ledges(ledge_box).map(|result| {
|
||||
AirCollisionWithLedgeResult { ledge: result.vertex_id }
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -115,6 +130,7 @@ mod tests {
|
||||
fn airborne_collision_skips_ignored_polygons() {
|
||||
let stage_collision = StageCollision {
|
||||
stage_polys: vec![horizontal_platform("0"), horizontal_platform("1")],
|
||||
..StageCollision::default()
|
||||
};
|
||||
let previous_translation = FighterPreviousTranslation(FGVec2::lit("0", "2"));
|
||||
let translation = FighterTranslation(FGVec2::lit("0", "-1"));
|
||||
@@ -150,6 +166,7 @@ mod tests {
|
||||
fn airborne_collision_skips_soft_platforms_while_passing_down() {
|
||||
let stage_collision = StageCollision {
|
||||
stage_polys: vec![horizontal_platform("0")],
|
||||
..StageCollision::default()
|
||||
};
|
||||
let previous_translation = FighterPreviousTranslation(FGVec2::lit("0", "2"));
|
||||
let translation = FighterTranslation(FGVec2::lit("0", "-1"));
|
||||
@@ -197,6 +214,7 @@ mod tests {
|
||||
fn airborne_collision_still_hits_solid_floors_while_passing_down() {
|
||||
let stage_collision = StageCollision {
|
||||
stage_polys: vec![solid_floor()],
|
||||
..StageCollision::default()
|
||||
};
|
||||
let previous_translation = FighterPreviousTranslation(FGVec2::lit("0", "2"));
|
||||
let translation = FighterTranslation(FGVec2::lit("0", "-1"));
|
||||
|
||||
Reference in New Issue
Block a user