mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-22 23:58:48 -05:00
Biomes: Define and use biome_t for biome IDs
This commit is contained in:
parent
8ed467d438
commit
109c7e3349
@ -36,6 +36,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define MG_LIGHT 0x10
|
#define MG_LIGHT 0x10
|
||||||
#define MG_DECORATIONS 0x20
|
#define MG_DECORATIONS 0x20
|
||||||
|
|
||||||
|
typedef u8 biome_t; // copy from mg_biome.h to avoid an unnecessary include
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
class MMVManip;
|
class MMVManip;
|
||||||
class INodeDefManager;
|
class INodeDefManager;
|
||||||
@ -161,7 +163,7 @@ public:
|
|||||||
|
|
||||||
u32 blockseed;
|
u32 blockseed;
|
||||||
s16 *heightmap;
|
s16 *heightmap;
|
||||||
u8 *biomemap;
|
biome_t *biomemap;
|
||||||
v3s16 csize;
|
v3s16 csize;
|
||||||
|
|
||||||
BiomeGen *biomegen;
|
BiomeGen *biomegen;
|
||||||
|
@ -128,7 +128,7 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
|
|||||||
|
|
||||||
heatmap = noise_heat->result;
|
heatmap = noise_heat->result;
|
||||||
humidmap = noise_humidity->result;
|
humidmap = noise_humidity->result;
|
||||||
biomemap = new u8[m_csize.X * m_csize.Z];
|
biomemap = new biome_t[m_csize.X * m_csize.Z];
|
||||||
}
|
}
|
||||||
|
|
||||||
BiomeGenOriginal::~BiomeGenOriginal()
|
BiomeGenOriginal::~BiomeGenOriginal()
|
||||||
@ -171,7 +171,7 @@ void BiomeGenOriginal::calcBiomeNoise(v3s16 pmin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u8 *BiomeGenOriginal::getBiomes(s16 *heightmap)
|
biome_t *BiomeGenOriginal::getBiomes(s16 *heightmap)
|
||||||
{
|
{
|
||||||
for (s32 i = 0; i != m_csize.X * m_csize.Z; i++) {
|
for (s32 i = 0; i != m_csize.X * m_csize.Z; i++) {
|
||||||
Biome *biome = calcBiomeFromNoise(
|
Biome *biome = calcBiomeFromNoise(
|
||||||
|
@ -31,7 +31,9 @@ class BiomeManager;
|
|||||||
//// Biome
|
//// Biome
|
||||||
////
|
////
|
||||||
|
|
||||||
#define BIOME_NONE ((u8)0)
|
typedef u8 biome_t;
|
||||||
|
|
||||||
|
#define BIOME_NONE ((biome_t)0)
|
||||||
|
|
||||||
// TODO(hmmmm): Decide whether this is obsolete or will be used in the future
|
// TODO(hmmmm): Decide whether this is obsolete or will be used in the future
|
||||||
enum BiomeType {
|
enum BiomeType {
|
||||||
@ -101,7 +103,7 @@ public:
|
|||||||
// Gets all biomes in current chunk using each corresponding element of
|
// Gets all biomes in current chunk using each corresponding element of
|
||||||
// heightmap as the y position, then stores the results by biome index in
|
// heightmap as the y position, then stores the results by biome index in
|
||||||
// biomemap (also returned)
|
// biomemap (also returned)
|
||||||
virtual u8 *getBiomes(s16 *heightmap) = 0;
|
virtual biome_t *getBiomes(s16 *heightmap) = 0;
|
||||||
|
|
||||||
// Gets a single biome at the specified position, which must be contained
|
// Gets a single biome at the specified position, which must be contained
|
||||||
// in the region formed by m_pmin and (m_pmin + m_csize - 1).
|
// in the region formed by m_pmin and (m_pmin + m_csize - 1).
|
||||||
@ -111,7 +113,7 @@ public:
|
|||||||
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
|
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
|
||||||
|
|
||||||
// Result of calcBiomes bulk computation.
|
// Result of calcBiomes bulk computation.
|
||||||
u8 *biomemap;
|
biome_t *biomemap;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BiomeManager *m_bmgr;
|
BiomeManager *m_bmgr;
|
||||||
@ -157,7 +159,7 @@ public:
|
|||||||
Biome *calcBiomeAtPoint(v3s16 pos) const;
|
Biome *calcBiomeAtPoint(v3s16 pos) const;
|
||||||
void calcBiomeNoise(v3s16 pmin);
|
void calcBiomeNoise(v3s16 pmin);
|
||||||
|
|
||||||
u8 *getBiomes(s16 *heightmap);
|
biome_t *getBiomes(s16 *heightmap);
|
||||||
Biome *getBiomeAtPoint(v3s16 pos) const;
|
Biome *getBiomeAtPoint(v3s16 pos) const;
|
||||||
Biome *getBiomeAtIndex(size_t index, s16 y) const;
|
Biome *getBiomeAtIndex(size_t index, s16 y) const;
|
||||||
|
|
||||||
@ -218,9 +220,6 @@ public:
|
|||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
// Looks for pos in the biome cache, and if non-existent, looks up by noise
|
|
||||||
u8 getBiomeAtPoint(v3s16 pos);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user