Contents
- Description
- Nested Class Summary
- Method Summary
- Method Details
- iterateFromTo(Vector3dc, Vector3dc, BlockIterator.BlockIteratorProcedure)
- iterateFromTo(Vector3ic, Vector3ic, BlockIterator.BlockIteratorProcedure)
- iterateFromTo(double, double, double, double, double, double, BlockIterator.BlockIteratorProcedure)
- iterateFromTo(double, double, double, double, double, double, BlockIterator.BlockIteratorProcedurePlus1, T)
- iterate(Vector3dc, Vector3dc, double, BlockIterator.BlockIteratorProcedure)
- iterate(double, double, double, double, double, double, double, BlockIterator.BlockIteratorProcedure)
- iterate(double, double, double, double, double, double, double, BlockIterator.BlockIteratorProcedurePlus1, T)
- isNonValidNumber(double)
- isZeroDirection(double, double, double)
Class BlockIterator
java.lang.Object
com.hypixel.hytale.math.iterator.BlockIterator
This class does a full block iteration from a position by a direction until it reaches a maximum distance.
The line, generated does not allow to have diagonal jumps. A block always has a direct neighbor. Once the
iteration reaches maximum distance, it stop the iteration.
O O O O O O O O X X X
O O O O O O X X X O O
O O O O X X X O O O O
O O X X X O O O O O O
X X X O O O O O O O O
This class is also ThreadSafe and can be called from multiple Threads at the same time. There is no memory allocation during the iteration process.
This class makes use of the functional interface BlockIteratorProcedure.
- Since:
- 15.06.2016
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis functional interface accepts the currently iterating block and also the entry / exit point of the ray.static interface -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisNonValidNumber(double d) Checks if a value is a valid double number.static booleanisZeroDirection(double dx, double dy, double dz) Checks if the given direction is a zero-vector or close to a zero-vector.static booleaniterate(double sx, double sy, double sz, double dx, double dy, double dz, double maxDistance, BlockIterator.BlockIteratorProcedure procedure) Internal method to do the actual iteration.static <T> booleaniterate(double sx, double sy, double sz, double dx, double dy, double dz, double maxDistance, BlockIterator.BlockIteratorProcedurePlus1<T> procedure, T obj1) Internal method to do the actual iteration.static booleaniterate(org.joml.Vector3dc origin, org.joml.Vector3dc direction, double maxDistance, BlockIterator.BlockIteratorProcedure procedure) Iterates from an origin vector into a given direction until it reaches the maximum distance.static booleaniterateFromTo(double sx, double sy, double sz, double tx, double ty, double tz, BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.static <T> booleaniterateFromTo(double sx, double sy, double sz, double tx, double ty, double tz, BlockIterator.BlockIteratorProcedurePlus1<T> procedure, T t) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.static booleaniterateFromTo(org.joml.Vector3dc origin, org.joml.Vector3dc target, BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.static booleaniterateFromTo(org.joml.Vector3ic origin, org.joml.Vector3ic target, BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.
-
Method Details
-
iterateFromTo
public static boolean iterateFromTo(@Nonnull org.joml.Vector3dc origin, @Nonnull org.joml.Vector3dc target, @Nonnull BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.- Parameters:
origin- Ray-origintarget- Ray-targetprocedure- Procedure to handle found blocks
-
iterateFromTo
public static boolean iterateFromTo(@Nonnull org.joml.Vector3ic origin, @Nonnull org.joml.Vector3ic target, @Nonnull BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.- Parameters:
origin- Ray-origintarget- Ray-targetprocedure- Procedure to handle found blocks
-
iterateFromTo
public static boolean iterateFromTo(double sx, double sy, double sz, double tx, double ty, double tz, @Nonnull BlockIterator.BlockIteratorProcedure procedure) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.- Parameters:
sx- X-coordinate of ray-originsy- Y-coordinate of ray-originsz- Z-coordinate of ray-origintx- X-coordinate of ray-targetty- Y-coordinate of ray-targettz- Z-coordinate of ray-targetprocedure- Procedure to handle found blocks
-
iterateFromTo
public static <T> boolean iterateFromTo(double sx, double sy, double sz, double tx, double ty, double tz, @Nonnull BlockIterator.BlockIteratorProcedurePlus1<T> procedure, T t) Iterates from a Vector3d to another Vector3d and reports found blocks to the passed procedure.- Parameters:
sx- X-coordinate of ray-originsy- Y-coordinate of ray-originsz- Z-coordinate of ray-origintx- X-coordinate of ray-targetty- Y-coordinate of ray-targettz- Z-coordinate of ray-targetprocedure- Procedure to handle found blocks
-
iterate
public static boolean iterate(@Nonnull org.joml.Vector3dc origin, @Nonnull org.joml.Vector3dc direction, double maxDistance, @Nonnull BlockIterator.BlockIteratorProcedure procedure) Iterates from an origin vector into a given direction until it reaches the maximum distance. Reports found blocks to the passed procedure.- Parameters:
origin- Ray-origindirection- Ray-directionmaxDistance- Maximum distance to iterate overprocedure- Procedure to handle found blocks
-
iterate
public static boolean iterate(double sx, double sy, double sz, double dx, double dy, double dz, double maxDistance, @Nonnull BlockIterator.BlockIteratorProcedure procedure) Internal method to do the actual iteration. It has O(n) runtime, where n is the maxDistance. It may abort early if the passed BlockIteratorProcedure returns false.- Parameters:
sx- X-coordinate of ray-originsy- Y-coordinate of ray-originsz- Z-coordinate of ray-origindx- X-value for ray-directiondy- Y-value for ray-directiondz- Z-value for ray-directionmaxDistance- Maximum distance to iterate over the rayprocedure- Procedure to report blocks
-
iterate
public static <T> boolean iterate(double sx, double sy, double sz, double dx, double dy, double dz, double maxDistance, @Nonnull BlockIterator.BlockIteratorProcedurePlus1<T> procedure, T obj1) Internal method to do the actual iteration. It has O(n) runtime, where n is the maxDistance. It may abort early if the passed BlockIteratorProcedure returns false.- Parameters:
sx- X-coordinate of ray-originsy- Y-coordinate of ray-originsz- Z-coordinate of ray-origindx- X-value for ray-directiondy- Y-value for ray-directiondz- Z-value for ray-directionmaxDistance- Maximum distance to iterate over the rayprocedure- Procedure to report blocks
-
isNonValidNumber
public static boolean isNonValidNumber(double d) Checks if a value is a valid double number.- Parameters:
d- Value- Returns:
- TRUE if a valid number
-
isZeroDirection
public static boolean isZeroDirection(double dx, double dy, double dz) Checks if the given direction is a zero-vector or close to a zero-vector. It uses the same rounding error as the BlockIterator algorithm.- Parameters:
dx- X-value for ray-directiondy- Y-value for ray-directiondz- Z-value for ray-direction- Returns:
- TRUE if direction is a zero-vector
-