FastNoiseWrapper.cpp 620 B

12345678910111213141516171819202122232425262728293031
  1. #include "FastNoiseWrapper.h"
  2. FastNoiseWrapper::FastNoiseWrapper(FastNoiseLite* noise, int seed)
  3. {
  4. this->noise = noise;
  5. this->seed = seed;
  6. this->multiplier = 1.f;
  7. }
  8. FastNoiseWrapper::~FastNoiseWrapper()
  9. {
  10. delete noise;
  11. }
  12. void FastNoiseWrapper::setMultiplier(float multiplier)
  13. {
  14. assert(multiplier > 0);
  15. this->multiplier = multiplier;
  16. }
  17. int FastNoiseWrapper::getSeed() const
  18. {
  19. return seed;
  20. }
  21. double FastNoiseWrapper::getNoise(double x, double y, double z)
  22. {
  23. // scale the noise from 0 to 1
  24. return (noise->GetNoise(x * multiplier, y * multiplier, z * multiplier) + 1)
  25. / 2;
  26. }