Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <VoronoiMap.h>
Public Member Functions | |
cVoronoiMap (int a_Seed, int a_CellSize=128, int a_JitterSize=128) | |
void | FindNearestSeeds (int a_X, int a_Y, int &a_NearestSeedX, int &a_NearestSeedY, int &a_SecondNearestSeedX, int &a_SecondNearestSeedY) |
Finds the nearest and second nearest seeds, returns their coords. More... | |
int | GetValueAt (int a_X, int a_Y) |
Returns the value in the cell into which the specified point lies. More... | |
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 distance to the nearest Voronoi seed. More... | |
int | GetValueAt (int a_X, int a_Y, int &a_NearestSeedX, int &a_NearestSeedY, int &a_MinDist2) |
Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds. More... | |
void | SetCellSize (int a_CellSize) |
Sets both the cell size and jitter size used for generating the Voronoi seeds. More... | |
void | SetJitterSize (int a_JitterSize) |
Sets the jitter size. More... | |
void | SetOddRowOffset (int a_OddRowOffset) |
Sets the offset that is added to each odd row of cells. More... | |
Protected Member Functions | |
void | UpdateCell (int a_CellX, int a_CellZ) |
Updates the cached cell seeds to match the specified cell. More... | |
Protected Attributes | |
int | m_CellSize |
Size of the Voronoi cells (avg X / Y distance between the seeds). More... | |
int | m_CurrentCellX |
The X coordinate of the currently cached cell neighborhood. More... | |
int | m_CurrentCellZ |
The Z coordinate of the currently cached cell neighborhood. More... | |
int | m_JitterSize |
The amount that the cell seeds may be offset from the grid. More... | |
cNoise | m_Noise1 |
The noise used for generating Voronoi seeds. More... | |
cNoise | m_Noise2 |
cNoise | m_Noise3 |
int | m_OddRowOffset |
The constant amount that the cell seeds of every odd row will be offset from the grid. More... | |
int | m_SeedX [5][5] |
The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords. More... | |
int | m_SeedZ [5][5] |
The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords. More... | |
Definition at line 18 of file VoronoiMap.h.
cVoronoiMap::cVoronoiMap | ( | int | a_Seed, |
int | a_CellSize = 128 , |
||
int | a_JitterSize = 128 |
||
) |
Definition at line 13 of file VoronoiMap.cpp.
void cVoronoiMap::FindNearestSeeds | ( | int | a_X, |
int | a_Y, | ||
int & | a_NearestSeedX, | ||
int & | a_NearestSeedY, | ||
int & | a_SecondNearestSeedX, | ||
int & | a_SecondNearestSeedY | ||
) |
Finds the nearest and second nearest seeds, returns their coords.
Definition at line 131 of file VoronoiMap.cpp.
int cVoronoiMap::GetValueAt | ( | int | a_X, |
int | a_Y | ||
) |
Returns the value in the cell into which the specified point lies.
Definition at line 60 of file VoronoiMap.cpp.
int cVoronoiMap::GetValueAt | ( | int | a_X, |
int | a_Y, | ||
int & | a_MinDistance | ||
) |
Returns the value in the cell into which the specified point lies, and the distance to the nearest Voronoi seed.
Definition at line 70 of file VoronoiMap.cpp.
int cVoronoiMap::GetValueAt | ( | int | a_X, |
int | a_Y, | ||
int & | a_NearestSeedX, | ||
int & | a_NearestSeedY, | ||
int & | a_MinDist2 | ||
) |
Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds.
Uses a cache.
Definition at line 82 of file VoronoiMap.cpp.
void cVoronoiMap::SetCellSize | ( | int | a_CellSize | ) |
Sets both the cell size and jitter size used for generating the Voronoi seeds.
Definition at line 29 of file VoronoiMap.cpp.
void cVoronoiMap::SetJitterSize | ( | int | a_JitterSize | ) |
void cVoronoiMap::SetOddRowOffset | ( | int | a_OddRowOffset | ) |
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].
Definition at line 51 of file VoronoiMap.cpp.
|
protected |
Updates the cached cell seeds to match the specified cell.
Noop if cell pos already matches. Updates m_SeedX and m_SeedZ.
Definition at line 183 of file VoronoiMap.cpp.
|
protected |
Size of the Voronoi cells (avg X / Y distance between the seeds).
Expected to be at least 2.
Definition at line 63 of file VoronoiMap.h.
|
protected |
The X coordinate of the currently cached cell neighborhood.
Definition at line 75 of file VoronoiMap.h.
|
protected |
The Z coordinate of the currently cached cell neighborhood.
Definition at line 78 of file VoronoiMap.h.
|
protected |
The amount that the cell seeds may be offset from the grid.
Expected to be at least 1 and less than m_CellSize.
Definition at line 67 of file VoronoiMap.h.
|
protected |
The noise used for generating Voronoi seeds.
Definition at line 58 of file VoronoiMap.h.
|
protected |
Definition at line 59 of file VoronoiMap.h.
|
protected |
Definition at line 60 of file VoronoiMap.h.
|
protected |
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.
Definition at line 72 of file VoronoiMap.h.
|
protected |
The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords.
Definition at line 81 of file VoronoiMap.h.
|
protected |
The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords.
Definition at line 84 of file VoronoiMap.h.