FlattenNoise.cpp 476 B

12345678910111213141516171819202122232425
  1. #include "FlattenNoise.h"
  2. FlattenNoise::FlattenNoise(Noise* base, double factor, double minValue)
  3. : Noise(),
  4. base(base),
  5. factor(factor),
  6. minValue(minValue)
  7. {}
  8. FlattenNoise::~FlattenNoise()
  9. {
  10. base->release();
  11. }
  12. int FlattenNoise::getSeed() const
  13. {
  14. return base->getSeed();
  15. }
  16. double FlattenNoise::getNoise(double x, double y, double z)
  17. {
  18. return MAX(
  19. MIN((base->getNoise(x, y, z) - 0.5) * factor + 0.5 + minValue, 1.0),
  20. 0.0);
  21. }