polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 2bd9a53e59878ce0cb35aa4b587be11cab29ed07
parent 69d38281d116861ba4501f8020f2ee7050a59539
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  3 May 2018 13:47:25 -0700

fix poisson disk sampling issue

Diffstat:
Msrc/poisson.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/poisson.c b/src/poisson.c @@ -231,8 +231,12 @@ poisson_disk_samples(const double point_dist, double size, for (size_t j = 0; j < ARRAY_SIZE(nearby); ++j) { int neari = nearby[j]; - assert(neari < cells); + if (neari < 0) + continue; struct point *near = &samples[neari]; + + assert(near); + double dx = near->x - candidate.x; double dy = near->y - candidate.y; double dist = sqrt(dx * dx + dy * dy);