2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
// CompoGen.h
|
|
|
|
|
|
|
|
/* Interfaces to the various terrain composition generators:
|
|
|
|
- cCompoGenSameBlock
|
|
|
|
- cCompoGenDebugBiomes
|
|
|
|
- cCompoGenClassic
|
|
|
|
- cCompoGenBiomal
|
2013-05-05 15:56:45 -04:00
|
|
|
- cCompoGenNether
|
|
|
|
- cCompoGenCache
|
2012-06-14 09:06:06 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-01-25 05:12:29 -05:00
|
|
|
#include "ComposableGenerator.h"
|
2014-11-18 06:07:08 -05:00
|
|
|
#include "../Noise/Noise.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cCompoGenSameBlock :
|
|
|
|
public cTerrainCompositionGen
|
|
|
|
{
|
|
|
|
public:
|
2013-10-11 04:18:01 -04:00
|
|
|
cCompoGenSameBlock(void) :
|
|
|
|
m_BlockType(E_BLOCK_STONE),
|
|
|
|
m_IsBedrocked(true)
|
2012-06-14 09:06:06 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
BLOCKTYPE m_BlockType;
|
|
|
|
bool m_IsBedrocked;
|
|
|
|
|
|
|
|
// cTerrainCompositionGen overrides:
|
2014-11-12 15:24:26 -05:00
|
|
|
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape) override;
|
2013-10-11 04:18:01 -04:00
|
|
|
virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cCompoGenDebugBiomes :
|
|
|
|
public cTerrainCompositionGen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cCompoGenDebugBiomes(void) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
// cTerrainCompositionGen overrides:
|
2014-11-12 15:24:26 -05:00
|
|
|
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cCompoGenClassic :
|
|
|
|
public cTerrainCompositionGen
|
|
|
|
{
|
|
|
|
public:
|
2013-10-11 04:18:01 -04:00
|
|
|
cCompoGenClassic(void);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
int m_SeaLevel;
|
|
|
|
int m_BeachHeight;
|
|
|
|
int m_BeachDepth;
|
|
|
|
BLOCKTYPE m_BlockTop;
|
|
|
|
BLOCKTYPE m_BlockMiddle;
|
|
|
|
BLOCKTYPE m_BlockBottom;
|
|
|
|
BLOCKTYPE m_BlockBeach;
|
|
|
|
BLOCKTYPE m_BlockBeachBottom;
|
|
|
|
BLOCKTYPE m_BlockSea;
|
|
|
|
|
|
|
|
// cTerrainCompositionGen overrides:
|
2014-11-12 15:24:26 -05:00
|
|
|
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape) override;
|
2013-10-11 04:18:01 -04:00
|
|
|
virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-11 13:15:34 -04:00
|
|
|
class cCompoGenNether :
|
|
|
|
public cTerrainCompositionGen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cCompoGenNether(int a_Seed);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cNoise m_Noise1;
|
|
|
|
cNoise m_Noise2;
|
|
|
|
|
|
|
|
int m_Threshold;
|
|
|
|
|
|
|
|
// cTerrainCompositionGen overrides:
|
2014-11-12 15:24:26 -05:00
|
|
|
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape) override;
|
2013-10-11 04:18:01 -04:00
|
|
|
virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
|
2013-03-11 13:15:34 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-05 15:56:45 -04:00
|
|
|
|
2014-10-19 08:01:59 -04:00
|
|
|
/** Caches most-recently-used chunk composition of another composition generator. Caches only the types and metas */
|
2013-05-05 15:56:45 -04:00
|
|
|
class cCompoGenCache :
|
|
|
|
public cTerrainCompositionGen
|
|
|
|
{
|
|
|
|
public:
|
2014-10-19 08:01:59 -04:00
|
|
|
cCompoGenCache(cTerrainCompositionGenPtr a_Underlying, int a_CacheSize); // Doesn't take ownership of a_Underlying
|
2013-05-05 15:56:45 -04:00
|
|
|
~cCompoGenCache();
|
|
|
|
|
|
|
|
// cTerrainCompositionGen override:
|
2014-11-12 15:24:26 -05:00
|
|
|
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape) override;
|
2013-10-11 04:18:01 -04:00
|
|
|
virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
|
2013-05-05 15:56:45 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2014-10-19 08:01:59 -04:00
|
|
|
cTerrainCompositionGenPtr m_Underlying;
|
2013-05-05 15:56:45 -04:00
|
|
|
|
|
|
|
struct sCacheData
|
|
|
|
{
|
|
|
|
int m_ChunkX;
|
|
|
|
int m_ChunkZ;
|
|
|
|
cChunkDef::BlockTypes m_BlockTypes;
|
|
|
|
cChunkDesc::BlockNibbleBytes m_BlockMetas; // The metas are uncompressed, 1 meta per byte
|
2014-11-13 15:28:50 -05:00
|
|
|
cChunkDef::HeightMap m_HeightMap;
|
2013-05-05 15:56:45 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
// To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data
|
|
|
|
int m_CacheSize;
|
|
|
|
int * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
|
|
|
|
sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
|
|
|
|
|
|
|
|
// Cache statistics
|
|
|
|
int m_NumHits;
|
|
|
|
int m_NumMisses;
|
|
|
|
int m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|