[SOLVED] finding if 2 Rects intersect

Hi, all!

A simple question - I have 2 Rects
for example

Rect r1(-500, -500, 500, 500);
Rect r2(-500, -100, 300, 5);

and I need to check if these are intersecting. How to do that in most effective way in AngelScript?
I need it for quadtree implementation.

For reference - if rectangkes do not intersect, the Clip result will have infinite size.

Rect r1(-1000, -1000,  -500, -500);
Rect r2(500, 5000,  1000, 1000);
if (r1.length == M_INFINITY)
    Print("do not intersect")

So this is a way to test for intersection.

Would make sense to add a similar IsInside() overload as for BoundingBox, which would return the intersection result.

Yeah, I think that would be more logical way.

QRect (from Qt) overloads the binary | & and bool operators, which will return a new rect that contains both, a new rect that defines the intersection, and returns true if position and size are not 0, respectively. I feel like those should be added to Urho as well. Checking if they intersect would then look like:

if(r1 & r2) { // the two intersect } else { // no intersection }