Class OBBImpl
java.lang.Object
com.hammy275.immersivemc.common.api_impl.hitbox.OBBImpl
- All Implemented Interfaces:
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
ConstructorDescriptionOBBImpl
(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 TypeMethodDescriptionnet.minecraft.world.phys.AABB
asAABB()
asOBB()
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. -
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. -
getUnderlyingAABB
public net.minecraft.world.phys.AABB getUnderlyingAABB()OBBs are rotated AABBs internally. This function retrieves that internal AABB.- Specified by:
getUnderlyingAABB
in interfaceOBB
- Returns:
- Internal AABB
-
getCenter
public net.minecraft.world.phys.Vec3 getCenter() -
getRotation
public org.joml.Quaternionf getRotation()OBBs are rotated AABBs internally. This function retrieves a copy of theQuaternionf
used for rotation.- Specified by:
getRotation
in interfaceOBB
- Returns:
- A copy of the internal Quaternionf.
-
getEnclosingAABB
public net.minecraft.world.phys.AABB getEnclosingAABB()- Specified by:
getEnclosingAABB
in interfaceOBB
- 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
- Specified by:
asOBB
in interfaceBoundingBox
- Returns:
- This BoundingBox as an OBB if it is one.
-
asAABB
public net.minecraft.world.phys.AABB asAABB()- Specified by:
asAABB
in interfaceBoundingBox
- Returns:
- This BoundingBox as an AABB if it is one.
-