Readded and optimized mapgen V6
parent
bddd5f2b98
commit
d5029958b9
|
@ -1587,7 +1587,7 @@ minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
|||
minetest.register_alias("mapgen_mese", "default:mese")
|
||||
|
||||
minetest.register_biome_groups({
|
||||
0.35, 0.30, 0.20
|
||||
0.35, 0.10, 0.30
|
||||
})
|
||||
|
||||
--
|
||||
|
@ -1619,7 +1619,7 @@ minetest.register_biome({
|
|||
num_top_nodes = 5,
|
||||
height_min = -3000,
|
||||
height_max = 3000,
|
||||
heat_min = 60.0,
|
||||
heat_min = 5.0,
|
||||
heat_max = 100.0,
|
||||
humidity_min = 0.0,
|
||||
humidity_max = 100.0,
|
||||
|
@ -1627,6 +1627,23 @@ minetest.register_biome({
|
|||
offset = 5.0,
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
group_id = 1,
|
||||
name = "Gravel Beach",
|
||||
terrain_type = "normal",
|
||||
node_top = "default:gravel",
|
||||
node_filler = "default:cobble",
|
||||
num_top_nodes = 5,
|
||||
height_min = -3000,
|
||||
height_max = 3000,
|
||||
heat_min = -50.0,
|
||||
heat_max = 5.0,
|
||||
humidity_min = 0.0,
|
||||
humidity_max = 100.0,
|
||||
scale = 5.0,
|
||||
offset = 5.0,
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
group_id = 2,
|
||||
name = "Land",
|
||||
|
@ -1641,7 +1658,7 @@ minetest.register_biome({
|
|||
humidity_min = 0.0,
|
||||
humidity_max = 100.0,
|
||||
scale = 12.0,
|
||||
offset = 10.0,
|
||||
offset = 20.0,
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
|
@ -1657,8 +1674,8 @@ minetest.register_biome({
|
|||
heat_max = 100.0,
|
||||
humidity_min = 0.0,
|
||||
humidity_max = 100.0,
|
||||
scale = 70.0,
|
||||
offset = 30.0,
|
||||
scale = 60.0,
|
||||
offset = 20.0,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ set(common_SRCS
|
|||
log.cpp
|
||||
content_sao.cpp
|
||||
mapgen.cpp
|
||||
mapgen_v6.cpp
|
||||
treegen.cpp
|
||||
content_nodemeta.cpp
|
||||
content_mapnode.cpp
|
||||
|
|
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "biome.h"
|
||||
#include "nodedef.h"
|
||||
#include "map.h" //for ManualMapVoxelManipulator
|
||||
#include "log.h"
|
||||
#include "main.h"
|
||||
|
||||
#define BT_NONE 0
|
||||
|
@ -64,15 +65,15 @@ int bg4_biomes[] = {BT_HILLS, BT_EXTREMEHILLS, BT_MOUNTAINS, BT_DESERT, BT_DESE
|
|||
float bg5_temps[] = {5.0, 40.0};
|
||||
int bg5_biomes[] = {BT_LAKE, BT_PLAINS, BT_DESERT};*/
|
||||
|
||||
NoiseParams np_default = {0.0, 20.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
||||
NoiseParams np_default = {20.0, 15.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
||||
|
||||
|
||||
BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
|
||||
this->m_gamedef = gamedef;
|
||||
this->ndef = gamedef->ndef();
|
||||
|
||||
bgroups.push_back(new std::vector<Biome *>); //the initial biome group
|
||||
//addDefaultBiomes(); //can't do this in the ctor, too early
|
||||
//the initial biome group
|
||||
bgroups.push_back(new std::vector<Biome *>);
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,20 +107,26 @@ void BiomeDefManager::addBiomeGroup(float freq) {
|
|||
newfreq += bgroup_freqs[size - 1];
|
||||
bgroup_freqs.push_back(newfreq);
|
||||
bgroups.push_back(new std::vector<Biome *>);
|
||||
printf("added biome with freq %f\n", newfreq);
|
||||
|
||||
verbosestream << "BiomeDefManager: added biome group with frequency " <<
|
||||
newfreq << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void BiomeDefManager::addBiome(int groupid, Biome *b) {
|
||||
void BiomeDefManager::addBiome(Biome *b) {
|
||||
std::vector<Biome *> *bgroup;
|
||||
|
||||
if (groupid >= bgroups.size()) {
|
||||
printf("blahblahblah");
|
||||
if (b->groupid >= bgroups.size()) {
|
||||
errorstream << "BiomeDefManager: attempted to add biome '" << b->name
|
||||
<< "' to nonexistent biome group " << b->groupid << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
bgroup = bgroups[groupid];
|
||||
bgroup = bgroups[b->groupid];
|
||||
bgroup->push_back(b);
|
||||
|
||||
verbosestream << "BiomeDefManager: added biome '" << b->name <<
|
||||
"' to biome group " << b->groupid << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +163,7 @@ Biome *BiomeDefManager::getBiome(float bgfreq, float heat, float humidity) {
|
|||
|
||||
int nbiomes = bgroup->size();
|
||||
for (i = 0; i != nbiomes; i++) {
|
||||
b = bgroup->operator[](i);///////////////////////////
|
||||
b = bgroup->operator[](i);
|
||||
if (heat >= b->heat_min && heat <= b->heat_max &&
|
||||
humidity >= b->humidity_min && humidity <= b->humidity_max)
|
||||
return b;
|
||||
|
@ -174,9 +181,24 @@ int Biome::getSurfaceHeight(float noise_terrain) {
|
|||
}
|
||||
|
||||
|
||||
void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||
void Biome::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
||||
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
||||
|
||||
/*///experimental
|
||||
if (groupid > 0) {
|
||||
float prevfreq = mg->biomedef->bgroup_freqs[groupid - 1];
|
||||
float range = mg->biomedef->bgroup_freqs[groupid] - prevfreq;
|
||||
float factor = (mg->map_bgroup[i] - prevfreq) / range;
|
||||
|
||||
std::vector<Biome *> *bg = mg->biomedef->bgroups[groupid - 1];
|
||||
Biome *b = (*bg)[0];
|
||||
int h1 = b->np->offset + b->np->scale * mg->map_terrain[i];
|
||||
surfaceh += (int)round((surfaceh - h1) * factor);
|
||||
//printf("h1: %d, surfaceh: %d, factor %f\n", h1, surfaceh, factor);
|
||||
}*/
|
||||
|
||||
|
||||
int y = y1;
|
||||
|
||||
i = mg->vmanip->m_area.index(x, y, z);
|
||||
|
@ -189,12 +211,10 @@ void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////// [ Ocean biome ] /////////////////////////////////
|
||||
|
||||
|
||||
|
||||
void BiomeLiquid::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||
void BiomeLiquid::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
||||
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
||||
int y = y1;
|
||||
|
@ -219,7 +239,7 @@ int BiomeHell::getSurfaceHeight(float noise_terrain) {
|
|||
}
|
||||
|
||||
|
||||
void BiomeHell::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||
void BiomeHell::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -232,7 +252,7 @@ int BiomeAether::getSurfaceHeight(float noise_terrain) {
|
|||
}
|
||||
|
||||
|
||||
void BiomeAether::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||
void BiomeAether::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -245,6 +265,15 @@ int BiomeSuperflat::getSurfaceHeight(float noise_terrain) {
|
|||
}
|
||||
|
||||
|
||||
void BiomeSuperflat::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||
void BiomeSuperflat::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||
int surfaceh = ntopnodes;
|
||||
int y = y1;
|
||||
|
||||
int i = mg->vmanip->m_area.index(x, y, z);
|
||||
for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
||||
mg->vmanip->m_data[i] = n_filler;
|
||||
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
||||
mg->vmanip->m_data[i] = n_top;
|
||||
for (; y <= y2; y++, i += mg->ystride)
|
||||
mg->vmanip->m_data[i] = mg->n_air;
|
||||
}
|
||||
|
|
15
src/biome.h
15
src/biome.h
|
@ -42,7 +42,8 @@ public:
|
|||
MapNode n_top;
|
||||
MapNode n_filler;
|
||||
s16 ntopnodes;
|
||||
s16 flags;
|
||||
s8 groupid;
|
||||
s8 flags;
|
||||
s16 height_min;
|
||||
s16 height_max;
|
||||
float heat_min;
|
||||
|
@ -52,26 +53,26 @@ public:
|
|||
std::string name;
|
||||
NoiseParams *np;
|
||||
|
||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||
virtual int getSurfaceHeight(float noise_terrain);
|
||||
};
|
||||
|
||||
class BiomeLiquid : public Biome {
|
||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||
};
|
||||
|
||||
class BiomeHell : public Biome {
|
||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||
virtual int getSurfaceHeight(float noise_terrain);
|
||||
};
|
||||
|
||||
class BiomeAether : public Biome {
|
||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||
virtual int getSurfaceHeight(float noise_terrain);
|
||||
};
|
||||
|
||||
class BiomeSuperflat : public Biome {
|
||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||
virtual int getSurfaceHeight(float noise_terrain);
|
||||
};
|
||||
|
||||
|
@ -90,7 +91,7 @@ public:
|
|||
Biome *getBiome(float bgfreq, float heat, float humidity);
|
||||
|
||||
void addBiomeGroup(float freq);
|
||||
void addBiome(int groupid, Biome *b);
|
||||
void addBiome(Biome *b);
|
||||
void addDefaultBiomes();
|
||||
};
|
||||
|
||||
|
|
|
@ -153,6 +153,7 @@ void set_default_settings(Settings *settings)
|
|||
|
||||
settings->setDefault("profiler_print_interval", "0");
|
||||
settings->setDefault("enable_mapgen_debug_info", "false");
|
||||
settings->setDefault("use_mapgen_version", "6");
|
||||
settings->setDefault("active_object_send_range_blocks", "3");
|
||||
settings->setDefault("active_block_range", "2");
|
||||
//settings->setDefault("max_simultaneous_block_sends_per_client", "1");
|
||||
|
@ -169,6 +170,7 @@ void set_default_settings(Settings *settings)
|
|||
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
|
||||
settings->setDefault("dedicated_server_step", "0.1");
|
||||
settings->setDefault("ignore_world_load_errors", "false");
|
||||
settings->setDefault("mgv6_use_smooth_biome_trans", "true"); //temporary
|
||||
settings->setDefault("congestion_control_aim_rtt", "0.2");
|
||||
settings->setDefault("congestion_control_max_rate", "400");
|
||||
settings->setDefault("congestion_control_min_rate", "10");
|
||||
|
|
|
@ -2021,7 +2021,9 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emer
|
|||
}
|
||||
emerge->seed = m_seed;
|
||||
emerge->water_level = g_settings->getS16("default_water_level");
|
||||
//<set noiseparams here>
|
||||
//mapgen version
|
||||
//chunksize
|
||||
//noiseparams
|
||||
|
||||
/*
|
||||
Experimental and debug stuff
|
||||
|
|
|
@ -52,21 +52,21 @@ Mapgen::Mapgen(BiomeDefManager *biomedef) {
|
|||
}*/
|
||||
|
||||
|
||||
Mapgen::Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed) {
|
||||
initMapgen(biomedef, mapgenid, seed,
|
||||
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed) {
|
||||
init(biomedef, mapgenid, seed,
|
||||
&nparams_mtdefault, &nparams_def_bgroup,
|
||||
&nparams_def_heat, &nparams_def_humidity);
|
||||
}
|
||||
|
||||
|
||||
Mapgen::Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
||||
initMapgen(biomedef, mapgenid, seed,
|
||||
init(biomedef, mapgenid, seed,
|
||||
np_terrain, np_bgroup, np_heat, np_humidity);
|
||||
}
|
||||
|
||||
void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
void MapgenV7::init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
||||
this->generating = false;
|
||||
|
@ -75,6 +75,7 @@ void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
|||
this->biomedef = biomedef;
|
||||
this->csize = v3s16(5, 5, 5) * MAP_BLOCKSIZE; /////////////////get this from config!
|
||||
this->water_level = g_settings->getS16("default_water_level"); ////fix this!
|
||||
this->ystride = csize.X;
|
||||
|
||||
this->np_terrain = np_terrain;
|
||||
this->np_bgroup = np_bgroup;
|
||||
|
@ -92,7 +93,7 @@ void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
|||
}
|
||||
|
||||
|
||||
Mapgen::~Mapgen() {
|
||||
MapgenV7::~MapgenV7() {
|
||||
delete noise_terrain;
|
||||
delete noise_bgroup;
|
||||
delete noise_heat;
|
||||
|
@ -100,12 +101,10 @@ Mapgen::~Mapgen() {
|
|||
}
|
||||
|
||||
|
||||
void Mapgen::makeChunk(BlockMakeData *data) {
|
||||
void MapgenV7::makeChunk(BlockMakeData *data) {
|
||||
if (data->no_op)
|
||||
return;
|
||||
|
||||
//printf("generating...\n");//////////////
|
||||
|
||||
assert(data->vmanip);
|
||||
assert(data->nodedef);
|
||||
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
|
||||
|
@ -123,6 +122,9 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||
this->ystride = em.X;
|
||||
this->zstride = em.Y * em.X;
|
||||
|
||||
if (node_max.X - node_min.X != 80)
|
||||
printf("uhoh, diff = %d, ystride = %d\n", node_max.X - node_min.X, ystride);
|
||||
|
||||
node_min = (data->blockpos_min) * MAP_BLOCKSIZE;
|
||||
node_max = (data->blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
|
||||
v3s16 full_node_min = (data->blockpos_min - 1) * MAP_BLOCKSIZE;
|
||||
|
@ -132,7 +134,7 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||
int y2 = node_max.Y;
|
||||
int x = node_min.X;
|
||||
int z = node_min.Z;
|
||||
//printf("full_node_min.X: %d | full_node_min.Z: %d | MinEdge: %d | MaxEdge: %d\n", node_min.X, node_min.Z, vmanip->m_area.MinEdge.X, vmanip->m_area.MinEdge.Z);
|
||||
|
||||
TimeTaker timer("Generating terrain");
|
||||
map_terrain = noise_terrain->perlinMap2D(x, z);
|
||||
map_bgroup = noise_bgroup->perlinMap2D(x, z);
|
||||
|
@ -161,11 +163,10 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||
updateLighting(node_min, node_max);
|
||||
|
||||
this->generating = false;
|
||||
//printf("generated block (%d, %d) to (%d, %d)\n", node_min.X, node_min.Y, node_max.X, node_max.Y);//////////
|
||||
}
|
||||
|
||||
|
||||
void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
||||
void MapgenV7::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
||||
bool isliquid, wasliquid;
|
||||
u32 i;
|
||||
|
||||
|
@ -190,7 +191,7 @@ void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
|||
}
|
||||
|
||||
|
||||
void Mapgen::updateLighting(v3s16 node_min, v3s16 node_max) {
|
||||
void MapgenV7::updateLighting(v3s16 node_min, v3s16 node_max) {
|
||||
enum LightBank banks[2] = {LIGHTBANK_DAY, LIGHTBANK_NIGHT};
|
||||
|
||||
VoxelArea a(node_min - v3s16(1,0,1) * MAP_BLOCKSIZE,
|
||||
|
@ -207,30 +208,13 @@ void Mapgen::updateLighting(v3s16 node_min, v3s16 node_max) {
|
|||
voxalgo::clearLightAndCollectSources(*vmanip, a, bank, ndef,
|
||||
light_sources, unlight_from);
|
||||
voxalgo::propagateSunlight(*vmanip, a, sunlight, light_sources, ndef);
|
||||
printf("light_sources: %d\t\tunlight_from: %d\n", light_sources.size(), unlight_from.size());
|
||||
//printf("light_sources: %d\t\tunlight_from: %d\n", light_sources.size(), unlight_from.size());
|
||||
vmanip->unspreadLight(bank, unlight_from, light_sources, ndef);
|
||||
vmanip->spreadLight(bank, light_sources, ndef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*class EmergeManager {
|
||||
public:
|
||||
int seed;
|
||||
int water_level;
|
||||
BiomeDefManager *biomedef;
|
||||
|
||||
//mapgen objects here
|
||||
|
||||
void addBlockToQueue();
|
||||
|
||||
|
||||
//mapgen helper methods
|
||||
int getGroundLevelAtPoint(u64 mseed, v2s16 p);
|
||||
bool isBlockUnderground(u64 mseed, v3s16 blockpos);
|
||||
u32 getBlockSeed(u64 mseed, v3s16 p);
|
||||
};*/
|
||||
|
||||
EmergeManager::EmergeManager(IGameDef *gamedef) {
|
||||
this->seed = 0;
|
||||
this->water_level = 0;
|
||||
|
@ -279,7 +263,7 @@ bool EmergeManager::isBlockUnderground(v3s16 blockpos) {
|
|||
|
||||
//yuck, but then again, should i bother being accurate?
|
||||
//the height of the nodes in a single block is quite variable
|
||||
return false; //blockpos.Y * (MAP_BLOCKSIZE + 1) <= water_level;
|
||||
return blockpos.Y * (MAP_BLOCKSIZE + 1) <= water_level;
|
||||
}
|
||||
|
||||
|
||||
|
|
101
src/mapgen.h
101
src/mapgen.h
|
@ -32,8 +32,17 @@ class Biome;
|
|||
//struct BlockMakeData;
|
||||
class MapBlock;
|
||||
class ManualMapVoxelManipulator;
|
||||
class VoxelManipulator;
|
||||
class INodeDefManager;
|
||||
|
||||
|
||||
enum BiomeType
|
||||
{
|
||||
BT_NORMAL,
|
||||
BT_DESERT
|
||||
};
|
||||
|
||||
|
||||
struct BlockMakeData {
|
||||
bool no_op;
|
||||
ManualMapVoxelManipulator *vmanip;
|
||||
|
@ -48,7 +57,81 @@ struct BlockMakeData {
|
|||
~BlockMakeData();
|
||||
};
|
||||
|
||||
|
||||
class Mapgen {
|
||||
public:
|
||||
|
||||
int seed;
|
||||
int water_level;
|
||||
|
||||
bool generating;
|
||||
int id;
|
||||
|
||||
|
||||
//virtual Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
|
||||
//virtual ~Mapgen();
|
||||
virtual void makeChunk(BlockMakeData *data) {};
|
||||
|
||||
//Legacy functions for Farmesh (pending removal)
|
||||
static bool get_have_beach(u64 seed, v2s16 p2d);
|
||||
static double tree_amount_2d(u64 seed, v2s16 p);
|
||||
static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
||||
};
|
||||
|
||||
|
||||
class MapgenV6 : public Mapgen {
|
||||
public:
|
||||
//ManualMapVoxelManipulator &vmanip;
|
||||
|
||||
int ystride;
|
||||
v3s16 csize;
|
||||
|
||||
v3s16 node_min;
|
||||
v3s16 node_max;
|
||||
|
||||
Noise *noise_terrain_base;
|
||||
Noise *noise_terrain_higher;
|
||||
Noise *noise_steepness;
|
||||
Noise *noise_height_select;
|
||||
Noise *noise_trees;
|
||||
Noise *noise_mud;
|
||||
Noise *noise_beach;
|
||||
Noise *noise_biome;
|
||||
Noise *noise_cave;
|
||||
|
||||
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;
|
||||
float *map_cave;
|
||||
|
||||
bool use_smooth_biome_trans;
|
||||
|
||||
MapgenV6(int mapgenid=0, u64 seed=0);
|
||||
~MapgenV6();
|
||||
|
||||
void makeChunk(BlockMakeData *data);
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
u32 get_blockseed(u64 seed, v3s16 p);
|
||||
};
|
||||
|
||||
|
||||
class MapgenV7 : public Mapgen {
|
||||
public:
|
||||
BlockMakeData *data;
|
||||
ManualMapVoxelManipulator *vmanip;
|
||||
|
@ -59,8 +142,8 @@ public:
|
|||
int zstride;
|
||||
|
||||
v3s16 csize;
|
||||
int seed;
|
||||
int water_level;
|
||||
//int seed;
|
||||
//int water_level;
|
||||
|
||||
Noise *noise_terrain;
|
||||
Noise *noise_bgroup;
|
||||
|
@ -88,23 +171,23 @@ public:
|
|||
MapNode n_water;
|
||||
MapNode n_lava;
|
||||
|
||||
Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
|
||||
Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
MapgenV7(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
|
||||
MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||
NoiseParams *np_heat, NoiseParams *np_humidity);
|
||||
void initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
void init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||
NoiseParams *np_heat, NoiseParams *np_humidity);
|
||||
~Mapgen();
|
||||
~MapgenV7();
|
||||
|
||||
void makeChunk(BlockMakeData *data);
|
||||
void updateLiquid(v3s16 node_min, v3s16 node_max);
|
||||
void updateLighting(v3s16 node_min, v3s16 node_max);
|
||||
|
||||
//Legacy functions for Farmesh (pending removal)
|
||||
static bool get_have_beach(u64 seed, v2s16 p2d);
|
||||
static double tree_amount_2d(u64 seed, v2s16 p);
|
||||
static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
||||
// static bool get_have_beach(u64 seed, v2s16 p2d);
|
||||
// static double tree_amount_2d(u64 seed, v2s16 p);
|
||||
// static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
||||
};
|
||||
|
||||
class EmergeManager {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -311,10 +311,13 @@ void Noise::setSize(int sx, int sy, int sz) {
|
|||
this->sy = sy;
|
||||
this->sz = sz;
|
||||
|
||||
this->noisebuf = NULL;
|
||||
resizeNoiseBuf(sz > 1);
|
||||
|
||||
delete[] buf;
|
||||
delete[] result;
|
||||
this->buf = new float[sx * sy * sz];
|
||||
this->result = new float[sx * sy * sz];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4460,10 +4460,8 @@ static int l_register_biome_groups(lua_State *L)
|
|||
{
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
int index = 1;
|
||||
if (!lua_istable(L, index)) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (!lua_istable(L, index))
|
||||
throw LuaError(L, "register_biome_groups: parameter is not a table");
|
||||
|
||||
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
|
||||
|
||||
|
@ -4514,15 +4512,16 @@ static int l_register_biome(lua_State *L)
|
|||
b->humidity_min = getfloatfield_default(L, index, "humidity_min", 0.);
|
||||
b->humidity_max = getfloatfield_default(L, index, "humidity_max", 0.);
|
||||
|
||||
//////hrm, what to do about the noiseparams...
|
||||
b->np = new NoiseParams; /////just a hacky solution
|
||||
b->np = new NoiseParams; // should read an entire NoiseParams later on...
|
||||
getfloatfield(L, index, "scale", b->np->scale);
|
||||
getfloatfield(L, index, "offset", b->np->offset);
|
||||
//TODO: add configurable spread factor and octaves!?
|
||||
//I'd have to create a Noise for every Biome...
|
||||
bmgr->addBiome(groupid, b);
|
||||
printf(" - added biome '%s' - %d %d\n", b->name.c_str(), b->n_top.param0, b->n_filler.param0);
|
||||
|
||||
b->groupid = (s8)groupid;
|
||||
b->flags = 0; //reserved
|
||||
|
||||
bmgr->addBiome(b);
|
||||
|
||||
verbosestream << "register_biome: " << b->name << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,8 +172,12 @@ void * EmergeThread::Thread()
|
|||
|
||||
ServerMap &map = ((ServerMap&)m_server->m_env->getMap());
|
||||
EmergeManager *emerge = m_server->m_emerge;
|
||||
Mapgen *mapgen = new Mapgen( m_server->m_emerge->biomedef,/*mapgenid*/ 0, map.getSeed()); ////////fix this...!
|
||||
|
||||
Mapgen *mapgen;
|
||||
if (g_settings->getS16("use_mapgen_version") == 7) ////////this is okay for now, fix later
|
||||
mapgen = new MapgenV7( m_server->m_emerge->biomedef,/*mapgenid*/ 0, map.getSeed());
|
||||
else
|
||||
mapgen = new MapgenV6(0, map.getSeed());
|
||||
/*
|
||||
Get block info from queue, emerge them and send them
|
||||
to clients.
|
||||
|
|
Loading…
Reference in New Issue