mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Add initial Lua biomedef support, fixed biome selection
This commit is contained in:
parent
11afcbff69
commit
96898c1794
@ -1586,6 +1586,82 @@ minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
|
|||||||
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
||||||
minetest.register_alias("mapgen_mese", "default:mese")
|
minetest.register_alias("mapgen_mese", "default:mese")
|
||||||
|
|
||||||
|
minetest.register_biome_groups({
|
||||||
|
0.35, 0.30, 0.20
|
||||||
|
})
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Register the biomes for the map generator
|
||||||
|
--
|
||||||
|
minetest.register_biome({
|
||||||
|
group_id = 0,
|
||||||
|
name = "Ocean",
|
||||||
|
terrain_type = "liquid",
|
||||||
|
node_top = "default:gravel",
|
||||||
|
node_filler = "default:stone",
|
||||||
|
num_top_nodes = 4,
|
||||||
|
height_min = -3000,
|
||||||
|
height_max = 3000,
|
||||||
|
heat_min = -20.0,
|
||||||
|
heat_max = 100.0,
|
||||||
|
humidity_min = 0.0,
|
||||||
|
humidity_max = 100.0,
|
||||||
|
scale = 10.0,
|
||||||
|
offset = -10.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_biome({
|
||||||
|
group_id = 1,
|
||||||
|
name = "Beach",
|
||||||
|
terrain_type = "normal",
|
||||||
|
node_top = "default:sand",
|
||||||
|
node_filler = "default:stone",
|
||||||
|
num_top_nodes = 5,
|
||||||
|
height_min = -3000,
|
||||||
|
height_max = 3000,
|
||||||
|
heat_min = 60.0,
|
||||||
|
heat_max = 100.0,
|
||||||
|
humidity_min = 0.0,
|
||||||
|
humidity_max = 100.0,
|
||||||
|
scale = 5.0,
|
||||||
|
offset = 5.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_biome({
|
||||||
|
group_id = 2,
|
||||||
|
name = "Land",
|
||||||
|
terrain_type = "normal",
|
||||||
|
node_top = "default:dirt_with_grass",
|
||||||
|
node_filler = "default:stone",
|
||||||
|
num_top_nodes = 5,
|
||||||
|
height_min = -3000,
|
||||||
|
height_max = 3000,
|
||||||
|
heat_min = -50.0,
|
||||||
|
heat_max = 100.0,
|
||||||
|
humidity_min = 0.0,
|
||||||
|
humidity_max = 100.0,
|
||||||
|
scale = 12.0,
|
||||||
|
offset = 10.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_biome({
|
||||||
|
group_id = 3,
|
||||||
|
name = "Hills",
|
||||||
|
terrain_type = "normal",
|
||||||
|
node_top = "default:dirt",
|
||||||
|
node_filler = "default:stone",
|
||||||
|
num_top_nodes = 3,
|
||||||
|
height_min = -3000,
|
||||||
|
height_max = 3000,
|
||||||
|
heat_min = -50.0,
|
||||||
|
heat_max = 100.0,
|
||||||
|
humidity_min = 0.0,
|
||||||
|
humidity_max = 100.0,
|
||||||
|
scale = 70.0,
|
||||||
|
offset = 30.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Support old code
|
-- Support old code
|
||||||
function default.spawn_falling_node(p, nodename)
|
function default.spawn_falling_node(p, nodename)
|
||||||
spawn_falling_node(p, nodename)
|
spawn_falling_node(p, nodename)
|
||||||
|
119
src/biome.cpp
119
src/biome.cpp
@ -64,11 +64,14 @@ int bg4_biomes[] = {BT_HILLS, BT_EXTREMEHILLS, BT_MOUNTAINS, BT_DESERT, BT_DESE
|
|||||||
float bg5_temps[] = {5.0, 40.0};
|
float bg5_temps[] = {5.0, 40.0};
|
||||||
int bg5_biomes[] = {BT_LAKE, BT_PLAINS, BT_DESERT};*/
|
int bg5_biomes[] = {BT_LAKE, BT_PLAINS, BT_DESERT};*/
|
||||||
|
|
||||||
|
NoiseParams np_default = {0.0, 20.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
||||||
|
|
||||||
|
|
||||||
BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
|
BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
|
||||||
this->m_gamedef = gamedef;
|
this->m_gamedef = gamedef;
|
||||||
this->ndef = gamedef->ndef();
|
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
|
//addDefaultBiomes(); //can't do this in the ctor, too early
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,19 +82,51 @@ BiomeDefManager::~BiomeDefManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeDefManager::addBiome() {
|
Biome *BiomeDefManager::createBiome(BiomeTerrainType btt) {
|
||||||
|
switch (btt) {
|
||||||
|
case BIOME_TERRAIN_NORMAL:
|
||||||
|
return new Biome;
|
||||||
|
case BIOME_TERRAIN_LIQUID:
|
||||||
|
return new BiomeLiquid;
|
||||||
|
case BIOME_TERRAIN_NETHER:
|
||||||
|
return new BiomeHell;
|
||||||
|
case BIOME_TERRAIN_AETHER:
|
||||||
|
return new BiomeAether;
|
||||||
|
case BIOME_TERRAIN_FLAT:
|
||||||
|
return new BiomeSuperflat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NoiseParams npmtdef = {0.0, 20.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
void BiomeDefManager::addBiomeGroup(float freq) {
|
||||||
|
int size = bgroup_freqs.size();
|
||||||
|
float newfreq = freq;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BiomeDefManager::addBiome(int groupid, Biome *b) {
|
||||||
|
std::vector<Biome *> *bgroup;
|
||||||
|
|
||||||
|
if (groupid >= bgroups.size()) {
|
||||||
|
printf("blahblahblah");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bgroup = bgroups[groupid];
|
||||||
|
bgroup->push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeDefManager::addDefaultBiomes() {
|
void BiomeDefManager::addDefaultBiomes() {
|
||||||
std::vector<Biome *> *bgroup;
|
std::vector<Biome *> *bgroup;
|
||||||
Biome *b;
|
Biome *b;
|
||||||
|
|
||||||
//bgroup = new std::vector<Biome *>;
|
|
||||||
|
|
||||||
b = new Biome;
|
b = new Biome;
|
||||||
b->name = "Default";
|
b->name = "Default";
|
||||||
b->n_top = MapNode(ndef->getId("mapgen_stone"));
|
b->n_top = MapNode(ndef->getId("mapgen_stone"));
|
||||||
@ -103,30 +138,25 @@ void BiomeDefManager::addDefaultBiomes() {
|
|||||||
b->heat_max = FLT_MAX;
|
b->heat_max = FLT_MAX;
|
||||||
b->humidity_min = FLT_MIN;
|
b->humidity_min = FLT_MIN;
|
||||||
b->humidity_max = FLT_MAX;
|
b->humidity_max = FLT_MAX;
|
||||||
b->np = &npmtdef;
|
b->np = &np_default;
|
||||||
biome_default = b;
|
biome_default = b;
|
||||||
|
|
||||||
//bgroup->push_back(b);
|
|
||||||
//bgroups.push_back(bgroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Biome *BiomeDefManager::getBiome(float bgfreq, float heat, float humidity) {
|
Biome *BiomeDefManager::getBiome(float bgfreq, float heat, float humidity) {
|
||||||
std::vector<Biome *> bgroup;
|
std::vector<Biome *> *bgroup;
|
||||||
Biome *b;
|
Biome *b;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int ngroups = bgroup_freqs.size();
|
int ngroups = bgroup_freqs.size();
|
||||||
if (!ngroups)
|
if (!ngroups)
|
||||||
return biome_default;
|
return biome_default;
|
||||||
for (i = 0; (i != ngroups - 1) && (bgfreq > bgroup_freqs[i]); i++);
|
for (i = 0; (i != ngroups) && (bgfreq > bgroup_freqs[i]); i++);
|
||||||
bgroup = *(bgroups[i]);
|
bgroup = bgroups[i];
|
||||||
|
|
||||||
int nbiomes = bgroup.size();
|
int nbiomes = bgroup->size();
|
||||||
if (!nbiomes)
|
for (i = 0; i != nbiomes; i++) {
|
||||||
return biome_default;
|
b = bgroup->operator[](i);///////////////////////////
|
||||||
for (i = 0; i != nbiomes - 1; i++) {
|
|
||||||
b = bgroup[i];
|
|
||||||
if (heat >= b->heat_min && heat <= b->heat_max &&
|
if (heat >= b->heat_min && heat <= b->heat_max &&
|
||||||
humidity >= b->humidity_min && humidity <= b->humidity_max)
|
humidity >= b->humidity_min && humidity <= b->humidity_max)
|
||||||
return b;
|
return b;
|
||||||
@ -145,13 +175,11 @@ int Biome::getSurfaceHeight(float noise_terrain) {
|
|||||||
|
|
||||||
|
|
||||||
void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||||
//printf("(%d, %d): %f\n", x, z, mg->map_terrain[z * mg->ystride + x]);
|
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 surfaceh = 4;
|
|
||||||
int surfaceh = np->offset + np->scale * mg->map_terrain[(z - mg->node_min.Z) * 80 /*THIS IS TEMPORARY mg->ystride*/ + (x - mg->node_min.X)];
|
|
||||||
//printf("gen column %f\n", );
|
|
||||||
int y = y1;
|
int y = y1;
|
||||||
int i = mg->vmanip->m_area.index(x, y, z); //z * mg->zstride + x + (y - mg->vmanip->m_area.MinEdge.Y) * mg->ystride;
|
|
||||||
|
i = mg->vmanip->m_area.index(x, y, z);
|
||||||
for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
||||||
mg->vmanip->m_data[i] = n_filler;
|
mg->vmanip->m_data[i] = n_filler;
|
||||||
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
||||||
@ -166,16 +194,18 @@ void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BiomeOcean::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeLiquid::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||||
int y, i = 0;
|
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;
|
||||||
|
|
||||||
int surfaceh = np->offset + np->scale * mg->map_terrain[z * mg->ystride + x];
|
i = mg->vmanip->m_area.index(x, y, z);
|
||||||
|
for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
||||||
i = z * mg->zstride + x;
|
|
||||||
for (y = y1; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
|
||||||
mg->vmanip->m_data[i] = n_filler;
|
mg->vmanip->m_data[i] = n_filler;
|
||||||
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
||||||
mg->vmanip->m_data[i] = n_top;
|
mg->vmanip->m_data[i] = n_top;
|
||||||
|
for (; y <= mg->water_level && y <= y2; y++, i += mg->ystride)
|
||||||
|
mg->vmanip->m_data[i] = mg->n_water;
|
||||||
for (; y <= y2; y++, i += mg->ystride)
|
for (; y <= y2; y++, i += mg->ystride)
|
||||||
mg->vmanip->m_data[i] = mg->n_air;
|
mg->vmanip->m_data[i] = mg->n_air;
|
||||||
}
|
}
|
||||||
@ -190,22 +220,23 @@ int BiomeHell::getSurfaceHeight(float noise_terrain) {
|
|||||||
|
|
||||||
|
|
||||||
void BiomeHell::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeHell::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||||
int y, i = 0;
|
|
||||||
|
|
||||||
int surfaceh = np->offset + np->scale * mg->map_terrain[z * mg->ystride + x];
|
|
||||||
|
|
||||||
i = z * mg->zstride + x;
|
|
||||||
for (y = y1; 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////// [ Aether biome ] ////////////////////////////////
|
///////////////////////////// [ Aether biome ] ////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
int BiomeAether::getSurfaceHeight(float noise_terrain) {
|
||||||
|
return np->offset + np->scale * noise_terrain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BiomeAether::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////// [ Superflat biome ] ///////////////////////////////
|
/////////////////////////// [ Superflat biome ] ///////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
@ -215,15 +246,5 @@ int BiomeSuperflat::getSurfaceHeight(float noise_terrain) {
|
|||||||
|
|
||||||
|
|
||||||
void BiomeSuperflat::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeSuperflat::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
||||||
int y, i = 0;
|
|
||||||
|
|
||||||
int surfaceh = ntopnodes;
|
|
||||||
|
|
||||||
i = z * mg->zstride + x;
|
|
||||||
for (y = y1; 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;
|
|
||||||
}
|
}
|
||||||
|
24
src/biome.h
24
src/biome.h
@ -20,12 +20,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef BIOME_HEADER
|
#ifndef BIOME_HEADER
|
||||||
#define BIOME_HEADER
|
#define BIOME_HEADER
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include "mapgen.h"
|
#include "mapgen.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum BiomeTerrainType
|
||||||
|
{
|
||||||
|
BIOME_TERRAIN_NORMAL,
|
||||||
|
BIOME_TERRAIN_LIQUID,
|
||||||
|
BIOME_TERRAIN_NETHER,
|
||||||
|
BIOME_TERRAIN_AETHER,
|
||||||
|
BIOME_TERRAIN_FLAT
|
||||||
|
};
|
||||||
|
|
||||||
class Biome {
|
class Biome {
|
||||||
public:
|
public:
|
||||||
MapNode n_top;
|
MapNode n_top;
|
||||||
@ -38,14 +49,14 @@ public:
|
|||||||
float heat_max;
|
float heat_max;
|
||||||
float humidity_min;
|
float humidity_min;
|
||||||
float humidity_max;
|
float humidity_max;
|
||||||
const char *name;
|
std::string name;
|
||||||
NoiseParams *np;
|
NoiseParams *np;
|
||||||
|
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BiomeOcean : public Biome {
|
class BiomeLiquid : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,6 +65,11 @@ class BiomeHell : public Biome {
|
|||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BiomeAether : public Biome {
|
||||||
|
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||||
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
|
};
|
||||||
|
|
||||||
class BiomeSuperflat : public Biome {
|
class BiomeSuperflat : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
@ -70,9 +86,11 @@ public:
|
|||||||
BiomeDefManager(IGameDef *gamedef);
|
BiomeDefManager(IGameDef *gamedef);
|
||||||
~BiomeDefManager();
|
~BiomeDefManager();
|
||||||
|
|
||||||
|
Biome *createBiome(BiomeTerrainType btt);
|
||||||
Biome *getBiome(float bgfreq, float heat, float humidity);
|
Biome *getBiome(float bgfreq, float heat, float humidity);
|
||||||
|
|
||||||
void addBiome();
|
void addBiomeGroup(float freq);
|
||||||
|
void addBiome(int groupid, Biome *b);
|
||||||
void addDefaultBiomes();
|
void addDefaultBiomes();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "treegen.h"
|
#include "treegen.h"
|
||||||
|
|
||||||
NoiseParams nparams_mtdefault =
|
NoiseParams nparams_mtdefault =
|
||||||
{0.0, 20.0, v3f(250., 250., 250.), 82341, 5, 0.6}; //terrain
|
{10.0, 12.0, v3f(350., 350., 350.), 82341, 5, 0.6}; //terrain
|
||||||
NoiseParams nparams_def_bgroup =
|
NoiseParams nparams_def_bgroup =
|
||||||
{0.5, 1/(2*1.6), v3f(250., 250., 250.), 5923, 2, 0.60}; //0 to 1
|
{0.5, 1/(2*1.6), v3f(350., 350., 350.), 5923, 2, 0.60}; //0 to 1
|
||||||
NoiseParams nparams_def_heat =
|
NoiseParams nparams_def_heat =
|
||||||
{25.0, 50.0, v3f(500., 500., 500.), 35293, 1, 0.00}; //-25 to 75
|
{25.0, 50.0, v3f(500., 500., 500.), 35293, 1, 0.00}; //-25 to 75
|
||||||
NoiseParams nparams_def_humidity =
|
NoiseParams nparams_def_humidity =
|
||||||
@ -139,9 +139,13 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
map_heat = noise_heat->perlinMap2D(x, z);
|
map_heat = noise_heat->perlinMap2D(x, z);
|
||||||
map_humidity = noise_humidity->perlinMap2D(x, z);
|
map_humidity = noise_humidity->perlinMap2D(x, z);
|
||||||
|
|
||||||
|
noise_bgroup->transformNoiseMap();
|
||||||
|
noise_heat->transformNoiseMap();
|
||||||
|
noise_humidity->transformNoiseMap();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (x = node_min.X; x <= node_max.X; x++) {
|
|
||||||
for (z = node_min.Z; z <= node_max.Z; z++) {
|
for (z = node_min.Z; z <= node_max.Z; z++) {
|
||||||
|
for (x = node_min.X; x <= node_max.X; x++) {
|
||||||
Biome *biome = biomedef->getBiome(map_bgroup[i], map_heat[i], map_humidity[i]);
|
Biome *biome = biomedef->getBiome(map_bgroup[i], map_heat[i], map_humidity[i]);
|
||||||
biome->genColumn(this, x, z, y1, y2);
|
biome->genColumn(this, x, z, y1, y2);
|
||||||
i++;
|
i++;
|
||||||
@ -153,7 +157,7 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
//genDungeon();
|
//genDungeon();
|
||||||
//add blobs of dirt and gravel underground
|
//add blobs of dirt and gravel underground
|
||||||
//decorateChunk();
|
//decorateChunk();
|
||||||
//updateLiquid(full_node_min, full_node_max);
|
updateLiquid(full_node_min, full_node_max);
|
||||||
updateLighting(node_min, node_max);
|
updateLighting(node_min, node_max);
|
||||||
|
|
||||||
this->generating = false;
|
this->generating = false;
|
||||||
@ -164,7 +168,6 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
||||||
bool isliquid, wasliquid;
|
bool isliquid, wasliquid;
|
||||||
u32 i;
|
u32 i;
|
||||||
content_t c;
|
|
||||||
|
|
||||||
for (s16 z = node_min.Z; z <= node_max.Z; z++) {
|
for (s16 z = node_min.Z; z <= node_max.Z; z++) {
|
||||||
for (s16 x = node_min.X; x <= node_max.X; x++) {
|
for (s16 x = node_min.X; x <= node_max.X; x++) {
|
||||||
|
@ -287,7 +287,7 @@ Noise::Noise(NoiseParams *np, int seed, int sx, int sy) {
|
|||||||
this->seed = seed;
|
this->seed = seed;
|
||||||
this->sx = sx;
|
this->sx = sx;
|
||||||
this->sy = sy;
|
this->sy = sy;
|
||||||
this->sz = 0;
|
this->sz = 1;
|
||||||
this->noisebuf = new float[nlx * nly];
|
this->noisebuf = new float[nlx * nly];
|
||||||
this->buf = new float[sx * sy];
|
this->buf = new float[sx * sy];
|
||||||
this->result = new float[sx * sy];
|
this->result = new float[sx * sy];
|
||||||
@ -538,3 +538,16 @@ float *Noise::perlinMap3D(float x, float y, float z) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Noise::transformNoiseMap() {
|
||||||
|
int i = 0;
|
||||||
|
for (int z = 0; z != sz; z++) {
|
||||||
|
for (int y = 0; y != sy; y++) {
|
||||||
|
for (int x = 0; x != sx; x++) {
|
||||||
|
result[i] = result[i] * np->scale + np->offset;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -95,6 +95,7 @@ public:
|
|||||||
int seed);
|
int seed);
|
||||||
float *perlinMap2D(float x, float y);
|
float *perlinMap2D(float x, float y);
|
||||||
float *perlinMap3D(float x, float y, float z);
|
float *perlinMap3D(float x, float y, float z);
|
||||||
|
void transformNoiseMap();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return value: -1 ... 1
|
// Return value: -1 ... 1
|
||||||
|
@ -37,6 +37,7 @@ extern "C" {
|
|||||||
#include "content_sao.h" // For LuaEntitySAO and PlayerSAO
|
#include "content_sao.h" // For LuaEntitySAO and PlayerSAO
|
||||||
#include "itemdef.h"
|
#include "itemdef.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
|
#include "biome.h"
|
||||||
#include "craftdef.h"
|
#include "craftdef.h"
|
||||||
#include "main.h" // For g_settings
|
#include "main.h" // For g_settings
|
||||||
#include "settings.h" // For accessing g_settings
|
#include "settings.h" // For accessing g_settings
|
||||||
@ -436,6 +437,16 @@ struct EnumString es_TileAnimationType[] =
|
|||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EnumString es_BiomeTerrainType[] =
|
||||||
|
{
|
||||||
|
{BIOME_TERRAIN_NORMAL, "normal"},
|
||||||
|
{BIOME_TERRAIN_LIQUID, "liquid"},
|
||||||
|
{BIOME_TERRAIN_NETHER, "nether"},
|
||||||
|
{BIOME_TERRAIN_AETHER, "aether"},
|
||||||
|
{BIOME_TERRAIN_FLAT, "flat"},
|
||||||
|
{0, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
C struct <-> Lua table converter functions
|
C struct <-> Lua table converter functions
|
||||||
*/
|
*/
|
||||||
@ -4147,6 +4158,8 @@ const luaL_reg EnvRef::methods[] = {
|
|||||||
method(EnvRef, find_node_near),
|
method(EnvRef, find_node_near),
|
||||||
method(EnvRef, find_nodes_in_area),
|
method(EnvRef, find_nodes_in_area),
|
||||||
method(EnvRef, get_perlin),
|
method(EnvRef, get_perlin),
|
||||||
|
//method{EnvRef, get_perlin_map_2d},
|
||||||
|
//method{EnvRef, get_perlin_map_3d},
|
||||||
method(EnvRef, clear_objects),
|
method(EnvRef, clear_objects),
|
||||||
method(EnvRef, spawn_tree),
|
method(EnvRef, spawn_tree),
|
||||||
{0,0}
|
{0,0}
|
||||||
@ -4442,6 +4455,77 @@ static int l_get_server_status(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register_biome_groups({frequencies})
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
|
||||||
|
|
||||||
|
lua_pushnil(L);
|
||||||
|
for (int i = 1; lua_next(L, index) != 0; i++) {
|
||||||
|
bmgr->addBiomeGroup(lua_tonumber(L, -1));
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// register_biome({lots of stuff})
|
||||||
|
static int l_register_biome(lua_State *L)
|
||||||
|
{
|
||||||
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
|
int index = 1, groupid;
|
||||||
|
std::string nodename;
|
||||||
|
|
||||||
|
IWritableNodeDefManager *ndef = get_server(L)->getWritableNodeDefManager();
|
||||||
|
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
|
||||||
|
|
||||||
|
groupid = getintfield_default(L, index, "group_id", 0);
|
||||||
|
|
||||||
|
enum BiomeTerrainType terrain = (BiomeTerrainType)getenumfield(L, index,
|
||||||
|
"terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL);
|
||||||
|
Biome *b = bmgr->createBiome(terrain);
|
||||||
|
|
||||||
|
b->name = getstringfield_default(L, index, "name", "");
|
||||||
|
|
||||||
|
if (getstringfield(L, index, "node_top", nodename))
|
||||||
|
b->n_top = MapNode(ndef->getId(nodename));
|
||||||
|
else
|
||||||
|
b->n_top = MapNode(CONTENT_IGNORE);
|
||||||
|
|
||||||
|
if (getstringfield(L, index, "node_filler", nodename))
|
||||||
|
b->n_filler = MapNode(ndef->getId(nodename));
|
||||||
|
else
|
||||||
|
b->n_filler = b->n_top;
|
||||||
|
|
||||||
|
b->ntopnodes = getintfield_default(L, index, "num_top_nodes", 0);
|
||||||
|
|
||||||
|
b->height_min = getintfield_default(L, index, "height_min", 0);
|
||||||
|
b->height_max = getintfield_default(L, index, "height_max", 0);
|
||||||
|
b->heat_min = getfloatfield_default(L, index, "heat_min", 0.);
|
||||||
|
b->heat_max = getfloatfield_default(L, index, "heat_max", 0.);
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// register_item_raw({lots of stuff})
|
// register_item_raw({lots of stuff})
|
||||||
static int l_register_item_raw(lua_State *L)
|
static int l_register_item_raw(lua_State *L)
|
||||||
{
|
{
|
||||||
@ -5254,6 +5338,8 @@ static const struct luaL_Reg minetest_f [] = {
|
|||||||
{"register_item_raw", l_register_item_raw},
|
{"register_item_raw", l_register_item_raw},
|
||||||
{"register_alias_raw", l_register_alias_raw},
|
{"register_alias_raw", l_register_alias_raw},
|
||||||
{"register_craft", l_register_craft},
|
{"register_craft", l_register_craft},
|
||||||
|
{"register_biome", l_register_biome},
|
||||||
|
{"register_biome_groups", l_register_biome_groups},
|
||||||
{"setting_set", l_setting_set},
|
{"setting_set", l_setting_set},
|
||||||
{"setting_get", l_setting_get},
|
{"setting_get", l_setting_get},
|
||||||
{"setting_getbool", l_setting_getbool},
|
{"setting_getbool", l_setting_getbool},
|
||||||
|
@ -549,6 +549,10 @@ public:
|
|||||||
|
|
||||||
// Envlock should be locked when using the rollback manager
|
// Envlock should be locked when using the rollback manager
|
||||||
IRollbackManager *getRollbackManager(){ return m_rollback; }
|
IRollbackManager *getRollbackManager(){ return m_rollback; }
|
||||||
|
|
||||||
|
//TODO: determine what should be locked when accessing the emerge manager
|
||||||
|
EmergeManager *getEmergeManager(){ return m_emerge; }
|
||||||
|
|
||||||
// actions: time-reversed list
|
// actions: time-reversed list
|
||||||
// Return value: success/failure
|
// Return value: success/failure
|
||||||
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
||||||
|
Loading…
Reference in New Issue
Block a user