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:
Emil
2026-06-20 21:56:13 +03:00
parent a731d5cbb7
commit a66b4ac0cb
4 changed files with 377 additions and 275 deletions
+131 -131
View File
@@ -12,16 +12,16 @@ Camera: (85, 230)
34
35
36
37
38
39
40 @@@@@
41 @@@@@@
42 @@@@@@
43 @@@@@ """""""""""""
44""" @@@@@ "":::::::::::::"""
45:::""" """::::::::::::::::::""
46::::::"" "":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T @@@@@ ...
41 T T ## @@@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -41,16 +41,16 @@ Entities: 1
34
35
36
37
38
39
40 @@@@@
41 @@@@@@
42 @@@@@@
43 @@@@@ """""""""""""
44""" @@@@@ "":::::::::::::"""
45:::""" """::::::::::::::::::""
46::::::"" "":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T @@@@@ ...
41 T T ## @@@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -71,16 +71,16 @@ Alive entities: Player(hp=100, pos=(125.0, 242.11879))
34
35
36
37
38
39
40 @@@@@
41 @@@@@@
42 @@@@@@
43 @@@@@ """""""""""""
44""" @@@@@ "":::::::::::::"""
45:::""" """::::::::::::::::::""
46::::::"" "":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T @@@@@ ...
41 T T ## @@@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -101,16 +101,16 @@ Alive entities: Player(hp=100, pos=(125.0, 242.38817))
34
35
36
37
38
39
40 @@@@@
41 @@@@@@
42 @@@@@@
43 @@@@@ """""""""""""
44""" @@@@@ "":::::::::::::"""
45:::""" """::::::::::::::::::""
46::::::"" "":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T @@@@@ ...
41 T T ## @@@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -130,16 +130,16 @@ Alive entities: Player(hp=100, pos=(125.0, 242.79922))
34
35
36
37
38
39
40
41 @@@@@
42 @@@@@@
43 @@@@@@ """""""""""""
44""" @@@@@ "":::::::::::::"""
45:::""" @@@@@ """::::::::::::::::::""
46::::::"" "":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -154,21 +154,22 @@ Entities: 1
Alive entities: Player(hp=100, pos=(125.0, 243.3436))
=== Tick 10 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43 @@@@@@ """""""""""""
44""" @@@@@@ "":::::::::::::"""
45:::""" @@@@@ """::::::::::::::::::""
46::::::"" @@@@@"":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -178,27 +179,27 @@ Alive entities: Player(hp=100, pos=(125.0, 243.3436))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(125.0,244.0) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(125.0, 244.01338))
Alive entities: Player(hp=100, pos=(125.0, 243.5))
=== Tick 12 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43 @@@@@@ """""""""""""
44""" @@@@@@ "":::::::::::::"""
45:::""" @@@@@ """::::::::::::::::::""
46::::::"" @@@@@"":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -208,27 +209,27 @@ Alive entities: Player(hp=100, pos=(125.0, 244.01338))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(125.0,244.5) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(125.0, 244.5))
Alive entities: Player(hp=100, pos=(125.0, 243.5))
=== Tick 14 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43 @@@@@@ """""""""""""
44""" @@@@@@ "":::::::::::::"""
45:::""" @@@@@ """::::::::::::::::::""
46::::::"" @@@@@"":::::::::::::::::::::::"""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
@@ -238,28 +239,28 @@ Alive entities: Player(hp=100, pos=(125.0, 244.5))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(125.0,244.5) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(125.0, 244.5))
Alive entities: Player(hp=100, pos=(125.0, 243.5))
=== Tick 16 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43" @@@@@@ """""""""""""
44:""" @@@@@@ "":::::::::::::"""
45::::""" @@@@@ """::::::::::::::::::""
46:::::::"" @@@@@ "":::::::::::::::::::::::"""
47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
50????????????????????????????????????????????????????????????????????????????????
@@ -268,28 +269,28 @@ Alive entities: Player(hp=100, pos=(125.0, 244.5))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(124.5, 244.5))
Alive entities: Player(hp=100, pos=(125.0, 243.5))
=== Tick 18 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43" @@@@@@ """""""""""""
44:""" @@@@@@ "":::::::::::::"""
45::::""" @@@@@ """::::::::::::::::::""
46:::::::"" @@@@@ "":::::::::::::::::::::::"""
47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
50????????????????????????????????????????????????????????????????????????????????
@@ -298,28 +299,28 @@ Alive entities: Player(hp=100, pos=(124.5, 244.5))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(124.5, 244.5))
Alive entities: Player(hp=100, pos=(125.0, 243.5))
=== Tick 20 ===
31
32
33
34
35
36
37
38
39
40
41
42 @@@@@
43" @@@@@@ """""""""""""
44:""" @@@@@@ "":::::::::::::"""
45::::""" @@@@@ """::::::::::::::::::""
46:::::::"" @@@@@ "":::::::::::::::::::::::"""
47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""
37 TTTTT
38 T T
39 T T .
40 T T ...
41 T T ## @@@@@ .....
42 T T ## @@@@@@ .......
43 T T ## @@@@@@ """"""""""""" .........
44""" T T ## @@@@@ "":::::::::::::""" ..........
45:::""" ## @@@@@ """::::::::::::::::::"" ...........
46::::::"" ## "":::::::::::::::::::::::""".........
47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""""
48::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
49################################################################################
50????????????????????????????????????????????????????????????????????????????????
@@ -328,8 +329,7 @@ Alive entities: Player(hp=100, pos=(124.5, 244.5))
53????????????????????????????????????????????????????????????????????????????????
54????????????????????????????????????????????????????????????????????????????????
55????????????????????????????????????????????????????????????????????????????????
56????????????????????????????????????????????????????????????????????????????????
Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false"
Player: "Player hp=100.0/100.0 pos=(125.0,243.5) bodies=27/27 on_fire=false"
Entities: 1
Alive entities: Player(hp=100, pos=(124.5, 244.5))
Alive entities: Player(hp=100, pos=(125.0, 243.5))