summaryrefslogtreecommitdiffstats
path: root/src/VoronoiMap.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-09-15 22:34:33 +0200
committermadmaxoft <github@xoft.cz>2014-09-15 22:34:33 +0200
commit96f45a48d4eb757096bc325f45729a21fba72caf (patch)
tree0a09889a879f111426d4f609b86eefbfa20f70b5 /src/VoronoiMap.h
parentQtBiomeVisualiser: Fixed colors and read failures. (diff)
downloadcuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar.gz
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar.bz2
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar.lz
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar.xz
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.tar.zst
cuberite-96f45a48d4eb757096bc325f45729a21fba72caf.zip
Diffstat (limited to 'src/VoronoiMap.h')
-rw-r--r--src/VoronoiMap.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/VoronoiMap.h b/src/VoronoiMap.h
index 84cf206e9..49f6c1da1 100644
--- a/src/VoronoiMap.h
+++ b/src/VoronoiMap.h
@@ -18,18 +18,28 @@
class cVoronoiMap
{
public:
- cVoronoiMap(int a_Seed, int a_CellSize = 128);
+ cVoronoiMap(int a_Seed, int a_CellSize = 128, int a_JitterSize = 128);
- /// Sets the cell size used for generating the Voronoi seeds
+ /** Sets both the cell size and jitter size used for generating the Voronoi seeds. */
void SetCellSize(int a_CellSize);
+
+ /** Sets the jitter size. Clamps it to current cell size. */
+ void SetJitterSize(int a_JitterSize);
+
+ /** Sets the offset that is added to each odd row of cells.
+ This offset makes the voronoi cells align to a non-grid.
+ Clamps the value to [-m_CellSize, +m_CellSize]. */
+ void SetOddRowOffset(int a_OddRowOffset);
- /// Returns the value in the cell into which the specified point lies
+ /** Returns the value in the cell into which the specified point lies. */
int GetValueAt(int a_X, int a_Y);
- /// Returns the value in the cell into which the specified point lies, and the distance to the nearest Voronoi seed
+ /** Returns the value in the cell into which the specified point lies,
+ and the distance to the nearest Voronoi seed. */
int GetValueAt(int a_X, int a_Y, int & a_MinDistance);
- /// Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds. Uses a cache
+ /** Returns the value in the cell into which the specified point lies,
+ and the distances to the 2 nearest Voronoi seeds. Uses a cache. */
int GetValueAt(int a_X, int a_Y, int & a_MinDistance1, int & a_MinDistance2);
protected:
@@ -38,8 +48,17 @@ protected:
cNoise m_Noise2;
cNoise m_Noise3;
- /// Size of the Voronoi cells (avg X/Y distance between the seeds)
+ /** Size of the Voronoi cells (avg X/Y distance between the seeds). Expected to be at least 2. */
int m_CellSize;
+
+ /** The amount that the cell seeds may be offset from the grid.
+ Expected to be at least 1 and less than m_CellSize. */
+ int m_JitterSize;
+
+ /** The constant amount that the cell seeds of every odd row will be offset from the grid.
+ This allows us to have non-rectangular grids.
+ Expected to be between -m_CellSize and +m_CellSize. */
+ int m_OddRowOffset;
/** The X coordinate of the currently cached cell neighborhood */
int m_CurrentCellX;