You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

noise.cpp 557B

123456789101112131415161718192021222324252627282930313233
  1. #include "terrain/noise.h"
  2. namespace vtk { namespace noise {
  3. Noise::Noise(const int64_t& seed) {
  4. mScale = 32.0;
  5. open_simplex_noise(seed, &mCtx);
  6. }
  7. Noise::~Noise() {
  8. open_simplex_noise_free(mCtx);
  9. }
  10. double Noise::get2D(const double& x, const double& y) {
  11. return open_simplex_noise2(mCtx,
  12. x / mScale,
  13. y / mScale);
  14. }
  15. double Noise::get3D(const double& x, const double& y, const double& z) {
  16. return open_simplex_noise3(mCtx,
  17. x / mScale,
  18. y / mScale,
  19. z / mScale);
  20. }
  21. void Noise::setScale(const double& scale) {
  22. mScale = scale;
  23. }
  24. }}