OverworldDimension.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "OverworldDimension.h"
  2. #include "GrasslandBiom.h"
  3. #include "FastNoiseWrapper.h"
  4. #include "RandNoise.h"
  5. OverworldDimension::OverworldDimension()
  6. : DimensionGenerator(ID)
  7. {
  8. registerBiom(new GrasslandBiom(), 1.0);
  9. biomNoise = 0;
  10. structureNoise = 0;
  11. }
  12. OverworldDimension::~OverworldDimension()
  13. {
  14. if (biomNoise)
  15. biomNoise->release();
  16. if (structureNoise)
  17. structureNoise->release();
  18. }
  19. Noise* OverworldDimension::zBiomNoise(int seed)
  20. {
  21. if (biomNoise)
  22. return biomNoise;
  23. FastNoiseLite* noise = new FastNoiseLite(seed);
  24. noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_Cellular);
  25. noise->SetRotationType3D(FastNoiseLite::RotationType3D::RotationType3D_None);
  26. noise->SetFrequency(0.015f);
  27. noise->SetFractalType(FastNoiseLite::FractalType::FractalType_None);
  28. noise->SetCellularDistanceFunction(FastNoiseLite::CellularDistanceFunction::CellularDistanceFunction_Hybrid);
  29. noise->SetCellularReturnType(FastNoiseLite::CellularReturnType::CellularReturnType_CellValue);
  30. noise->SetCellularJitter(1.f);
  31. noise->SetDomainWarpType(FastNoiseLite::DomainWarpType::DomainWarpType_OpenSimplex2Reduced);
  32. noise->SetDomainWarpAmp(30.f);
  33. biomNoise = new FastNoiseWrapper(noise, seed);
  34. return biomNoise;
  35. }
  36. Noise* OverworldDimension::zStructureNoise(int seed)
  37. {
  38. if (structureNoise)
  39. return structureNoise;
  40. structureNoise = new RandNoise(seed);
  41. return structureNoise;
  42. }