Browse Source

simplex_interpolator: bug fix on negative values.

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
a815a788e6
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      src/lol/math/simplex_interpolator.h
  2. +2
    -2
      src/t/math/simplex_interpolator.cpp

+ 1
- 1
src/lol/math/simplex_interpolator.h View File

@@ -117,7 +117,7 @@ protected:
{ {
// Finding floor point index // Finding floor point index
for (int i = 0 ; i < N ; ++i) for (int i = 0 ; i < N ; ++i)
floor_point[i] = (int) simplex_position[i];
floor_point[i] = ((int) simplex_position[i]) - (simplex_position[i] < 0 ? 1 : 0);


// Extracting decimal part from simplex sample // Extracting decimal part from simplex sample
for (int i = 0 ; i < N ; ++i) for (int i = 0 ; i < N ; ++i)


+ 2
- 2
src/t/math/simplex_interpolator.cpp View File

@@ -226,9 +226,9 @@ lolunit_declare_fixture(SimplexInterpolatorTest)
s.SetGradients(gradients); s.SetGradients(gradients);


std::cout << std::endl; std::cout << std::endl;
for (int i = 0 ; i < 32 ; ++i)
for (int i = -64 ; i < 64 ; ++i)
{ {
for (int j = 0 ; j < 32 ; ++j)
for (int j = -64 ; j < 64 ; ++j)
{ {
std::cout << s.Interp(vec_t<float, 2>({i * 0.1f, j * 0.1f})) << ", "; std::cout << s.Interp(vec_t<float, 2>({i * 0.1f, j * 0.1f})) << ", ";
} }


Loading…
Cancel
Save