private void Query(out int lowerQueryOut, out int upperQueryOut,
ushort lowerValue, ushort upperValue,
Bound[] bounds, int boundCount, int axis)
{
int lowerQuery = BinarySearch(bounds, boundCount, lowerValue);
int upperQuery = BinarySearch(bounds, boundCount, upperValue);
// Easy case: lowerQuery <= lowerIndex(i) < upperQuery
// Solution: search query range for min bounds.
for (int i = lowerQuery; i < upperQuery; ++i)
{
if (bounds[i].IsLower)
{
IncrementOverlapCount(bounds[i].ProxyId);
}
}
// Hard case: lowerIndex(i) < lowerQuery < upperIndex(i)
// Solution: use the stabbing count to search down the bound array.
if (lowerQuery > 0)
{
int i = lowerQuery - 1;
int s = bounds[i].StabbingCount;
// Find the s overlaps.
while (s != 0)
{
Box2DXDebug.Assert(i >= 0);
if (bounds[i].IsLower)
{
Proxy proxy = _proxyPool[bounds[i].ProxyId];
if (lowerQuery <= proxy.UpperBounds[axis])
{
IncrementOverlapCount(bounds[i].ProxyId);
--s;
}
}
--i;
}
}
lowerQueryOut = lowerQuery;
upperQueryOut = upperQuery;
}
int qi1 = 0;