From 7950e4563257f944dcb12e3deb205785b03df410 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Jul 2023 21:14:44 +0200 Subject: [PATCH] reordered terms in _rect_overlap --- src/corelib/physics.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/corelib/physics.c b/src/corelib/physics.c index bd41676..dab0b33 100644 --- a/src/corelib/physics.c +++ b/src/corelib/physics.c @@ -31,13 +31,13 @@ static inline int _rect_overlap(float aminx, float aminy, float amaxx, float amaxy, float bminx, float bminy, float bmaxx, float bmaxy) { return ( - (aminx < bmaxx && aminx > bmaxx) + (aminx < bmaxx && aminx > bminx) || - (amaxx > bminx && amaxx < bmaxx) + (bminx < amaxx && bminx > aminx) ) && ( - (aminy < bmaxy && aminy > bmaxy) + (aminy < bmaxy && aminy > bminy) || - (amaxy > bminy && amaxy < bmaxy) + (bminy < amaxy && bminy > aminy) ); } @@ -58,8 +58,10 @@ short _collision_aabb_aabb(const object_t* a, const object_t* b) { static inline short _collision_circle_circle(const object_t* a, const object_t* b) { - const float ax = a->sprite.x + a->physics.circle.x, ay = a->sprite.y + a->physics.circle.y, - bx = b->sprite.x + b->physics.circle.x, by = b->sprite.y + b->physics.circle.y; + const float ax = a->sprite.x + a->physics.circle.x, + ay = a->sprite.y + a->physics.circle.y, + bx = b->sprite.x + b->physics.circle.x, + by = b->sprite.y + b->physics.circle.y; const float dx = fabsf(ax-bx), dy = fabsf(ay-by); const float sqrdist = dx*dx+dy*dy; const float mindist = a->physics.circle.radius + b->physics.circle.radius;