Bug @ CGRect::CGRectIntersectsRect

Hello, while I was playing around with cocos2d-x I hit a bug at CGRect::CGRectIntersectsRect(…), inside $cocos2dx_root/cocos2dx/cocoa/CGGeometry.cpp.

Instead of this:

return !(CGRectGetMaxX(rectA) < CGRectGetMinX(rectB)||
            CGRectGetMaxX(rectB) < CGRectGetMinX(rectA)||
            CGRectGetMaxY(rectA) < CGRectGetMinY(rectB)||
            CGRectGetMaxY(rectB) < CGRectGetMinY(rectB));   // <-- bug!

…it should actually be like this:

return !(CGRectGetMaxX(rectA) < CGRectGetMinX(rectB)||
            CGRectGetMaxX(rectB) < CGRectGetMinX(rectA)||
            CGRectGetMaxY(rectA) < CGRectGetMinY(rectB)||
            CGRectGetMaxY(rectB) < CGRectGetMinY(rectA));   // <-- fixed!

Note the last rectA instead of rectB being used for the comparison between maxY and minY :slight_smile: Without it, the intersection test will always return true in certain cases where it should really return false instead.

Thanks a lot! I’m looking for how to resolve this bug for a long time. My pool math :frowning:
It’s fixed in this commit

Cool, thank you for committing the fix so quickly!

I’m starting to really like this project :slight_smile: