mapgen_valleys.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. Minetest Valleys C
  3. Copyright (C) 2016-2017 Duane Robertson <duane@duanerobertson.com>
  4. Copyright (C) 2016-2017 paramat
  5. Based on Valleys Mapgen by Gael de Sailly
  6. (https://forum.minetest.net/viewtopic.php?f=9&t=11430)
  7. and mapgen_v7 by kwolekr and paramat.
  8. Licensing changed by permission of Gael de Sailly.
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU Lesser General Public License as published by
  11. the Free Software Foundation; either version 2.1 of the License, or
  12. (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU Lesser General Public License for more details.
  17. You should have received a copy of the GNU Lesser General Public License along
  18. with this program; if not, write to the Free Software Foundation, Inc.,
  19. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. */
  21. #ifndef MAPGEN_VALLEYS_HEADER
  22. #define MAPGEN_VALLEYS_HEADER
  23. #include "mapgen.h"
  24. ////////////// Mapgen Valleys flags
  25. #define MGVALLEYS_ALT_CHILL 0x01
  26. #define MGVALLEYS_HUMID_RIVERS 0x02
  27. // Feed only one variable into these.
  28. #define MYSQUARE(x) (x) * (x)
  29. #define MYCUBE(x) (x) * (x) * (x)
  30. class BiomeManager;
  31. class BiomeGenOriginal;
  32. // Global profiler
  33. //class Profiler;
  34. //extern Profiler *mapgen_profiler;
  35. struct MapgenValleysParams : public MapgenParams {
  36. u32 spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
  37. s16 large_cave_depth = -33;
  38. s16 massive_cave_depth = -256; // highest altitude of massive caves
  39. u16 altitude_chill = 90; // The altitude at which temperature drops by 20C.
  40. u16 lava_features = 0; // How often water will occur in caves.
  41. u16 river_depth = 4; // How deep to carve river channels.
  42. u16 river_size = 5; // How wide to make rivers.
  43. u16 water_features = 0; // How often water will occur in caves.
  44. float cave_width = 0.09f;
  45. NoiseParams np_cave1;
  46. NoiseParams np_cave2;
  47. NoiseParams np_filler_depth;
  48. NoiseParams np_inter_valley_fill;
  49. NoiseParams np_inter_valley_slope;
  50. NoiseParams np_rivers;
  51. NoiseParams np_massive_caves;
  52. NoiseParams np_terrain_height;
  53. NoiseParams np_valley_depth;
  54. NoiseParams np_valley_profile;
  55. MapgenValleysParams();
  56. ~MapgenValleysParams() {}
  57. void readParams(const Settings *settings);
  58. void writeParams(Settings *settings) const;
  59. };
  60. struct TerrainNoise {
  61. s16 x;
  62. s16 z;
  63. float terrain_height;
  64. float *rivers;
  65. float *valley;
  66. float valley_profile;
  67. float *slope;
  68. float inter_valley_fill;
  69. };
  70. class MapgenValleys : public MapgenBasic {
  71. public:
  72. MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeManager *emerge);
  73. ~MapgenValleys();
  74. virtual MapgenType getType() const { return MAPGEN_VALLEYS; }
  75. virtual void makeChunk(BlockMakeData *data);
  76. int getSpawnLevelAtPoint(v2s16 p);
  77. s16 large_cave_depth;
  78. private:
  79. BiomeGenOriginal *m_bgen;
  80. bool humid_rivers;
  81. bool use_altitude_chill;
  82. float humidity_adjust;
  83. s16 cave_water_max_height;
  84. s16 lava_max_height;
  85. float altitude_chill;
  86. s16 lava_features_lim;
  87. s16 massive_cave_depth;
  88. float river_depth_bed;
  89. float river_size_factor;
  90. float *tcave_cache;
  91. s16 water_features_lim;
  92. Noise *noise_inter_valley_fill;
  93. Noise *noise_inter_valley_slope;
  94. Noise *noise_rivers;
  95. Noise *noise_cave1;
  96. Noise *noise_cave2;
  97. Noise *noise_massive_caves;
  98. Noise *noise_terrain_height;
  99. Noise *noise_valley_depth;
  100. Noise *noise_valley_profile;
  101. float terrainLevelAtPoint(s16 x, s16 z);
  102. void calculateNoise();
  103. virtual int generateTerrain();
  104. float terrainLevelFromNoise(TerrainNoise *tn);
  105. float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
  106. virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
  107. };
  108. #endif