ShapedNoise.cpp 761 B

12345678910111213141516171819202122232425262728293031
  1. #include "ShapedNoise.h"
  2. ShapedNoise::ShapedNoise(Noise* delegateNoise)
  3. : delegateNoise(delegateNoise),
  4. neighborOffset(1)
  5. {}
  6. ShapedNoise ::~ShapedNoise()
  7. {
  8. delegateNoise->release();
  9. }
  10. void ShapedNoise::setNeighborOffset(double offset)
  11. {
  12. neighborOffset = offset;
  13. }
  14. double ShapedNoise::getNoise(double x, double y, double z)
  15. {
  16. double max = 0;
  17. double noise = delegateNoise->getNoise(x, y, z);
  18. max = MAX(max, abs(noise - delegateNoise->getNoise(x + neighborOffset, y, z)));
  19. max = MAX(max, abs(noise - delegateNoise->getNoise(x, y + neighborOffset, z)));
  20. max = MAX(max, abs(noise - delegateNoise->getNoise(x, y, z + neighborOffset)));
  21. return max;
  22. }
  23. int ShapedNoise::getSeed() const
  24. {
  25. return delegateNoise->getSeed();
  26. }