reordered terms in _rect_overlap

pull/17/head
Sara 2023-07-16 21:14:44 +02:00
parent 0dc35bd9d9
commit 7950e45632
1 changed files with 8 additions and 6 deletions

View File

@ -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;