OverworldDimension.cpp 1.4 KB

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