From 5fb2526e0739fa27d925a686669f2c3aef56e825 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 12 Nov 2014 21:24:26 +0100 Subject: Generator: Shape initial refactoring. The code compiles, but several structure generators are broken, crash on start. --- src/Generating/ChunkDesc.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/Generating/ChunkDesc.h') diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index 570132790..b86041a7d 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -29,10 +29,17 @@ class cChunkDesc { public: // tolua_end + + /** The datatype used to represent the entire chunk worth of shape. + 0 = air + 1 = solid + Indexed as [y + 256 * z + 256 * 16 * x]. */ + typedef Byte Shape[256 * 16 * 16]; /** Uncompressed block metas, 1 meta per byte */ typedef NIBBLETYPE BlockNibbleBytes[cChunkDef::NumBlocks]; + cChunkDesc(int a_ChunkX, int a_ChunkZ); ~cChunkDesc(); @@ -57,10 +64,21 @@ public: EMCSBiome GetBiome(int a_RelX, int a_RelZ); // These operate on the heightmap, so they could get out of sync with the data - // Use UpdateHeightmap() to re-sync + // Use UpdateHeightmap() to re-calculate heightmap from the block data void SetHeight(int a_RelX, int a_RelZ, int a_Height); int GetHeight(int a_RelX, int a_RelZ); + // tolua_end + + /** Sets the heightmap to match the given shape data. + Note that this ignores overhangs; the method is mostly used by old composition generators. */ + void SetHeightFromShape(const Shape & a_Shape); + + /** Sets the shape in a_Shape to match the heightmap stored currently in m_HeightMap. */ + void GetShapeFromHeight(Shape & a_Shape) const; + + // tolua_begin + // Default generation: void SetUseDefaultBiomes(bool a_bUseDefaultBiomes); bool IsUsingDefaultBiomes(void) const; @@ -77,8 +95,11 @@ public: /** Reads an area from the chunk into a cBlockArea, blocktypes and blockmetas */ void ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ); - /** Returns the maximum height value in the heightmap */ + /** Returns the maximum height value in the heightmap. */ HEIGHTTYPE GetMaxHeight(void) const; + + /** Returns the minimum height value in the heightmap. */ + HEIGHTTYPE GetMinHeight(void) const; /** Fills the relative cuboid with specified block; allows cuboid out of range of this chunk */ void FillRelCuboid( -- cgit v1.2.3 From 889aa7404dd37b862d8874c9d5545f51be19e17d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 15 Nov 2014 20:23:47 +0100 Subject: ChunkDesc: Fixed comment about indexing. --- src/Generating/ChunkDesc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Generating/ChunkDesc.h') diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index b86041a7d..480106fb5 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -33,7 +33,7 @@ public: /** The datatype used to represent the entire chunk worth of shape. 0 = air 1 = solid - Indexed as [y + 256 * z + 256 * 16 * x]. */ + Indexed as [y + 256 * x + 256 * 16 * z]. */ typedef Byte Shape[256 * 16 * 16]; /** Uncompressed block metas, 1 meta per byte */ -- cgit v1.2.3