Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- scale(double)
- invScale(double)
- getCellX(double, double)
- getCellY(double, double)
- nearest2D(int, double, double, int, int, ResultBuffer.ResultBuffer2d, PointEvaluator)
- nearest3D(int, double, double, double, int, int, int, ResultBuffer.ResultBuffer3d, PointEvaluator)
- transition2D(int, double, double, int, int, ResultBuffer.ResultBuffer2d, PointEvaluator)
- transition3D(int, double, double, double, int, int, int, ResultBuffer.ResultBuffer3d, PointEvaluator)
- evalPoint(int, double, double, int, int, ResultBuffer.ResultBuffer2d, PointEvaluator)
- evalPoint(int, double, double, double, int, int, int, ResultBuffer.ResultBuffer3d, PointEvaluator)
- evalPoint2(int, double, double, int, int, ResultBuffer.ResultBuffer2d, PointEvaluator)
- evalPoint2(int, double, double, double, int, int, int, ResultBuffer.ResultBuffer3d, PointEvaluator)
- collect(int, int, int, int, int, int, ResultBuffer.Bounds2d, T, PointConsumer, PointEvaluator)
- toString()
- getHash(int, int, int)
- toGridX(double, double)
- toGridY(double, double)
- toHexX(double, double)
- toHexY(double, double)
Class HexCellDistanceFunction
java.lang.Object
com.hypixel.hytale.procedurallib.logic.cell.HexCellDistanceFunction
- All Implemented Interfaces:
CellDistanceFunction
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHash function adapted from: https://youtu.be/LWFzPP8ZbdU? -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HexCellDistanceFunctionstatic final DoubleArray.Double2[]Maintain our own offset array to support negative values (this is possible because our toGrid methods round rather than floor values).static final CellPointFunction -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidcollect(int originalSeed, int seed, int minX, int minY, int maxX, int maxY, ResultBuffer.Bounds2d bounds, T ctx, PointConsumer<T> collector, PointEvaluator pointEvaluator) Iterate the cell-grid between the two provided corner coordinates and collect the cell centre-points of each cell visited.voidevalPoint(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Evaluate distance to the given cell centre-point recording only the closest result.voidevalPoint(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, PointEvaluator pointEvaluator) Evaluate distance to the given cell centre-point recording only the closest result.voidevalPoint2(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Evaluate distance to the given cell centre-point recording the closest and second-closest result.voidevalPoint2(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, PointEvaluator pointEvaluator) Evaluate distance to the given cell centre-point recording the closest and second-closest result.intgetCellX(double x, double y) Get the x-index of the cell that point x,y is inside.intgetCellY(double x, double y) Get the y-index of the cell that point x,y is inside.static intgetHash(int seed, int x, int y) doubleinvScale(double value) Convert the provided coordinate component to the inverse scale of this CellDistanceFunction.voidnearest2D(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, PointEvaluator pointEvaluator) Calculate the distance to the nearest cell centre-point of a 2D cell neighborhood.voidnearest3D(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Calculate the distance to the nearest cell centre-point of a 3D cell neighborhood.doublescale(double value) Convert the provided coordinate component to the scale of this CellDistanceFunction.static inttoGridX(double x, double y) static inttoGridY(double x, double y) static doubletoHexX(double hx, double hy) static doubletoHexY(double hx, double hy) toString()voidtransition2D(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, PointEvaluator pointEvaluator) Calculate the distance to the nearest and second-nearest cell centre-points of a 2D cell neighborhood.voidtransition3D(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Calculate the distance to the nearest and second-nearest cell centre-points of a 2D cell neighborhood.Methods inherited from interface CellDistanceFunction
getCellX, getCellY, getCellZ
-
Field Details
-
DISTANCE_FUNCTION
-
POINT_FUNCTION
-
HEX_CELL_2D
Maintain our own offset array to support negative values (this is possible because our toGrid methods round rather than floor values).
-
-
Constructor Details
-
HexCellDistanceFunction
public HexCellDistanceFunction()
-
-
Method Details
-
scale
public double scale(double value) Description copied from interface:CellDistanceFunctionConvert the provided coordinate component to the scale of this CellDistanceFunction.- Specified by:
scalein interfaceCellDistanceFunction- Parameters:
value- The coordinate component to scale.- Returns:
- The coordinate component scaled to this CellDistanceFunction's domain.
-
invScale
public double invScale(double value) Description copied from interface:CellDistanceFunctionConvert the provided coordinate component to the inverse scale of this CellDistanceFunction.- Specified by:
invScalein interfaceCellDistanceFunction- Parameters:
value- The coordinate component to scale.- Returns:
- The coordinate component inversely scaled from this CellDistanceFunction's domain.
-
getCellX
public int getCellX(double x, double y) Description copied from interface:CellDistanceFunctionGet the x-index of the cell that point x,y is inside.- Specified by:
getCellXin interfaceCellDistanceFunction- Parameters:
x- The x-coordinate of the point.y- The y-coordinate of the point.- Returns:
- The cell's x-index.
-
getCellY
public int getCellY(double x, double y) Description copied from interface:CellDistanceFunctionGet the y-index of the cell that point x,y is inside.- Specified by:
getCellYin interfaceCellDistanceFunction- Parameters:
x- The x-coordinate of the point.y- The y-coordinate of the point.- Returns:
- The cell's y-index.
-
nearest2D
public void nearest2D(int seed, double x, double y, int cellX, int cellY, @Nonnull ResultBuffer.ResultBuffer2d buffer, @Nonnull PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionCalculate the distance to the nearest cell centre-point of a 2D cell neighborhood.- Specified by:
nearest2Din interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.cellX- The x-index of cell to evaluate around.cellY- The y-index of cell to evaluate around.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
nearest3D
public void nearest3D(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionCalculate the distance to the nearest cell centre-point of a 3D cell neighborhood.- Specified by:
nearest3Din interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.z- The y-coordinate being sampled.cellX- The x-index of cell to evaluate around.cellY- The y-index of cell to evaluate around.cellZ- The z-index of cell to evaluate around.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
transition2D
public void transition2D(int seed, double x, double y, int cellX, int cellY, @Nonnull ResultBuffer.ResultBuffer2d buffer, @Nonnull PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionCalculate the distance to the nearest and second-nearest cell centre-points of a 2D cell neighborhood.- Specified by:
transition2Din interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.cellX- The x-index of cell to evaluate around.cellY- The y-index of cell to evaluate around.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
transition3D
public void transition3D(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionCalculate the distance to the nearest and second-nearest cell centre-points of a 2D cell neighborhood.- Specified by:
transition3Din interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.z- The y-coordinate being sampled.cellX- The x-index of cell to evaluate around.cellY- The y-index of cell to evaluate around.cellZ- The z-index of cell to evaluate around.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
evalPoint
public void evalPoint(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, @Nonnull PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionEvaluate distance to the given cell centre-point recording only the closest result.- Specified by:
evalPointin interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.cellX- The x-index of cell being evaluated.cellY- The y-index of cell being evaluated.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
evalPoint
public void evalPoint(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionEvaluate distance to the given cell centre-point recording only the closest result.- Specified by:
evalPointin interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.z- The y-coordinate being sampled.cellX- The x-index of cell being evaluated.cellY- The y-index of cell being evaluated.cellZ- The z-index of cell being evaluated.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
evalPoint2
public void evalPoint2(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, @Nonnull PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionEvaluate distance to the given cell centre-point recording the closest and second-closest result.- Specified by:
evalPoint2in interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.cellX- The x-index of cell being evaluated.cellY- The y-index of cell being evaluated.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
evalPoint2
public void evalPoint2(int seed, double x, double y, double z, int cellX, int cellY, int cellZ, ResultBuffer.ResultBuffer3d buffer, PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionEvaluate distance to the given cell centre-point recording the closest and second-closest result.- Specified by:
evalPoint2in interfaceCellDistanceFunction- Parameters:
seed- The seed being sampled.x- The x-coordinate being sampled.y- The y-coordinate being sampled.z- The y-coordinate being sampled.cellX- The x-index of cell being evaluated.cellY- The y-index of cell being evaluated.cellZ- The z-index of cell being evaluated.buffer- The buffer into which the result of the evaluation is recorded.pointEvaluator- A function that evaluates each cell centre-point.
-
collect
public <T> void collect(int originalSeed, int seed, int minX, int minY, int maxX, int maxY, @Nonnull ResultBuffer.Bounds2d bounds, T ctx, @Nonnull PointConsumer<T> collector, @Nonnull PointEvaluator pointEvaluator) Description copied from interface:CellDistanceFunctionIterate the cell-grid between the two provided corner coordinates and collect the cell centre-points of each cell visited.- Specified by:
collectin interfaceCellDistanceFunction- Type Parameters:
T- The type of the contextual information being passed to the collector.- Parameters:
originalSeed- A seed from which child-seeds may be offset.seed- The seed used to determine cell centre-points.minX- The x-index of the inclusive lower corner of the cell region.minY- The y-index of the inclusive lower corner of the cell region.maxX- The x-index of the inclusive upper corner of the cell region.maxY- The y-index of the inclusive upper corner of the cell region.bounds- The bounds that generated points must be limited to.ctx- An arbitrary piece of contextual information to pass to the collector for each point visited.collector- A consumer for each visited cell centre-point.pointEvaluator- A function that evaluates each cell centre-point.
-
toString
-
getHash
public static int getHash(int seed, int x, int y) -
toGridX
public static int toGridX(double x, double y) -
toGridY
public static int toGridY(double x, double y) -
toHexX
public static double toHexX(double hx, double hy) -
toHexY
public static double toHexY(double hx, double hy)
-