mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-22 15:48:48 -05:00
Clean up Mapgen
This commit is contained in:
parent
eb90c3d92d
commit
d10223254a
2233
src/mapgen.cpp
2233
src/mapgen.cpp
File diff suppressed because it is too large
Load Diff
@ -72,6 +72,11 @@ public:
|
||||
int water_level;
|
||||
bool generating;
|
||||
int id;
|
||||
ManualMapVoxelManipulator *vm;
|
||||
INodeDefManager *ndef;
|
||||
|
||||
void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
|
||||
void updateLighting(v3s16 nmin, v3s16 nmax);
|
||||
|
||||
virtual void makeChunk(BlockMakeData *data) {};
|
||||
virtual int getGroundLevelAtPoint(v2s16 p) = 0;
|
||||
|
1636
src/mapgen_v6.cpp
1636
src/mapgen_v6.cpp
File diff suppressed because it is too large
Load Diff
@ -20,10 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#ifndef MAPGENV6_HEADER
|
||||
#define MAPGENV6_HEADER
|
||||
|
||||
#include "dungeongen.h"
|
||||
#include "mapgen.h"
|
||||
|
||||
#define AVERAGE_MUD_AMOUNT 4
|
||||
#define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
|
||||
|
||||
enum BiomeType
|
||||
{
|
||||
@ -74,13 +74,17 @@ struct MapgenV6Params : public MapgenParams {
|
||||
|
||||
class MapgenV6 : public Mapgen {
|
||||
public:
|
||||
//ManualMapVoxelManipulator &vmanip;
|
||||
|
||||
int ystride;
|
||||
v3s16 csize;
|
||||
u32 flags;
|
||||
|
||||
u32 blockseed;
|
||||
v3s16 node_min;
|
||||
v3s16 node_max;
|
||||
v3s16 full_node_min;
|
||||
v3s16 full_node_max;
|
||||
v3s16 central_area_size;
|
||||
int volume_nodes;
|
||||
|
||||
Noise *noise_terrain_base;
|
||||
Noise *noise_terrain_higher;
|
||||
@ -90,21 +94,20 @@ public:
|
||||
Noise *noise_mud;
|
||||
Noise *noise_beach;
|
||||
Noise *noise_biome;
|
||||
|
||||
float *map_terrain_base;
|
||||
float *map_terrain_higher;
|
||||
float *map_steepness;
|
||||
float *map_height_select;
|
||||
float *map_trees;
|
||||
float *map_mud;
|
||||
float *map_beach;
|
||||
float *map_biome;
|
||||
|
||||
NoiseParams *np_cave;
|
||||
|
||||
u32 flags;
|
||||
float freq_desert;
|
||||
float freq_beach;
|
||||
|
||||
content_t c_stone;
|
||||
content_t c_dirt;
|
||||
content_t c_dirt_with_grass;
|
||||
content_t c_sand;
|
||||
content_t c_water_source;
|
||||
content_t c_lava_source;
|
||||
content_t c_gravel;
|
||||
content_t c_cobble;
|
||||
content_t c_desert_sand;
|
||||
content_t c_desert_stone;
|
||||
|
||||
MapgenV6(int mapgenid, MapgenV6Params *params);
|
||||
~MapgenV6();
|
||||
@ -112,21 +115,37 @@ public:
|
||||
void makeChunk(BlockMakeData *data);
|
||||
int getGroundLevelAtPoint(v2s16 p);
|
||||
|
||||
double baseRockLevelFromNoise(v2s16 p);
|
||||
static s16 find_ground_level(VoxelManipulator &vmanip,
|
||||
v2s16 p2d, INodeDefManager *ndef);
|
||||
static s16 find_stone_level(VoxelManipulator &vmanip,
|
||||
v2s16 p2d, INodeDefManager *ndef);
|
||||
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
bool is_apple_tree, INodeDefManager *ndef);
|
||||
double tree_amount_2d(u64 seed, v2s16 p);
|
||||
float baseTerrainLevel(float terrain_base, float terrain_higher,
|
||||
float steepness, float height_select);
|
||||
float baseTerrainLevelFromNoise(v2s16 p);
|
||||
float baseTerrainLevelFromMap(v2s16 p);
|
||||
float baseTerrainLevelFromMap(int index);
|
||||
|
||||
s16 find_ground_level(v2s16 p2d);
|
||||
s16 find_stone_level(v2s16 p2d);
|
||||
bool block_is_underground(u64 seed, v3s16 blockpos);
|
||||
double base_rock_level_2d(u64 seed, v2s16 p);
|
||||
s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
||||
double get_mud_add_amount(u64 seed, v2s16 p);
|
||||
bool get_have_beach(u64 seed, v2s16 p2d);
|
||||
BiomeType get_biome(u64 seed, v2s16 p2d);
|
||||
|
||||
float getTreeAmount(v2s16 p);
|
||||
float getTreeAmount(int index);
|
||||
float getMudAmount(v2s16 p);
|
||||
float getMudAmount(int index);
|
||||
bool getHaveBeach(v2s16 p);
|
||||
bool getHaveBeach(int index);
|
||||
BiomeType getBiome(v2s16 p);
|
||||
BiomeType getBiome(int index, v2s16 p);
|
||||
|
||||
u32 get_blockseed(u64 seed, v3s16 p);
|
||||
|
||||
|
||||
void calculateNoise();
|
||||
int generateGround();
|
||||
void addMud();
|
||||
void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
|
||||
void addDirtGravelBlobs();
|
||||
void growGrass();
|
||||
void placeTrees();
|
||||
void generateCaves(int max_stone_y);
|
||||
};
|
||||
|
||||
struct MapgenFactoryV6 : public MapgenFactory {
|
||||
|
@ -28,15 +28,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
namespace treegen
|
||||
{
|
||||
|
||||
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
bool is_apple_tree, INodeDefManager *ndef,int seed)
|
||||
bool is_apple_tree, INodeDefManager *ndef, int seed)
|
||||
{
|
||||
MapNode treenode(ndef->getId("mapgen_tree"));
|
||||
MapNode leavesnode(ndef->getId("mapgen_leaves"));
|
||||
MapNode applenode(ndef->getId("mapgen_apple"));
|
||||
|
||||
PseudoRandom ps(seed);
|
||||
s16 trunk_h = ps.range(4, 5);
|
||||
PseudoRandom pr(seed);
|
||||
s16 trunk_h = pr.range(4, 5);
|
||||
v3s16 p1 = p0;
|
||||
for(s16 ii=0; ii<trunk_h; ii++)
|
||||
{
|
||||
@ -72,9 +73,9 @@ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
s16 d = 1;
|
||||
|
||||
v3s16 p(
|
||||
ps.range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
|
||||
ps.range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
|
||||
ps.range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
|
||||
pr.range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
|
||||
pr.range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
|
||||
pr.range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
|
||||
);
|
||||
|
||||
for(s16 z=0; z<=d; z++)
|
||||
@ -100,7 +101,7 @@ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
continue;
|
||||
u32 i = leaves_a.index(x,y,z);
|
||||
if(leaves_d[i] == 1) {
|
||||
bool is_apple = ps.range(0,99) < 10;
|
||||
bool is_apple = pr.range(0,99) < 10;
|
||||
if(is_apple_tree && is_apple) {
|
||||
vmanip.m_data[vi] = applenode;
|
||||
} else {
|
||||
@ -111,7 +112,7 @@ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
}
|
||||
|
||||
// L-System tree LUA spawner
|
||||
void spawn_ltree (ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef, TreeDef tree_definition)
|
||||
void spawn_ltree(ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef, TreeDef tree_definition)
|
||||
{
|
||||
ServerMap *map = &env->getServerMap();
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
@ -506,17 +507,17 @@ v3f transposeMatrix(irr::core::matrix4 M, v3f v)
|
||||
return translated;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
INodeDefManager *ndef)
|
||||
void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
INodeDefManager *ndef, int seed)
|
||||
{
|
||||
MapNode treenode(ndef->getId("mapgen_jungletree"));
|
||||
MapNode leavesnode(ndef->getId("mapgen_leaves"));
|
||||
|
||||
PseudoRandom pr(seed);
|
||||
for(s16 x=-1; x<=1; x++)
|
||||
for(s16 z=-1; z<=1; z++)
|
||||
{
|
||||
if(myrand_range(0, 2) == 0)
|
||||
if(pr.range(0, 2) == 0)
|
||||
continue;
|
||||
v3s16 p1 = p0 + v3s16(x,0,z);
|
||||
v3s16 p2 = p0 + v3s16(x,-1,z);
|
||||
@ -527,7 +528,7 @@ static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
|
||||
}
|
||||
|
||||
s16 trunk_h = myrand_range(8, 12);
|
||||
s16 trunk_h = pr.range(8, 12);
|
||||
v3s16 p1 = p0;
|
||||
for(s16 ii=0; ii<trunk_h; ii++)
|
||||
{
|
||||
@ -562,9 +563,9 @@ static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
s16 d = 1;
|
||||
|
||||
v3s16 p(
|
||||
myrand_range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
|
||||
myrand_range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
|
||||
myrand_range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
|
||||
pr.range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
|
||||
pr.range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
|
||||
pr.range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
|
||||
);
|
||||
|
||||
for(s16 z=0; z<=d; z++)
|
||||
@ -593,6 +594,5 @@ static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
vmanip.m_data[vi] = leavesnode;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}; // namespace treegen
|
||||
|
@ -27,33 +27,36 @@ class ManualMapVoxelManipulator;
|
||||
class INodeDefManager;
|
||||
|
||||
|
||||
namespace treegen
|
||||
{
|
||||
namespace treegen {
|
||||
|
||||
struct TreeDef
|
||||
{
|
||||
std::string initial_axiom;
|
||||
std::string rules_a;
|
||||
std::string rules_b;
|
||||
std::string rules_c;
|
||||
std::string rules_d;
|
||||
MapNode trunknode;
|
||||
MapNode leavesnode;
|
||||
MapNode leaves2node;
|
||||
int leaves2_chance;
|
||||
int angle;
|
||||
int iterations;
|
||||
int iterations_random_level;
|
||||
std::string trunk_type;
|
||||
bool thin_branches;
|
||||
MapNode fruitnode;
|
||||
int fruit_chance;
|
||||
int seed;
|
||||
};
|
||||
struct TreeDef {
|
||||
std::string initial_axiom;
|
||||
std::string rules_a;
|
||||
std::string rules_b;
|
||||
std::string rules_c;
|
||||
std::string rules_d;
|
||||
|
||||
MapNode trunknode;
|
||||
MapNode leavesnode;
|
||||
MapNode leaves2node;
|
||||
|
||||
int leaves2_chance;
|
||||
int angle;
|
||||
int iterations;
|
||||
int iterations_random_level;
|
||||
std::string trunk_type;
|
||||
bool thin_branches;
|
||||
MapNode fruitnode;
|
||||
int fruit_chance;
|
||||
int seed;
|
||||
};
|
||||
|
||||
// Add default tree
|
||||
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
|
||||
bool is_apple_tree, INodeDefManager *ndef,int seed);
|
||||
bool is_apple_tree, INodeDefManager *ndef, int seed);
|
||||
// Add jungle tree
|
||||
void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
|
||||
INodeDefManager *ndef, int seed);
|
||||
|
||||
// Add L-Systems tree (used by engine)
|
||||
void make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
|
||||
@ -73,7 +76,7 @@ int seed;
|
||||
PseudoRandom ps, TreeDef &tree_definition);
|
||||
void tree_fruit_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
|
||||
TreeDef &tree_definition);
|
||||
irr::core::matrix4 setRotationAxisRadians(irr::core::matrix4 M, double angle,v3f axis);
|
||||
irr::core::matrix4 setRotationAxisRadians(irr::core::matrix4 M, double angle, v3f axis);
|
||||
|
||||
v3f transposeMatrix(irr::core::matrix4 M ,v3f v);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user