Remove the corner helpers akgl_collide_rectangles no longer uses
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:
26
tests/perf.c
26
tests/perf.c
@@ -758,14 +758,6 @@ static akerr_ErrorContext *bench_logic_frame(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Time the geometry helpers, including the all-pairs sweep a caller has to write.
|
||||
*
|
||||
* akgl_collide_rectangles tests eight corners and returns at the first hit, so
|
||||
* an overlap is cheap and a miss is the full eight. The third benchmark is the
|
||||
* broad phase the library does not provide: 64 actors is 2016 pairs, and a
|
||||
* caller doing collision at all does that every frame.
|
||||
*/
|
||||
/** @brief Counts nothing; the query cost is what is being measured. */
|
||||
static akerr_ErrorContext *bench_collision_visit(akgl_CollisionProxy *proxy, void *data)
|
||||
{
|
||||
@@ -895,11 +887,22 @@ static akerr_ErrorContext *bench_collision(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Time akgl_collide_rectangles, and the all-pairs sweep it used to imply.
|
||||
*
|
||||
* The function is four span comparisons in `float32_t`, so an overlap and a miss
|
||||
* cost the same -- it has no early exit and does not want one.
|
||||
*
|
||||
* The last benchmark is the **control**, not a recommendation. It is what a game
|
||||
* had to write before 0.8.0: 64 actors is 2016 pairs, every frame. The
|
||||
* partitioner rows in bench_collision are what to compare it against, and the
|
||||
* comparison is generous to the control -- it tests pairs and does not sync,
|
||||
* sub-step or resolve anything.
|
||||
*/
|
||||
static akerr_ErrorContext *bench_geometry(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
akerr_ErrorContext *inner = NULL;
|
||||
akgl_RectanglePoints points;
|
||||
SDL_FRect rects[BENCH_ACTOR_COUNT];
|
||||
SDL_FRect overlapping = { .x = 8.0, .y = 8.0, .w = 32.0, .h = 32.0 };
|
||||
SDL_FRect disjoint = { .x = 900.0, .y = 900.0, .w = 32.0, .h = 32.0 };
|
||||
@@ -922,11 +925,6 @@ static akerr_ErrorContext *bench_geometry(void)
|
||||
pairs = (BENCH_ACTOR_COUNT * (BENCH_ACTOR_COUNT - 1)) / 2;
|
||||
|
||||
for ( rep = 0; rep < AKGL_BENCH_REPETITIONS; rep++ ) {
|
||||
bench_start("rectangle_points", "call", 100.0);
|
||||
BENCH_LOOP(inner, i, count, akgl_rectangle_points(&points, &subject));
|
||||
bench_stop(count);
|
||||
PASS(errctx, inner);
|
||||
|
||||
bench_start("collide_rectangles, overlapping", "call", 300.0);
|
||||
BENCH_LOOP(inner, i, count, akgl_collide_rectangles(&subject, &overlapping, &collide));
|
||||
bench_stop(count);
|
||||
|
||||
Reference in New Issue
Block a user