forked from Mirrorlandia_minetest/minetest
Biomes: Make biome heat and humidity noise parameters user-configurable
This commit is contained in:
parent
7490368984
commit
29b413b376
@ -363,6 +363,8 @@ void EmergeManager::loadParamsFromSettings(Settings *settings) {
|
|||||||
settings->getS16NoEx("water_level", params.water_level);
|
settings->getS16NoEx("water_level", params.water_level);
|
||||||
settings->getS16NoEx("chunksize", params.chunksize);
|
settings->getS16NoEx("chunksize", params.chunksize);
|
||||||
settings->getFlagStrNoEx("mg_flags", params.flags, flagdesc_mapgen);
|
settings->getFlagStrNoEx("mg_flags", params.flags, flagdesc_mapgen);
|
||||||
|
settings->getNoiseParams("mg_biome_np_heat", params.np_biome_heat);
|
||||||
|
settings->getNoiseParams("mg_biome_np_humidity", params.np_biome_humidity);
|
||||||
|
|
||||||
delete params.sparams;
|
delete params.sparams;
|
||||||
params.sparams = createMapgenParams(params.mg_name);
|
params.sparams = createMapgenParams(params.mg_name);
|
||||||
@ -377,6 +379,8 @@ void EmergeManager::saveParamsToSettings(Settings *settings) {
|
|||||||
settings->setS16("water_level", params.water_level);
|
settings->setS16("water_level", params.water_level);
|
||||||
settings->setS16("chunksize", params.chunksize);
|
settings->setS16("chunksize", params.chunksize);
|
||||||
settings->setFlagStr("mg_flags", params.flags, flagdesc_mapgen, (u32)-1);
|
settings->setFlagStr("mg_flags", params.flags, flagdesc_mapgen, (u32)-1);
|
||||||
|
settings->setNoiseParams("mg_biome_np_heat", params.np_biome_heat);
|
||||||
|
settings->setNoiseParams("mg_biome_np_humidity", params.np_biome_humidity);
|
||||||
|
|
||||||
if (params.sparams)
|
if (params.sparams)
|
||||||
params.sparams->writeParams(settings);
|
params.sparams->writeParams(settings);
|
||||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef MAPGEN_HEADER
|
#ifndef MAPGEN_HEADER
|
||||||
#define MAPGEN_HEADER
|
#define MAPGEN_HEADER
|
||||||
|
|
||||||
|
#include "noise.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
@ -107,6 +108,9 @@ struct MapgenParams {
|
|||||||
s16 water_level;
|
s16 water_level;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
|
NoiseParams np_biome_heat;
|
||||||
|
NoiseParams np_biome_humidity;
|
||||||
|
|
||||||
MapgenSpecificParams *sparams;
|
MapgenSpecificParams *sparams;
|
||||||
|
|
||||||
MapgenParams()
|
MapgenParams()
|
||||||
@ -117,6 +121,8 @@ struct MapgenParams {
|
|||||||
chunksize = 5;
|
chunksize = 5;
|
||||||
flags = MG_TREES | MG_CAVES | MG_LIGHT;
|
flags = MG_TREES | MG_CAVES | MG_LIGHT;
|
||||||
sparams = NULL;
|
sparams = NULL;
|
||||||
|
np_biome_heat = NoiseParams(50, 50, v3f(500.0, 500.0, 500.0), 5349, 3, 0.70, 2.0);
|
||||||
|
np_biome_humidity = NoiseParams(50, 50, v3f(500.0, 500.0, 500.0), 842, 3, 0.55, 2.0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
|
|||||||
noise_wetness = new Noise(&sp->np_wetness, seed, csize.X, csize.Y + 2, csize.Z);
|
noise_wetness = new Noise(&sp->np_wetness, seed, csize.X, csize.Y + 2, csize.Z);
|
||||||
|
|
||||||
// Biome noise
|
// Biome noise
|
||||||
noise_heat = new Noise(bmgr->np_heat, seed, csize.X, csize.Z);
|
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||||
noise_humidity = new Noise(bmgr->np_humidity, seed, csize.X, csize.Z);
|
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||||
|
|
||||||
//// Resolve nodes to be used
|
//// Resolve nodes to be used
|
||||||
INodeDefManager *ndef = emerge->ndef;
|
INodeDefManager *ndef = emerge->ndef;
|
||||||
|
@ -81,8 +81,8 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
|
|||||||
noise_ridge = new Noise(&sp->np_ridge, seed, csize.X, csize.Y, csize.Z);
|
noise_ridge = new Noise(&sp->np_ridge, seed, csize.X, csize.Y, csize.Z);
|
||||||
|
|
||||||
//// Biome noise
|
//// Biome noise
|
||||||
noise_heat = new Noise(bmgr->np_heat, seed, csize.X, csize.Z);
|
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||||
noise_humidity = new Noise(bmgr->np_humidity, seed, csize.X, csize.Z);
|
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||||
|
|
||||||
//// Resolve nodes to be used
|
//// Resolve nodes to be used
|
||||||
INodeDefManager *ndef = emerge->ndef;
|
INodeDefManager *ndef = emerge->ndef;
|
||||||
@ -305,8 +305,8 @@ void MapgenV7::calculateNoise() {
|
|||||||
|
|
||||||
|
|
||||||
Biome *MapgenV7::getBiomeAtPoint(v3s16 p) {
|
Biome *MapgenV7::getBiomeAtPoint(v3s16 p) {
|
||||||
float heat = NoisePerlin2D(bmgr->np_heat, p.X, p.Z, seed);
|
float heat = NoisePerlin2D(noise_heat->np, p.X, p.Z, seed);
|
||||||
float humidity = NoisePerlin2D(bmgr->np_humidity, p.X, p.Z, seed);
|
float humidity = NoisePerlin2D(noise_humidity->np, p.X, p.Z, seed);
|
||||||
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Z);
|
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Z);
|
||||||
|
|
||||||
return bmgr->getBiome(heat, humidity, groundlevel);
|
return bmgr->getBiome(heat, humidity, groundlevel);
|
||||||
|
@ -29,17 +29,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
const char *BiomeManager::ELEMENT_TITLE = "biome";
|
const char *BiomeManager::ELEMENT_TITLE = "biome";
|
||||||
|
|
||||||
NoiseParams nparams_biome_def_heat(50, 50, v3f(500.0, 500.0, 500.0), 5349, 3, 0.70, 2.0);
|
|
||||||
NoiseParams nparams_biome_def_humidity(50, 50, v3f(500.0, 500.0, 500.0), 842, 3, 0.55, 2.0);
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BiomeManager::BiomeManager(IGameDef *gamedef)
|
BiomeManager::BiomeManager(IGameDef *gamedef)
|
||||||
{
|
{
|
||||||
m_resolver = gamedef->getNodeDefManager()->getResolver();
|
m_resolver = gamedef->getNodeDefManager()->getResolver();
|
||||||
np_heat = &nparams_biome_def_heat;
|
|
||||||
np_humidity = &nparams_biome_def_humidity;
|
|
||||||
|
|
||||||
// Create default biome to be used in case none exist
|
// Create default biome to be used in case none exist
|
||||||
Biome *b = new Biome;
|
Biome *b = new Biome;
|
||||||
|
@ -21,7 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define MG_BIOME_HEADER
|
#define MG_BIOME_HEADER
|
||||||
|
|
||||||
#include "mapgen.h"
|
#include "mapgen.h"
|
||||||
#include "noise.h"
|
|
||||||
|
struct NoiseParams;
|
||||||
|
|
||||||
enum BiomeType
|
enum BiomeType
|
||||||
{
|
{
|
||||||
@ -32,10 +33,6 @@ enum BiomeType
|
|||||||
BIOME_TYPE_FLAT
|
BIOME_TYPE_FLAT
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NoiseParams nparams_biome_def_heat;
|
|
||||||
extern NoiseParams nparams_biome_def_humidity;
|
|
||||||
|
|
||||||
|
|
||||||
class Biome : public GenElement {
|
class Biome : public GenElement {
|
||||||
public:
|
public:
|
||||||
u32 flags;
|
u32 flags;
|
||||||
@ -61,9 +58,6 @@ public:
|
|||||||
static const char *ELEMENT_TITLE;
|
static const char *ELEMENT_TITLE;
|
||||||
static const size_t ELEMENT_LIMIT = 0x100;
|
static const size_t ELEMENT_LIMIT = 0x100;
|
||||||
|
|
||||||
NoiseParams *np_heat;
|
|
||||||
NoiseParams *np_humidity;
|
|
||||||
|
|
||||||
BiomeManager(IGameDef *gamedef);
|
BiomeManager(IGameDef *gamedef);
|
||||||
~BiomeManager();
|
~BiomeManager();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user