Skip to content

fix: constrain Line.contains() to its endpoints - #1812

Open
mmporong wants to merge 1 commit into
melonjs:masterfrom
mmporong:fix/line-segment-contains
Open

mmporong wants to merge 1 commit into
melonjs:masterfrom
mmporong:fix/line-segment-contains

Conversation

@mmporong

@mmporong mmporong commented Oct 31, 2026 •

Copy link
Copy Markdown

Description

Line#contains() previously checked only whether a point was collinear with the line. As a result, points beyond either endpoint were reported as contained.

This change also checks that both point coordinates fall within the segment's endpoint bounds. A regression test covers collinear points beyond both ends of the segment.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Checklist

  • I have read the Contributing Guide
  • My code follows the existing code style (pnpm lint passes)
  • I have tested my changes locally (pnpm test passes)
  • I have added tests that cover my changes (if applicable)
  • The build succeeds (pnpm build)

The focused browser test passes with all 15 Line tests. The broader browser suite was stopped after unrelated audio/network, WebGL context-loss, and state timing failures appeared in this environment.

Related issues

None.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant