fix: AABB capsule collider for rigid entities, sliding on surfaces
- Replace per-body collision with single AABB collider for rigid entities - Entity has half_w/half_h defining the collider box - Separate axis resolution: X first (min-penetration push), then Y (velocity-direction push to handle floor/ceiling correctly) - Sliding: when hitting a wall, only X velocity is zeroed, Y continues - check_on_ground uses AABB bottom edge, not individual bodies - Fix: X resolution uses minimum penetration (was velocity-based, which pushed player through walls when velocity was zero) - Default scene: added water pool, lava pool, wood structure, sand dune, acid pool, stone wall obstacle - 28/28 tests passing
This commit is contained in:
@@ -13,17 +13,17 @@ fn setup_empty() -> GameSession {
|
||||
fn player_falls_and_lands() {
|
||||
let mut s = GameSession::new_seeded(42);
|
||||
s.init_empty();
|
||||
s.clear_area(115, 120, 20, 10);
|
||||
s.clear_area(115, 115, 20, 15);
|
||||
s.perform_action(&AiAction::FillRect { x: 110, y: 130, w: 30, h: 15, material: "stone".into() });
|
||||
s.step(40);
|
||||
s.step(80);
|
||||
let player = s.get_player().expect("player should exist");
|
||||
assert!(player.alive, "player should be alive");
|
||||
let y = player.pos[1];
|
||||
assert!(y < 140.0, "player should not fall through stone floor, got y={}", y);
|
||||
s.step(20);
|
||||
assert!(y < 135.0, "player should not fall through stone floor, got y={}", y);
|
||||
s.step(30);
|
||||
let player2 = s.get_player().expect("player should exist");
|
||||
let dy = (player2.pos[1] - y).abs();
|
||||
assert!(dy < 2.0, "player should have stopped falling (dy={:.2}), y={} -> {}", dy, y, player2.pos[1]);
|
||||
assert!(dy < 3.0, "player should have stopped falling (dy={:.2}), y={} -> {}", dy, y, player2.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user