java.lang.Object
com.hammy275.immersivemc.common.api_impl.hitbox.OBBImpl
All Implemented Interfaces:
BoundingBox, OBB

public class OBBImpl extends Object implements BoundingBox, OBB
Oriented Bounding Box. This is similar to an Axis-Aligned Bounding Box (AABB), but rotatable. OBBs allow for better accuracy at the cost of a significant performance hit. Internally, the OBB is an AABB, but rotated by some amount on the X, Y, and Z axis. All rotations are in radians.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OBBImpl(net.minecraft.world.phys.AABB aabb)
    Create an OBB from an existing AABB.
    OBBImpl(net.minecraft.world.phys.AABB aabb, double pitch, double yaw, double roll)
    Create an OBB from an existing AABB, rotated on the axes in the order yaw, pitch, roll.
    OBBImpl(net.minecraft.world.phys.AABB aabb, org.joml.Quaternionf rotation)
    Create an OBB from an existing AABB, rotated by some arbitrary rotations.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.phys.AABB
     
     
    boolean
    contains(net.minecraft.world.phys.Vec3 point)
    Whether a given point can be found inside this OBB.
    net.minecraft.world.phys.Vec3
     
    net.minecraft.world.phys.AABB
     
    org.joml.Quaternionf
    OBBs are rotated AABBs internally.
    net.minecraft.world.phys.AABB
    OBBs are rotated AABBs internally.
    Optional<net.minecraft.world.phys.Vec3>
    rayHit(net.minecraft.world.phys.Vec3 rayStart, net.minecraft.world.phys.Vec3 rayEnd)
    Where the provided ray intersects this OBB the soonest.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.hammy275.immersivemc.api.common.hitbox.BoundingBox

    isAABB, isOBB
  • Constructor Details

    • OBBImpl

      public OBBImpl(net.minecraft.world.phys.AABB aabb)
      Create an OBB from an existing AABB.
      Parameters:
      aabb - The AABB to create an OBB from.
    • OBBImpl

      public OBBImpl(net.minecraft.world.phys.AABB aabb, double pitch, double yaw, double roll)
      Create an OBB from an existing AABB, rotated on the axes in the order yaw, pitch, roll.
      Parameters:
      aabb - The AABB to create an OBB from.
      pitch - The pitch of the OBB, in radians.
      yaw - The yaw of the OBB, in radians,
      roll - The roll of the OBB, in radians
    • OBBImpl

      public OBBImpl(net.minecraft.world.phys.AABB aabb, org.joml.Quaternionf rotation)
      Create an OBB from an existing AABB, rotated by some arbitrary rotations.
      Parameters:
      aabb - The AABB to create an OBB from.
      rotation - The quaternion representing the rotations applied to this OBB.
  • Method Details

    • contains

      public boolean contains(net.minecraft.world.phys.Vec3 point)
      Whether a given point can be found inside this OBB.
      Specified by:
      contains in interface OBB
      Parameters:
      point - Point to check.
      Returns:
      Whether the point is in this OBB or not.
    • rayHit

      public Optional<net.minecraft.world.phys.Vec3> rayHit(net.minecraft.world.phys.Vec3 rayStart, net.minecraft.world.phys.Vec3 rayEnd)
      Where the provided ray intersects this OBB the soonest.
      Specified by:
      rayHit in interface OBB
      Parameters:
      rayStart - Start of ray
      rayEnd - End of ray
      Returns:
      An optional containing where they ray hit this OBB, or an empty Optional if there was no hit.
    • getUnderlyingAABB

      public net.minecraft.world.phys.AABB getUnderlyingAABB()
      OBBs are rotated AABBs internally. This function retrieves that internal AABB.
      Specified by:
      getUnderlyingAABB in interface OBB
      Returns:
      Internal AABB
    • getCenter

      public net.minecraft.world.phys.Vec3 getCenter()
      Specified by:
      getCenter in interface OBB
      Returns:
      The center of this OBB
    • getRotation

      public org.joml.Quaternionf getRotation()
      OBBs are rotated AABBs internally. This function retrieves a copy of the Quaternionf used for rotation.
      Specified by:
      getRotation in interface OBB
      Returns:
      A copy of the internal Quaternionf.
    • getEnclosingAABB

      public net.minecraft.world.phys.AABB getEnclosingAABB()
      Specified by:
      getEnclosingAABB in interface OBB
      Returns:
      A reasonably-sized AABB guaranteed to contain this OBB. Bad for collision checks, as it tends to be significantly larger than the actual OBB, but good for detecting things that should then be detected on this OBB.
    • asOBB

      public OBBImpl asOBB()
      Specified by:
      asOBB in interface BoundingBox
      Returns:
      This BoundingBox as an OBB if it is one.
    • asAABB

      public net.minecraft.world.phys.AABB asAABB()
      Specified by:
      asAABB in interface BoundingBox
      Returns:
      This BoundingBox as an AABB if it is one.