Commit 2ea885e
Seed the KdTree nearest-neighbour distance with the squared-distance type's max
Summary:
`nearestNeighbor()` writes its result into a `SquareValueTyper<T>::Type`, but seeded the
sentinel from `T`. For floating point the two types are identical, so nothing was wrong
there. For every integer instantiation they differ and the sentinel is far too small -
`SquareValueTyper<short>::Type` is `unsigned int` (max 4294967295) while
`numeric_limits<short>::max()` is 32767.
The recursive helper only assigns `nearest` inside `if (localDistance < distance)`, so any
tree whose closest point sits farther than that sentinel returned no candidate at all. For
`short` that is any coordinate delta beyond about 181.
___
Differential Revision: D114541610
fbshipit-source-id: 4745518e0e6fce1e18ccb6808ff9250b04973ed81 parent 6a021ef commit 2ea885e
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | | - | |
| 343 | + | |
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| |||
0 commit comments