I am able to resolve collision between an OBB and a plane but can't get it to work when I introduce some bounds on the plane size. I want to have the plane of width
and height
dimensions defined by a normal
and a position
.
The code for detecting/resolving is fairly simple if the plane doesn't have any bounds:
function obbIntersectsPlane( obb, plane ) {
let r = obb.size.x / 2 * Math.abs( dot( obb.right, plane.normal ) ) +
obb.size.y / 2 * Math.abs( dot( obb.up, plane.normal ) ) +
obb.size.z / 2 * Math.abs( dot( obb.forward, plane.normal ) );
let s = dot( plane.normal, obb.position ) - dot( plane.normal, plane.position );
if ( Math.abs( s ) < r ) {
return {
overlap: r - s,
vector: plane.normal
};
}
return false;
}