summaryrefslogtreecommitdiffstats
path: root/src/Generating/GridStructGen.h
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-06-16 16:22:02 +0200
committerTycho <work.tycho+git@gmail.com>2014-06-16 16:22:02 +0200
commitd5c84b5fe6358c0763f2b5695914ff34c74dd912 (patch)
tree96b703b1a7e052f74a8d270fb0278e5acb70435a /src/Generating/GridStructGen.h
parentMoved repeater handling to seperate pass (diff)
parentMerge branch 'master' of github.com:mc-server/MCServer (diff)
downloadcuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar.gz
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar.bz2
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar.lz
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar.xz
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.tar.zst
cuberite-d5c84b5fe6358c0763f2b5695914ff34c74dd912.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/GridStructGen.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h
index 630a5e44e..03131fce9 100644
--- a/src/Generating/GridStructGen.h
+++ b/src/Generating/GridStructGen.h
@@ -10,6 +10,7 @@
#pragma once
#include "ComposableGenerator.h"
+#include "../Noise.h"
@@ -19,7 +20,12 @@
Defines a grid in the XZ space with predefined cell size in each direction. Each cell then receives exactly
one structure (provided by the descendant class). The structure is placed within the cell, but doesn't need
to be bounded by the cell, it can be well outside the cell; the generator uses the MaxStructureSize parameter
-to determine how far away from the cell the structure can be at most.
+to determine how far away from the cell the structure can be at most. Each structure has an offset from the
+grid's center point, the offset is generated randomly from a range given to this class as a parameter.
+
+Each structure thus contains the coords of its grid center (m_GridX, m_GridZ) and the actual origin from
+which it's built (m_OriginX, m_OriginZ).
+
This class provides a cache for the structures generated for successive chunks and manages that cache. It
also provides the cFinishGen override that uses the cache to actually generate the structure into chunk data.
@@ -43,12 +49,17 @@ public:
class cStructure
{
public:
- /** The origin (the coords of the gridpoint for which the structure is generated) */
+ /** The grid point for which the structure is generated. */
+ int m_GridX, m_GridZ;
+
+ /** The origin (the coords for which the structure is generated) */
int m_OriginX, m_OriginZ;
- /** Creates a structure that has its originset at the specified coords. */
- cStructure (int a_OriginX, int a_OriginZ) :
+ /** Creates a structure that has its origin set at the specified coords. */
+ cStructure (int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) :
+ m_GridX(a_GridX),
+ m_GridZ(a_GridZ),
m_OriginX(a_OriginX),
m_OriginZ(a_OriginZ)
{
@@ -70,20 +81,30 @@ public:
cGridStructGen(
int a_Seed,
int a_GridSizeX, int a_GridSizeZ,
+ int a_MaxOffsetX, int a_MaxOffsetZ,
int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
size_t a_MaxCacheSize
);
protected:
- /** Seed for generating the semi-random grid. */
+ /** Seed for generating grid offsets and also available for descendants. */
int m_Seed;
+ /** The noise used for generating grid offsets. */
+ cNoise m_Noise;
+
/** The size of each grid's cell in the X axis */
int m_GridSizeX;
/** The size of each grid's cell in the Z axis */
int m_GridSizeZ;
+ /** The maximum offset of the structure's origin from the grid midpoint, in X coord. */
+ int m_MaxOffsetX;
+
+ /** The maximum offset of the structure's origin from the grid midpoint, in Z coord. */
+ int m_MaxOffsetZ;
+
/** Maximum theoretical size of the structure in the X axis.
This limits the structures considered for a single chunk, so the lesser the number, the better performance.
Structures large than this may get cropped. */
@@ -115,7 +136,7 @@ protected:
// Functions for the descendants to override:
/** Create a new structure at the specified gridpoint */
- virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) = 0;
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) = 0;
} ;