Skip to content

Fall back to the nearest point of the node in sample_point_on_node. - #205

Open
sidneyprins wants to merge 1 commit into
andriyDev:mainfrom
sidneyprins:fix-sample-point-on-node-edge
Open

sidneyprins wants to merge 1 commit into
andriyDev:mainfrom
sidneyprins:fix-sample-point-on-node-edge

Conversation

@sidneyprins

Copy link
Copy Markdown

Fixes #204.

sample_point_on_node assumes the point projects onto the node. Points on the node's boundary, such as the clipped ends of an animation link's portal, can miss every triangle by float error, and the function panics. Instead it now falls back to the point of the node nearest to the given point.

  • sample_point's nested project_to_triangle, which already clamps to the triangle, moves to a module-level closest_point_on_triangle so both functions share it. Its behavior is unchanged.
  • sample_point_on_node still returns the first triangle the point projects onto. While it tests the triangles it keeps the nearest clamped point, and returns that when none matches.
  • Adds sample_point_on_node_point_just_outside_node, using the triangle and point from the issue. Without the change it panics at the same line.

I left EPSILON as it is rather than widening it: a larger tolerance only moves the boundary where it fails, while the fallback handles any point the caller believes is on the node.

cargo test --all-features --all-targets, cargo clippy -- -D warnings and cargo +nightly fmt --all -- --check pass. With this patch our stress test that used to panic in two of three runs passed every run.

🤖 Generated with Claude Code

@sidneyprins
sidneyprins force-pushed the fix-sample-point-on-node-edge branch from 727ba37 to 3b32c2b Compare October 17, 2026 19:54
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.

Panic in sample_point_on_node for an animation link point on a node's edge

1 participant