From: Joshua Grams Date: Mon, 11 Jul 2005 18:39:39 +0000 (+0000) Subject: oops, have to check all 9 buckets. X-Git-Tag: 0.4~39 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=2b5dd5bc0eb1739dd744de6f565d0f3a7ae02c95 oops, have to check all 9 buckets. maybe I should consider doing the 4 resort/check cycles instead... --- diff --git a/rocks.c b/rocks.c index e098fa0..f68a57a 100644 --- a/rocks.c +++ b/rocks.c @@ -301,8 +301,18 @@ hit_rocks(float x, float y, struct shape *shape) int bdx = ((int)x+shape->w)/grid_size - (int)x/grid_size; int bdy = ((int)y+shape->h)/grid_size - (int)y/grid_size; if(hit_in_bucket(b, x, y, shape)) return 1; - if(bdx && hit_in_bucket(b+1, x, y, shape)) return 1; - if(bdy && hit_in_bucket(b+bw, x, y, shape)) return 1; + if(hit_in_bucket(b-1, x, y, shape)) return 1; + if(hit_in_bucket(b-bw, x, y, shape)) return 1; + if(hit_in_bucket(b-bw-1, x, y, shape)) return 1; + + if(bdx) { + if(hit_in_bucket(b+1, x, y, shape)) return 1; + if(hit_in_bucket(b+1-bw, x, y, shape)) return 1; + } + if(bdy) { + if(hit_in_bucket(b+bw, x, y, shape)) return 1; + if(hit_in_bucket(b+bw-1, x, y, shape)) return 1; + } if(bdx && bdy && hit_in_bucket(b+bw+1, x, y, shape)) return 1; return 0; } diff --git a/shape.c b/shape.c index 92729e9..75424ef 100644 --- a/shape.c +++ b/shape.c @@ -116,6 +116,6 @@ pixel_collide(unsigned int xoff, unsigned int yoff, struct shape *r) if(xoff >= r->w || yoff >= r->h) return 0; - pmask = 1 << (32 - (xoff&0x1f)); + pmask = 0x80000000 >> (xoff&0x1f); return r->mask[(yoff*r->mw) + (xoff>>5)] & pmask; }