Skip to content

Utils.isPointInPoly should include boundary #68

@rob-myers

Description

@rob-myers

When Pathfinding.findPath outputs navigable points, I'd expect every point to be a valid place to start another navpath.

This fails reasonably often for my programmatically constructed meshes.
It can be fixed by patching Utils.isPointInPoly:

  • replace pt.z < poly[j].z by pt.z <= poly[j].z.
  • replace pt.z < poly[i].z by pt.z <= poly[i].z.

As far as I can tell, isPointInPoly is used to test point-in-triangle via the crossing number method.
The link mentions that:

A standard convention is to say that a point on a left or bottom edge is inside, and a point on a right or top edge is outside. This way, if two distinct polygons share a common boundary segment, then a point on that segment will be in one polygon or the other, but not both at the same time. This avoids a number of problems that might occur, especially in computer graphics displays.

But including the boundary produces no problem in our use case.
If two triangles "contain" the point, the one corresponding to the earlier node will always be picked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions