OrientedBoundingBox

public class OrientedBoundingBox

Represents a bounding box that can be rotated in any direction. Unlike an axis-aligned bounding box, this can rotate with the model. Optimized for performance with object reuse and dirty flag system. Now supports dynamic scaling.

Constructors

Link copied to clipboard
public void OrientedBoundingBox(Vector3d center, double width, double height, double depth)
Creates an oriented bounding box
public void OrientedBoundingBox(Vector3d center, double width, double height, double depth, ModeledEntity entity)
Creates an oriented bounding box with scale support
public void OrientedBoundingBox(Location location, double width, double height, double depth)
Creates an oriented bounding box from a Bukkit location and dimensions
public void OrientedBoundingBox(Location location, double width, double height, double depth, ModeledEntity entity)
Creates an oriented bounding box from a Bukkit location and dimensions with entity reference

Properties

Link copied to clipboard
public final Vector3d baseHalfExtents
Link copied to clipboard
public final Vector3d center
Link copied to clipboard
public final Vector3d halfExtents
Link copied to clipboard
public final Matrix3d rotation
Link copied to clipboard
public double scaleModifier

Functions

Link copied to clipboard
public synchronized double centerDistanceIfIntersects(BoundingBox aabb, double x, double y, double z)
Returns the center distance when the supplied AABB intersects this exact pose, or -1 when it does not.
Link copied to clipboard
public synchronized double distanceFromCenter(double x, double y, double z)
Returns the distance from the current coherent OBB center to a point.
Link copied to clipboard
public Vector3d getBaseHalfExtents()
Link copied to clipboard
public Vector3d getCenter()
Link copied to clipboard
public synchronized Array<Vector3d> getCorners()
Gets the 8 corners of the OBB in world space
Link copied to clipboard
public Vector3d getHalfExtents()
Link copied to clipboard
public Matrix3d getRotation()
Link copied to clipboard
public double getScaleModifier()
Link copied to clipboard
public synchronized boolean intersectsAABB(BoundingBox aabb)
Exact OBB-vs-AABB intersection via the Separating Axis Theorem (15 axes).
Link copied to clipboard
public synchronized boolean intersectsAABBCoherently(BoundingBox aabb)
Runs the cheap enclosing-AABB rejection and the exact SAT test against the same pose.
Link copied to clipboard
public synchronized boolean quickAabbReject(BoundingBox aabb)
Coarse pre-filter: returns true if the AABB overlaps the OBB's enclosing world-aligned bounding box.
Link copied to clipboard
public synchronized double rayIntersection(Location eyeLocation, double maxDistance)
Checks if a ray from a player's eye location intersects with this OBB.
public synchronized double rayIntersection(double ox, double oy, double oz, double dx, double dy, double dz, double maxDistance)
Ray/segment intersection against this OBB from an explicit origin and direction.
Link copied to clipboard
public static Optional<ModeledEntity> raytraceFromPlayer(Player player)
Perform a ray trace from a player's eye location in the direction they're looking
Link copied to clipboard
public static Optional<ModeledEntity> raytraceFromPoint(World world, Location location, float maxDistance)
Perform a ray trace from a specific point in a specific direction
Link copied to clipboard
Sets the associated entity for scale calculations
Link copied to clipboard
public synchronized OrientedBoundingBox update(Location location)
Updates both position, rotation, and scale from a Location in one efficient call.
Link copied to clipboard
public static void visualizeOBB(ModeledEntity entity, int durationTicks, Player player)