3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef CAVEGEN_HEADER
21 #define CAVEGEN_HEADER
23 #define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
24 #define DEFAULT_LAVA_DEPTH (-256)
26 class GenerateNotifier;
28 class CavesRandomWalk {
32 INodeDefManager *ndef;
37 NoiseParams *np_caveliquids;
39 s16 min_tunnel_diameter;
40 s16 max_tunnel_diameter;
41 u16 tunnel_routepoints;
43 int part_max_length_rs;
45 bool large_cave_is_flat;
52 v3f orp; // starting point, relative to caved space
53 v3s16 of; // absolute coordinates of caved space
54 v3s16 ar; // allowed route area
55 s16 rs; // tunnel radius size
63 content_t c_water_source;
64 content_t c_lava_source;
70 CavesRandomWalk(Mapgen *mg, PseudoRandom *ps);
71 void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
72 void makeTunnel(bool dirswitch);
73 void carveRoute(v3f vec, float f, bool randomize_xz);
76 inline bool isPosAboveSurface(v3s16 p);
80 CavesV6 is the original version of caves used with Mapgen V6.
82 Though it uses the same fundamental algorithm as CavesRandomWalk, it is made
83 separate to preserve the exact sequence of PseudoRandom calls - any change
84 to this ordering results in the output being radically different.
85 Because caves in Mapgen V6 are responsible for a large portion of the basic
86 terrain shape, modifying this will break our contract of reverse
87 compatibility for a 'stable' mapgen such as V6.
90 *** DO NOT TOUCH THIS CLASS UNLESS YOU KNOW WHAT YOU ARE DOING ***
95 INodeDefManager *ndef;
96 GenerateNotifier *gennotify;
101 content_t c_water_source;
102 content_t c_lava_source;
107 s16 min_tunnel_diameter;
108 s16 max_tunnel_diameter;
109 u16 tunnel_routepoints;
111 int part_max_length_rs;
114 bool large_cave_is_flat;
119 v3f orp; // starting point, relative to caved space
120 v3s16 of; // absolute coordinates of caved space
121 v3s16 ar; // allowed route area
122 s16 rs; // tunnel radius size
128 // ndef is a mandatory parameter.
129 // If gennotify is NULL, generation events are not logged.
130 CavesV6(INodeDefManager *ndef,
131 GenerateNotifier *gennotify = NULL,
133 content_t water_source = CONTENT_IGNORE,
134 content_t lava_source = CONTENT_IGNORE);
136 // vm, ps, and ps2 are mandatory parameters.
137 // If heightmap is NULL, the surface level at all points is assumed to
139 void makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax,
140 PseudoRandom *ps, PseudoRandom *ps2,
141 bool is_large_cave, int max_stone_height, s16 *heightmap = NULL);
144 void makeTunnel(bool dirswitch);
145 void carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground);
147 inline s16 getSurfaceFromHeightmap(v3s16 p);