Class AStarBase

java.lang.Object
com.hypixel.hytale.server.npc.navigation.AStarBase
Direct Known Subclasses:
AStarWithTarget

public class AStarBase extends Object
  • Field Details

    • FULL_STEP_THRESHOLD

      public static final double FULL_STEP_THRESHOLD
      See Also:
    • REQUIRED_TARGET_DISTANCE

      public static final double REQUIRED_TARGET_DISTANCE
      See Also:
    • HALF_STEP_THRESHOLD

      public static final double HALF_STEP_THRESHOLD
      See Also:
    • ON_GRID_THRESHOLD

      public static final double ON_GRID_THRESHOLD
      See Also:
    • INDEX_FRACTIONAL_BITS

      protected static final int INDEX_FRACTIONAL_BITS
      See Also:
    • POSITION_BITS

      protected static final int POSITION_BITS
      See Also:
    • POSITION_OFFSET

      protected static final int POSITION_OFFSET
      See Also:
    • POSITION_MASK

      protected static final int POSITION_MASK
      See Also:
    • maxPathLength

      protected int maxPathLength
    • openNodesLimit

      protected int openNodesLimit
    • totalNodesLimit

      protected int totalNodesLimit
    • canMoveDiagonal

      protected boolean canMoveDiagonal
    • optimizedBuildPath

      protected boolean optimizedBuildPath
    • isAvoidingBlockDamage

      protected boolean isAvoidingBlockDamage
    • isRelaxedMoveConstraints

      protected boolean isRelaxedMoveConstraints
    • startPosition

      protected final Vector3d startPosition
    • evaluator

      protected AStarEvaluator evaluator
    • positionToIndexOffsetX

      protected double positionToIndexOffsetX
    • positionToIndexOffsetY

      protected double positionToIndexOffsetY
    • positionToIndexOffsetZ

      protected double positionToIndexOffsetZ
    • indexToPositionOffsetX

      protected long indexToPositionOffsetX
    • indexToPositionOffsetY

      protected long indexToPositionOffsetY
    • indexToPositionOffsetZ

      protected long indexToPositionOffsetZ
    • startPositionIndex

      protected long startPositionIndex
    • is2D

      protected boolean is2D
    • projectedX

      protected boolean projectedX
    • projectedY

      protected boolean projectedY
    • projectedZ

      protected boolean projectedZ
    • searchDirectionsWorldNormal

      protected final Vector3d searchDirectionsWorldNormal
    • searchDirectionIsDiagonalMoves

      protected boolean searchDirectionIsDiagonalMoves
    • searchDirectionIs2D

      protected boolean searchDirectionIs2D
    • searchDirections

      protected Vector3d[] searchDirections
    • searchDirectionDistances

      protected double[] searchDirectionDistances
    • inverseSearchDirections

      protected int[] inverseSearchDirections
    • normalsPerDirection

      protected int normalsPerDirection
    • normalDirections

      protected int[] normalDirections
    • nodePool

      protected AStarNodePool nodePool
    • openNodes

      protected final List<AStarNode> openNodes
    • visitedBlocks

      protected final it.unimi.dsi.fastutil.longs.Long2ObjectMap<AStarNode> visitedBlocks
    • iterations

      protected int iterations
    • path

      @Nullable protected AStarNode path
    • progress

      protected AStarBase.Progress progress
    • pathEnd

      protected final Vector3d pathEnd
    • tempPositionVector

      protected final Vector3d tempPositionVector
    • tempDirectionVector

      protected final Vector3d tempDirectionVector
  • Constructor Details

    • AStarBase

      public AStarBase()
  • Method Details

    • setCanMoveDiagonal

      public void setCanMoveDiagonal(boolean canMoveDiagonal)
    • setMaxPathLength

      public void setMaxPathLength(int maxPathLength)
    • setOpenNodesLimit

      public void setOpenNodesLimit(int openNodesLimit)
    • setTotalNodesLimit

      public void setTotalNodesLimit(int totalNodesLimit)
    • setStartPosition

      public void setStartPosition(@Nonnull Vector3d position)
    • getStartPosition

      @Nonnull public Vector3d getStartPosition()
    • setOptimizedBuildPath

      public void setOptimizedBuildPath(boolean optimizedBuildPath)
    • getEvaluator

      public AStarEvaluator getEvaluator()
    • getOpenNodes

      @Nonnull public List<AStarNode> getOpenNodes()
    • getOpenCount

      public int getOpenCount()
    • getVisitedBlocks

      @Nonnull public it.unimi.dsi.fastutil.longs.Long2ObjectMap<AStarNode> getVisitedBlocks()
    • getStartPositionIndex

      public long getStartPositionIndex()
    • getPath

      @Nullable public AStarNode getPath()
    • getPosition

      @Nullable public Vector3d getPosition()
    • getLength

      public int getLength()
    • getIterations

      public int getIterations()
    • getEndPosition

      @Nullable public Vector3d getEndPosition()
    • clearPath

      public void clearPath()
    • initComputePath

      public AStarBase.Progress initComputePath(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d start, AStarEvaluator evaluator, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController, @Nonnull ProbeMoveData probeMoveData, @Nonnull AStarNodePoolProvider nodePoolProvider, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • computePath

      public AStarBase.Progress computePath(@Nonnull Ref<EntityStore> ref, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController, @Nonnull ProbeMoveData probeMoveData, int nodesToProcess, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • getProgress

      public AStarBase.Progress getProgress()
    • isComputing

      public boolean isComputing()
    • buildLongestPath

      public float buildLongestPath()
    • buildFurthestPath

      public float buildFurthestPath()
    • buildBestPath

      @Nullable public AStarNode buildBestPath(@Nonnull ToFloatFunction<AStarNode> weight, @Nonnull BiFloatPredicate predicate, float initialValue)
    • findBestVisitedNode

      @Nullable public AStarNode findBestVisitedNode(@Nonnull ToFloatFunction<AStarNode> weight, @Nonnull BiFloatPredicate predicate, float initialValue)
    • buildBestPath

      @Nullable public <T> AStarNode buildBestPath(@Nonnull BiToFloatFunction<AStarNode,T> weight, @Nonnull BiFloatPredicate predicate, float initialValue, T obj)
    • findBestVisitedNode

      @Nullable public <T> AStarNode findBestVisitedNode(@Nonnull BiToFloatFunction<AStarNode,T> weight, @Nonnull BiFloatPredicate predicate, float initialValue, T obj)
    • createDebugHelper

      @Nonnull public AStarDebugBase createDebugHelper(@Nonnull com.hypixel.hytale.logger.HytaleLogger logger)
    • indexFromXYZ

      public static long indexFromXYZ(long dx, long dy, long dz)
    • zFromIndex

      public static int zFromIndex(long index)
    • yFromIndex

      public static int yFromIndex(long index)
    • xFromIndex

      public static int xFromIndex(long index)
    • positionIndexToString

      @Nonnull public static String positionIndexToString(long index)
    • setProgress

      protected AStarBase.Progress setProgress(AStarBase.Progress progress)
    • canAdvance

      @Nullable protected Vector3d canAdvance(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d startPosition, @Nonnull Vector3d destination, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController, @Nonnull ProbeMoveData probeMoveData, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • addStartNode

      protected void addStartNode(Vector3d startPosition, @Nonnull Vector3d position, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController)
    • addOpenNode

      protected void addOpenNode(@Nonnull AStarNode parentNode, int directionIndex, @Nonnull Vector3d position, long positionIndex, float cost, com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController)
    • addOpenNode

      protected void addOpenNode(@Nonnull AStarNode node, long index)
    • updateNode

      protected void updateNode(@Nonnull AStarNode node, int directionIndex, @Nonnull AStarNode targetNode, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController)
    • addOrUpdateNode

      protected void addOrUpdateNode(@Nonnull AStarNode node, int directionIndex, @Nonnull Vector3d position, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • updateNodeCost

      protected void updateNodeCost(@Nonnull AStarNode node, int directionIndex, @Nonnull AStarNode targetNode, float stepCost)
    • positionToIndex

      protected long positionToIndex(@Nonnull Vector3d position)
    • measureWalkCost

      protected float measureWalkCost(Vector3d fromPosition, Vector3d toPosition, @Nonnull com.hypixel.hytale.server.npc.movement.controllers.MotionController motionController)
    • buildPath

      protected void buildPath(@Nullable AStarNode endNode)
    • addOffsetToIndex

      protected long addOffsetToIndex(long index, long xSteps, long ySteps, long zSteps)