The manual entry on raycasting is a little confusing.
Suppose I want to find the closest point among fixtures meeting some criteria. In my callback, I return fraction if the fixture is acceptable and 1.0f if not. However, this occasionally produces incorrect results.
After reading it more closely and doing some experimentation, my theory is that this is a result of the callback being called out of order, and returning a higher value causes stuff to be unfiltered. So if it was called on a good fixture of distance 10, then a bad fixture of distance 8, and then a good fixture of distance 12, the second call would unfilter the last one and the final result would be 12.
It seems like this is a dangerous pitfall that should be emphasized more clearly in the documentation. It is not immediately obvious that you have to keep track of the cumulative cutoff if you want things to remain filtered.
Suppose I want to find the closest point among fixtures meeting some criteria. In my callback, I return fraction if the fixture is acceptable and 1.0f if not. However, this occasionally produces incorrect results.
After reading it more closely and doing some experimentation, my theory is that this is a result of the callback being called out of order, and returning a higher value causes stuff to be unfiltered. So if it was called on a good fixture of distance 10, then a bad fixture of distance 8, and then a good fixture of distance 12, the second call would unfilter the last one and the final result would be 12.
It seems like this is a dangerous pitfall that should be emphasized more clearly in the documentation. It is not immediately obvious that you have to keep track of the cumulative cutoff if you want things to remain filtered.