diff --git a/noise/basis/patch.ipp b/noise/basis/patch.ipp index 86122df0..5136697b 100644 --- a/noise/basis/patch.ipp +++ b/noise/basis/patch.ipp @@ -51,10 +51,7 @@ namespace util { namespace noise { namespace basis { patch::operator () (point2 p) const { // extract integer and fractional parts. be careful to always round down - // (particularly with negatives) and avoid rounding errors. - auto p_int = p.template cast (); - if (p.x < 0) p_int.x -= 1; - if (p.y < 0) p_int.y -= 1; + auto p_int = floor (p).template cast (); auto p_rem = (p - p_int).template as (); static const util::vector2i OFFSETS[] = { diff --git a/noise/basis/perlin.ipp b/noise/basis/perlin.ipp index 1f38e667..ebbfc43b 100644 --- a/noise/basis/perlin.ipp +++ b/noise/basis/perlin.ipp @@ -47,10 +47,7 @@ namespace util { namespace noise { namespace basis { perlin::operator() (util::point<2,T> p) const { // extract integer and fractional parts. be careful to always round down - // (particularly with negatives) and avoid rounding errors. - auto p_int = p.template cast (); - if (p.x < 0) p_int.x -= 1; - if (p.y < 0) p_int.y -= 1; + auto p_int = floor (p).template cast (); auto p_rem = p - p_int; // generate the corner positions diff --git a/noise/basis/value.ipp b/noise/basis/value.ipp index 8f867c7f..4c2f3786 100644 --- a/noise/basis/value.ipp +++ b/noise/basis/value.ipp @@ -62,10 +62,7 @@ namespace util { namespace noise { namespace basis { value::operator() (util::point<2,T> p) const { // extract integer and fractional parts. be careful to always round down - // (particularly with negatives) and avoid rounding errors. - auto p_int = p.template cast (); - if (p.x < 0) p_int.x -= 1; - if (p.y < 0) p_int.y -= 1; + auto p_int = floor (p).template cast (); auto p_rem = p - p_int; // generate the corner points diff --git a/noise/basis/worley.ipp b/noise/basis/worley.ipp index 451082af..e16e991b 100644 --- a/noise/basis/worley.ipp +++ b/noise/basis/worley.ipp @@ -64,10 +64,7 @@ namespace util { namespace noise { namespace basis { worley::operator() (util::point<2,T> p) const { // extract integer and fractional parts. be careful to always round down - // (particularly with negatives) and avoid rounding errors. - auto p_int = p.template cast (); - if (p.x < 0) p_int.x -= 1; - if (p.y < 0) p_int.y -= 1; + auto p_int = floor (p).template cast (); auto p_rem = (p - p_int).template as (); // setup an array of distances