From 6e196c2ce4285c0aea2a5c714e842d90c1b84b43 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 1 Feb 2011 03:06:02 +0200 Subject: partly working chunk-based map generator (doesn't save properly, spawn is pretty random) --- src/voxel.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/voxel.h') diff --git a/src/voxel.h b/src/voxel.h index ff5d534cb..89333159c 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -262,7 +262,31 @@ public: { return index(p.X, p.Y, p.Z); } + + // Translate index in the X coordinate + void add_x(const v3s16 &extent, u32 &i, s16 a) + { + i += a; + } + // Translate index in the Y coordinate + void add_y(const v3s16 &extent, u32 &i, s16 a) + { + i += a * extent.X; + } + // Translate index in the Z coordinate + void add_z(const v3s16 &extent, u32 &i, s16 a) + { + i += a * extent.X*extent.Y; + } + // Translate index in space + void add_p(const v3s16 &extent, u32 &i, v3s16 a) + { + i += a.Z*extent.X*extent.Y + a.Y*extent.X + a.X; + } + /* + Print method for debugging + */ void print(std::ostream &o) const { v3s16 e = getExtent(); @@ -394,6 +418,10 @@ public: */ void copyFrom(MapNode *src, VoxelArea src_area, v3s16 from_pos, v3s16 to_pos, v3s16 size); + + // Copy data + void copyTo(MapNode *dst, VoxelArea dst_area, + v3s16 dst_pos, v3s16 from_pos, v3s16 size); /* Algorithms -- cgit v1.2.3