donmccurdy/three-pathfinding

Potential optimization in clampStep

Opened this issue · 0 comments

clampStep does a branching search of nodes and neighbors to find the closest matching node, but I think it could bail out if any of those tests returns a distance to the current node triangle of zero (around here in the code).

This is also likely to be the majority path because clients will typically submit the hint node they actually end up in and you already go to the trouble of projecting the destination point onto the plane of this nodes triangle, which is likely to improve the chances that the distance to the triangle is zero.

This optimization must be safe because unless I'm misreading the code, no later node could ever replace this selection anyway because the distance will never be below zero.