Class SweptSphereMath

java.lang.Object
com.hypixel.hytale.server.core.modules.collision.SweptSphereMath

public final class SweptSphereMath extends Object
Swept sphere tests against boxes.

A sweep moves the sphere center from start to start + dir. A hit fraction t in [0, 1] puts the center at start + t * dir at the first contact. The sphere touches a box when its center enters the box grown by the radius, with rounded edges and corners (Ericson, Real-Time Collision Detection, section 5.5.7).

Every method writes the result to minMax: x is the entry fraction and y is the exit fraction of the grown box without rounding. No method allocates.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    intersectSweptSphereAABB(double startX, double startY, double startZ, double dirX, double dirY, double dirZ, double radius, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, org.joml.Vector2d minMax)
    Sweeps a sphere against an axis-aligned box given by its corners.
    static boolean
    intersectSweptSphereAABB(org.joml.Vector3dc start, org.joml.Vector3dc dir, double radius, double boxX, double boxY, double boxZ, Box box, org.joml.Vector2d minMax)
    Sweeps a sphere against a box that is axis-aligned in world space.
    static boolean
    intersectSweptSphereRotatedAABB(org.joml.Vector3dc start, org.joml.Vector3dc dir, double radius, org.joml.Vector3dc pivot, double yaw, org.joml.Vector3dc offset, Box box, org.joml.Vector2d minMax)
    Sweeps a sphere against a box that turns with its owner's yaw.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • intersectSweptSphereAABB

      public static boolean intersectSweptSphereAABB(@Nonnull org.joml.Vector3dc start, @Nonnull org.joml.Vector3dc dir, double radius, double boxX, double boxY, double boxZ, @Nonnull Box box, @Nonnull org.joml.Vector2d minMax)
      Sweeps a sphere against a box that is axis-aligned in world space.
      Parameters:
      start - The sphere center at the start of the sweep.
      dir - The movement of the sphere center over the sweep.
      radius - The sphere radius.
      boxX - The x position of the box origin.
      boxY - The y position of the box origin.
      boxZ - The z position of the box origin.
      box - The box, relative to its origin.
      minMax - The output entry and exit fractions.
      Returns:
      true when the sphere touches the box within the sweep.
    • intersectSweptSphereRotatedAABB

      public static boolean intersectSweptSphereRotatedAABB(@Nonnull org.joml.Vector3dc start, @Nonnull org.joml.Vector3dc dir, double radius, @Nonnull org.joml.Vector3dc pivot, double yaw, @Nonnull org.joml.Vector3dc offset, @Nonnull Box box, @Nonnull org.joml.Vector2d minMax)
      Sweeps a sphere against a box that turns with its owner's yaw.

      The box is axis-aligned in the owner's model frame. A world point w maps to pivot + rotateY(yaw, offset + local). The test runs in the model frame, where the sphere keeps its shape and the box stays axis-aligned. A rigid transform keeps the hit fraction, so start + t * dir stays valid in world space.

      Parameters:
      start - The sphere center at the start of the sweep, in world space.
      dir - The movement of the sphere center over the sweep, in world space.
      radius - The sphere radius.
      pivot - The owner's world position.
      yaw - The owner's yaw, in radians, with the convention of Vector3d.rotateY.
      offset - The box origin in the owner's model frame.
      box - The box, relative to offset.
      minMax - The output entry and exit fractions.
      Returns:
      true when the sphere touches the box within the sweep.
    • intersectSweptSphereAABB

      public static boolean intersectSweptSphereAABB(double startX, double startY, double startZ, double dirX, double dirY, double dirZ, double radius, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, @Nonnull org.joml.Vector2d minMax)
      Sweeps a sphere against an axis-aligned box given by its corners.
      Returns:
      true when the sphere touches the box within the sweep.