2016-01-14 04:57:02 +01:00
|
|
|
/*
|
|
|
|
Minetest Valleys C
|
|
|
|
Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
|
|
|
|
Copyright (C) 2010-2015 paramat, Matt Gregory
|
|
|
|
Copyright (C) 2016 Duane Robertson <duane@duanerobertson.com>
|
|
|
|
|
|
|
|
Based on Valleys Mapgen by Gael de Sailly
|
|
|
|
(https://forum.minetest.net/viewtopic.php?f=9&t=11430)
|
|
|
|
and mapgen_v7 by kwolekr and paramat.
|
|
|
|
|
|
|
|
Licensing changed by permission of Gael de Sailly.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MAPGEN_VALLEYS_HEADER
|
|
|
|
#define MAPGEN_VALLEYS_HEADER
|
|
|
|
|
|
|
|
#include "mapgen.h"
|
|
|
|
|
2016-02-04 02:03:31 +01:00
|
|
|
////////////// Mapgen Valleys flags
|
|
|
|
#define MGVALLEYS_ALT_CHILL 0x01
|
|
|
|
#define MGVALLEYS_HUMID_RIVERS 0x02
|
2016-01-31 09:59:15 +01:00
|
|
|
|
|
|
|
// Feed only one variable into these.
|
|
|
|
#define MYSQUARE(x) (x) * (x)
|
|
|
|
#define MYCUBE(x) (x) * (x) * (x)
|
2016-01-14 04:57:02 +01:00
|
|
|
|
|
|
|
class BiomeManager;
|
2016-04-28 09:43:09 +02:00
|
|
|
class BiomeGenOriginal;
|
2016-01-14 04:57:02 +01:00
|
|
|
|
|
|
|
// Global profiler
|
|
|
|
//class Profiler;
|
|
|
|
//extern Profiler *mapgen_profiler;
|
|
|
|
|
|
|
|
|
2016-06-25 00:15:56 +02:00
|
|
|
struct MapgenValleysParams : public MapgenParams {
|
2016-01-14 04:57:02 +01:00
|
|
|
u32 spflags;
|
2016-01-31 09:59:15 +01:00
|
|
|
s16 large_cave_depth;
|
|
|
|
s16 massive_cave_depth;
|
2016-01-14 04:57:02 +01:00
|
|
|
u16 altitude_chill;
|
2016-01-31 09:59:15 +01:00
|
|
|
u16 lava_features;
|
2016-01-14 04:57:02 +01:00
|
|
|
u16 river_depth;
|
|
|
|
u16 river_size;
|
|
|
|
u16 water_features;
|
2016-04-25 12:47:25 +02:00
|
|
|
float cave_width;
|
2016-01-31 09:59:15 +01:00
|
|
|
NoiseParams np_cave1;
|
|
|
|
NoiseParams np_cave2;
|
2016-01-14 04:57:02 +01:00
|
|
|
NoiseParams np_filler_depth;
|
|
|
|
NoiseParams np_inter_valley_fill;
|
|
|
|
NoiseParams np_inter_valley_slope;
|
|
|
|
NoiseParams np_rivers;
|
2016-01-31 09:59:15 +01:00
|
|
|
NoiseParams np_massive_caves;
|
2016-01-14 04:57:02 +01:00
|
|
|
NoiseParams np_terrain_height;
|
|
|
|
NoiseParams np_valley_depth;
|
|
|
|
NoiseParams np_valley_profile;
|
|
|
|
|
|
|
|
MapgenValleysParams();
|
|
|
|
~MapgenValleysParams() {}
|
|
|
|
|
|
|
|
void readParams(const Settings *settings);
|
|
|
|
void writeParams(Settings *settings) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TerrainNoise {
|
2016-01-16 10:53:02 +01:00
|
|
|
s16 x;
|
|
|
|
s16 z;
|
|
|
|
float terrain_height;
|
|
|
|
float *rivers;
|
|
|
|
float *valley;
|
|
|
|
float valley_profile;
|
|
|
|
float *slope;
|
|
|
|
float inter_valley_fill;
|
2016-01-14 04:57:02 +01:00
|
|
|
};
|
|
|
|
|
2016-05-02 08:24:57 +02:00
|
|
|
class MapgenValleys : public MapgenBasic {
|
2016-01-14 04:57:02 +01:00
|
|
|
public:
|
|
|
|
|
2016-06-25 00:15:56 +02:00
|
|
|
MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeManager *emerge);
|
2016-01-14 04:57:02 +01:00
|
|
|
~MapgenValleys();
|
|
|
|
|
2016-06-14 06:10:55 +02:00
|
|
|
virtual MapgenType getType() const { return MAPGEN_VALLEYS; }
|
|
|
|
|
2016-01-14 04:57:02 +01:00
|
|
|
virtual void makeChunk(BlockMakeData *data);
|
2016-02-04 02:03:31 +01:00
|
|
|
int getSpawnLevelAtPoint(v2s16 p);
|
2016-01-14 04:57:02 +01:00
|
|
|
|
2016-01-31 09:59:15 +01:00
|
|
|
s16 large_cave_depth;
|
|
|
|
|
2016-01-14 04:57:02 +01:00
|
|
|
private:
|
2016-04-28 09:43:09 +02:00
|
|
|
BiomeGenOriginal *m_bgen;
|
2016-01-14 04:57:02 +01:00
|
|
|
|
2016-01-31 09:59:15 +01:00
|
|
|
float map_gen_limit;
|
|
|
|
|
2016-01-14 04:57:02 +01:00
|
|
|
bool humid_rivers;
|
|
|
|
bool use_altitude_chill;
|
2016-04-25 12:47:25 +02:00
|
|
|
float humidity_adjust;
|
|
|
|
s16 cave_water_max_height;
|
|
|
|
s16 lava_max_height;
|
2016-01-14 04:57:02 +01:00
|
|
|
|
2016-04-25 12:47:25 +02:00
|
|
|
float altitude_chill;
|
|
|
|
s16 lava_features_lim;
|
|
|
|
s16 massive_cave_depth;
|
|
|
|
float river_depth_bed;
|
|
|
|
float river_size_factor;
|
|
|
|
float *tcave_cache;
|
|
|
|
s16 water_features_lim;
|
2016-01-14 04:57:02 +01:00
|
|
|
Noise *noise_inter_valley_fill;
|
|
|
|
Noise *noise_inter_valley_slope;
|
|
|
|
Noise *noise_rivers;
|
2016-05-19 09:40:22 +02:00
|
|
|
Noise *noise_cave1;
|
|
|
|
Noise *noise_cave2;
|
2016-01-31 09:59:15 +01:00
|
|
|
Noise *noise_massive_caves;
|
2016-01-14 04:57:02 +01:00
|
|
|
Noise *noise_terrain_height;
|
|
|
|
Noise *noise_valley_depth;
|
|
|
|
Noise *noise_valley_profile;
|
|
|
|
|
|
|
|
content_t c_lava_source;
|
|
|
|
|
|
|
|
float terrainLevelAtPoint(s16 x, s16 z);
|
|
|
|
|
|
|
|
void calculateNoise();
|
|
|
|
|
|
|
|
virtual int generateTerrain();
|
|
|
|
float terrainLevelFromNoise(TerrainNoise *tn);
|
|
|
|
float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
|
|
|
|
|
2016-05-02 08:24:57 +02:00
|
|
|
virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
|
2016-01-14 04:57:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|