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
ConstructorsConstructorDescriptionOBBImpl(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.AABBasAABB()asOBB()booleancontains(net.minecraft.world.phys.Vec3 point) Whether a given point can be found inside this OBB.net.minecraft.world.phys.Vec3net.minecraft.world.phys.AABBorg.joml.QuaternionfOBBs are rotated AABBs internally.net.minecraft.world.phys.AABBOBBs are rotated AABBs internally.move(net.minecraft.world.phys.Vec3 movement) Creates a new OBB which is this OBB, but moved by some amount.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, waitMethods 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:
getUnderlyingAABBin 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 theQuaternionfused for rotation.- Specified by:
getRotationin interfaceOBB- Returns:
- A copy of the internal Quaternionf.
-
getEnclosingAABB
public net.minecraft.world.phys.AABB getEnclosingAABB()- Specified by:
getEnclosingAABBin 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.
-
move
Description copied from interface:OBBCreates a new OBB which is this OBB, but moved by some amount. -
asOBB
- Specified by:
asOBBin interfaceBoundingBox- Returns:
- This BoundingBox as an OBB if it is one.
-
asAABB
public net.minecraft.world.phys.AABB asAABB()- Specified by:
asAABBin interfaceBoundingBox- Returns:
- This BoundingBox as an AABB if it is one.
-