n/basis: simplify fractional point extraction
This commit is contained in:
parent
50c1088918
commit
a03d407204
@ -51,10 +51,7 @@ namespace util { namespace noise { namespace basis {
|
||||
patch<T>::operator () (point2<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<intmax_t> ();
|
||||
if (p.x < 0) p_int.x -= 1;
|
||||
if (p.y < 0) p_int.y -= 1;
|
||||
auto p_int = floor (p).template cast<intmax_t> ();
|
||||
auto p_rem = (p - p_int).template as<point> ();
|
||||
|
||||
static const util::vector2i OFFSETS[] = {
|
||||
|
@ -47,10 +47,7 @@ namespace util { namespace noise { namespace basis {
|
||||
perlin<T,L,G>::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<intmax_t> ();
|
||||
if (p.x < 0) p_int.x -= 1;
|
||||
if (p.y < 0) p_int.y -= 1;
|
||||
auto p_int = floor (p).template cast<intmax_t> ();
|
||||
auto p_rem = p - p_int;
|
||||
|
||||
// generate the corner positions
|
||||
|
@ -62,10 +62,7 @@ namespace util { namespace noise { namespace basis {
|
||||
value<T,L>::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<intmax_t> ();
|
||||
if (p.x < 0) p_int.x -= 1;
|
||||
if (p.y < 0) p_int.y -= 1;
|
||||
auto p_int = floor (p).template cast<intmax_t> ();
|
||||
auto p_rem = p - p_int;
|
||||
|
||||
// generate the corner points
|
||||
|
@ -64,10 +64,7 @@ namespace util { namespace noise { namespace basis {
|
||||
worley<T,F>::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<intmax_t> ();
|
||||
if (p.x < 0) p_int.x -= 1;
|
||||
if (p.y < 0) p_int.y -= 1;
|
||||
auto p_int = floor (p).template cast<intmax_t> ();
|
||||
auto p_rem = (p - p_int).template as<point> ();
|
||||
|
||||
// setup an array of distances
|
||||
|
Loading…
Reference in New Issue
Block a user