From 41e0927843a8060fc381e7695faf4cf8d3c875e6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 31 Mar 2013 19:05:41 +0000 Subject: cChunkDesc: Added the RandomFillRelCuboid() function git-svn-id: http://mc-server.googlecode.com/svn/trunk@1341 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Generating/ChunkDesc.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source/Generating/ChunkDesc.cpp') diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp index 81e6851a4..f0927f294 100644 --- a/source/Generating/ChunkDesc.cpp +++ b/source/Generating/ChunkDesc.cpp @@ -7,6 +7,7 @@ #include "ChunkDesc.h" #include "../BlockArea.h" #include "../Cuboid.h" +#include "../Noise.h" @@ -489,6 +490,42 @@ void cChunkDesc::FloorRelCuboid( +void cChunkDesc::RandomFillRelCuboid( + int a_MinX, int a_MaxX, + int a_MinY, int a_MaxY, + int a_MinZ, int a_MaxZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, + int a_RandomSeed, int a_ChanceOutOf10k +) +{ + cNoise Noise(a_RandomSeed); + int MinX = std::max(a_MinX, 0); + int MinY = std::max(a_MinY, 0); + int MinZ = std::max(a_MinZ, 0); + int MaxX = std::min(a_MaxX, cChunkDef::Width - 1); + int MaxY = std::min(a_MaxY, cChunkDef::Height - 1); + int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1); + + for (int y = MinY; y <= MaxY; y++) + { + for (int z = MinZ; z <= MaxZ; z++) + { + for (int x = MinX; x <= MaxX; x++) + { + int rnd = (Noise.IntNoise3DInt(x, y, z) / 7) % 10000; + if (rnd <= a_ChanceOutOf10k) + { + SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta); + } + } + } // for z + } // for y +} + + + + + void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas) { const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas(); -- cgit v1.2.3