Remove the corner helpers akgl_collide_rectangles no longer uses
Some checks failed
libakgl CI Build / cmake_build (push) Failing after 21s
libakgl CI Build / performance (push) Failing after 21s
libakgl CI Build / memory_check (push) Failing after 17s
libakgl CI Build / mutation_test (push) Failing after 19s

akgl_rectangle_points, akgl_collide_point_rectangle, akgl_Point and
akgl_RectanglePoints go. They were the intermediate form of an implementation
that changed: akgl_collide_rectangles was eight corner-containment tests built on
them, and it has been four span comparisons since the cross-case fix. Nothing
outside tests/ called either function, and a point-in-rectangle test is four
comparisons a caller can write without a struct conversion in front of them.

akgl_collide_rectangles stays. It has two correct callers in the sidescroller
asking a game-level overlap question -- a coin, a hazard, from an updatefunc --
where a bool is the whole answer and a proxy plus a narrowphase call would be
computing a normal nothing reads. TODO.md records the split rather than leaving
it to be rediscovered.

Public API removal, so 194 exported akgl_ symbols against 196, and the manual's
counts move with them. The perf suite loses its rectangle_points row; the
all-pairs sweep stays as the control it is now labelled, and PERFORMANCE.md says
what 0.8.0 measured against it -- 188.5 us for 32,640 pairs at 256 actors, where
a whole step with collision attached is 54.1 us doing strictly more.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71
This commit is contained in:
2026-08-02 08:09:42 -04:00
parent 3a6569e384
commit 4e32328681
11 changed files with 134 additions and 395 deletions

46
TODO.md
View File

@@ -2518,36 +2518,36 @@ follow that are true today and would not survive a change:
`akgl_ccd_arena_highwater()` is public so a game can assert its own ceiling.
## The `util.h` rectangle helpers stay, and why
## `akgl_collide_rectangles` stays; the corner helpers did not
The collision plan's last step was to **delete `akgl_rectangle_points`,
`akgl_collide_point_rectangle` and `akgl_collide_rectangles`** once the shape API
landed, on the grounds that collision now has a real narrowphase. That step was
not taken, and this is the reasoning rather than an oversight.
landed, on the grounds that collision now has a real narrowphase. Two of the
three went, in 0.8.0, along with `akgl_Point` and `akgl_RectanglePoints`. The
third stays, and this is the reasoning rather than an oversight.
- **They still have callers that are correct.** `examples/sidescroller/player.c`
uses `akgl_collide_rectangles` twice, for coins and for hazards. Those are
overlap *questions* asked from an `updatefunc` -- "am I touching this" -- and
the right answer is a `bool`. Routing them through a collision shape would
mean a proxy, a broad-phase insert and a narrowphase call to compute a normal
and a depth that nothing reads.
- **`akgl_collide_rectangles` was fixed in this same series**, not left broken.
It was a corner test that missed the cross case and truncated through
`akgl_Point`'s `int` members; it is a span test now, exact in `float32_t`.
Deleting it two commits after fixing it is a strange thing to do to a caller.
**Why the two went.** They were the intermediate form of an implementation that
changed. `akgl_collide_rectangles` was eight corner-containment tests built on
them; it is four span comparisons now and does not go through either. Nothing
outside `tests/` called them, and a point-in-rectangle test is four comparisons a
caller can write without a struct conversion in front of it.
**Why the third stays.**
- **It has callers that are correct.** `examples/sidescroller/player.c` uses it
twice, for coins and for hazards. Those are overlap *questions* asked from an
`updatefunc` -- "am I touching this" -- and the right answer is a `bool`.
Routing them through a collision shape would mean a proxy, a broad-phase insert
and a narrowphase call to compute a normal and a depth that nothing reads.
- **It was fixed in this same series**, not left broken. It missed the cross case
and truncated through `akgl_Point`'s `int` members; it is exact in `float32_t`
now. Deleting it two commits after fixing it is a strange thing to do to a
caller.
- **A game-level overlap question is not always a physics question.** A minimap
marker, a UI hit test, "is the cursor over this". None of those wants to be
pushed, and none of them belongs in a collision world.
`akgl_rectangle_points` and `akgl_collide_point_rectangle` are the weaker case:
nothing outside `tests/` calls either, and `akgl_collide_rectangles` no longer
does since it stopped working corner by corner. They are kept for symmetry with
the one that is used and because a point-in-rectangle test is the other half of
the same question -- but if a 0.9.0 wants to trim the public surface, those two
are the candidates, not `akgl_collide_rectangles`.
One thing found while writing this and fixed rather than recorded:
One thing found while doing this and fixed rather than recorded:
`akgl_RectanglePoints`' Doxygen comment still said `akgl_collide_rectangles`
"works corner by corner rather than by comparing edge spans", which had been
false since the fix. [Chapter 19](docs/19-utilities.md) already described the
current behaviour correctly, so the header was the only place saying otherwise.
false since the fix. It went with the type.