intersectsPlane method

bool intersectsPlane(
  1. Plane plane
)

Returns true if the given plane intersects this OBB.

Reference: Testing Box Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.3)

Implementation

bool intersectsPlane(Plane plane ) {
	rotation.extractBasis( _xAxis, _yAxis, _zAxis );

	// compute the projection interval radius of this OBB onto L(t) = this->center + t * p.normal;
	final r = halfSizes.x * plane.normal.dot( _xAxis ).abs(  ) +
			halfSizes.y * plane.normal.dot( _yAxis ).abs(  ) +
			halfSizes.z * plane.normal.dot( _zAxis ).abs(  );

	// compute distance of the OBB's center from the plane
	final d = plane.normal.dot( center ) - plane.constant;

	// Intersection occurs when distance d falls within [-r,+r] interval
	return d.abs() <= r;
}