# OBB vs rectangle/quad/plane with bounds collision detection/response

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;
}

• Have you considered treating the quad as an extremely thin OBB? – DMGregory Oct 28 '20 at 16:51
• yeah i have already tried it and it works but am i not doing extra calculations? a quad needs 4 vertices, an obb 8. But I think i shouldn't care about that and let it be like that. I should mention that I had to tweak something in how I calculated overlaps for various axes to account for situations in which the projection of one object was completely inside the projection of the other. This is crucial if the size is close to 0 or you will have extremely slow resolution or no resolution at all when the size is absolutely 0. Edit: I think i should post the new overlap calculation code – Abhinav Singh Oct 30 '20 at 8:24

Taking the plane as an obb with depth=0 works fine for me. I had to modify how I calculated overlap though to account for cases when the projection of one object was fully inside the other object's projection.

let overlap;

// check for cases when the projection is fully inside the projection of the other object

if ( a_max > b_max && a_min < b_min ) {
overlap = Math.min( a_max - b_min, b_max - a_min );
} else if ( b_max > a_max && b_min < a_min ) {
overlap = Math.min( b_max - a_min, a_max - b_min );
} else {
overlap = Math.min( a_max, b_max ) - Math.max( a_min, b_min );
}