summaryrefslogtreecommitdiffstats
path: root/source/Generating
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-29 21:47:51 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-29 21:47:51 +0100
commitc76092e329f421c508d42b4013f4ee151304fea6 (patch)
tree1f8e73cc81fcaaccfd1b4b0a8ecf0b2039e7e70c /source/Generating
parentCuboid: Added DoesIntersect(), more IsInside() and more constructors (diff)
downloadcuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar.gz
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar.bz2
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar.lz
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar.xz
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.tar.zst
cuberite-c76092e329f421c508d42b4013f4ee151304fea6.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/ChunkDesc.cpp57
-rw-r--r--source/Generating/ChunkDesc.h9
2 files changed, 66 insertions, 0 deletions
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index 21ebf90ec..4a1272ffd 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -6,6 +6,7 @@
#include "Globals.h"
#include "ChunkDesc.h"
#include "../BlockArea.h"
+#include "../Cuboid.h"
@@ -382,6 +383,62 @@ HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
+void cChunkDesc::FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ int MinX = std::max(a_RelCuboid.p1.x, 0);
+ int MinY = std::max(a_RelCuboid.p1.y, 0);
+ int MinZ = std::max(a_RelCuboid.p1.z, 0);
+ int MaxX = std::min(a_RelCuboid.p2.x, cChunkDef::Width - 1);
+ int MaxY = std::min(a_RelCuboid.p2.y, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_RelCuboid.p2.z, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cChunkDesc::ReplaceRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta)
+{
+ int MinX = std::max(a_RelCuboid.p1.x, 0);
+ int MinY = std::max(a_RelCuboid.p1.y, 0);
+ int MinZ = std::max(a_RelCuboid.p1.z, 0);
+ int MaxX = std::min(a_RelCuboid.p2.x, cChunkDef::Width - 1);
+ int MaxY = std::min(a_RelCuboid.p2.y, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_RelCuboid.p2.z, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ GetBlockTypeMeta(x, y, z, BlockType, BlockMeta);
+ if ((BlockType == a_SrcType) && (BlockMeta == a_SrcMeta))
+ {
+ SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
+ }
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
{
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h
index 226d22429..d4b0c4d91 100644
--- a/source/Generating/ChunkDesc.h
+++ b/source/Generating/ChunkDesc.h
@@ -19,6 +19,9 @@
// fwd: ../BlockArea.h
class cBlockArea;
+// fwd: ../Cuboid.h
+class cCuboid;
+
@@ -76,6 +79,12 @@ public:
/// Returns the maximum height value in the heightmap
HEIGHTTYPE GetMaxHeight(void) const;
+ /// Fills the relative cuboid with specified block; allows cuboid out of range of this chunk
+ void FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+
+ /// Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk
+ void ReplaceRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta);
+
// tolua_end