Skip to content

[shapes] False positive with CheckCollisionPointPoly() #3742

@mllimo

Description

@mllimo

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

The "CheckCollisionPointPoly" function gives me a false positive when I check that two instances of squares form by 4 vertices are colliding particulary when one vertex is inside the other. I have noticed that it happens only when I reach the same or lower "Y" coordinate from the right side or when I surround it in clockwise direction. See the videos below for more clarity.

Environment

Windows 11 x64, OpenGL 3.3, AMD Radeon RX 6600

Issue Screenshot

https://github.com/raysan5/raylib/assets/38075437/bce679e1-ada7-4467-b86b-4292ba58c5fe
debugging
verticesrepresentation

Code Example

int main()
{
    std::vector<Vector2> vertices_b = {
        { 668.678406, 60.9284592 },
        { 629.318420, 53.7983131 },
        { 622.188721, 93.1581116 },
        { 661.548462, 100.287857 }
    };
   
    // Colliding: 1 
    std::cout << "Colliding: " << CheckCollisionPointPoly({ 100, 100 }, (Vector2*)vertices_b.data(), vertices_b.size()) << '\n';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions