Nez.Portable/Physics/SpatialHash.cs
/// <summary>
/// gets all the colliders that fall within the specified circle
/// </summary>
/// <returns>the number of Colliders returned</returns>
/// <param name="circleCenter">Circle center.</param>
/// <param name="radius">Radius.</param>
/// <param name="results">Results.</param>
/// <param name="layerMask">Layer mask.</param>
gets all the colliders that fall within the specified circle
gets all the colliders that fall within the specified circle
public int overlapCircle(Vector2 circleCenter, float radius, Collider[] results, int layerMask)
        {
            var bounds = new RectangleF(circleCenter.X - radius, circleCenter.Y - radius, radius * 2f, radius * 2f);
            _overlapTestCirce.radius = radius;
            _overlapTestCirce.position = circleCenter;
            var resultCounter = 0;
            var potentials = aabbBroadphase(ref bounds, null, layerMask);
            foreach (var collider in potentials)
            {
                if (collider is BoxCollider)
                {
                    results[resultCounter] = collider;
                    resultCounter++;
                }
                else if (collider is CircleCollider)
                {
                    if (collider.shape.overlaps(_overlapTestCirce))
                    {
                        results[resultCounter] = collider;
                        resultCounter++;
                    }
                }
                else if (collider is PolygonCollider)
                {
                    if (collider.shape.overlaps(_overlapTestCirce))
                    {
                        results[resultCounter] = collider;
                        resultCounter++;
                    }
                }
                else
                {
                    throw new NotImplementedException("overlapCircle against this collider type is not implemented!");
                }
                if (resultCounter == results.Length)
                    return resultCounter;
            }
            return resultCounter;
        }
public int overlapCircle ( Vector2 circleCenter , float radius , Collider [ ] results , int layerMask ) { var bounds = new RectangleF ( circleCenter . X - radius , circleCenter . Y - radius , radius * 2f , radius * 2f ) ; _overlapTestCirce . radius = radius ; _overlapTestCirce . position = circleCenter ; var resultCounter = 0 ; var potentials = aabbBroadphase ( ref bounds , null , layerMask ) ; foreach ( var collider in potentials ) { if ( collider is BoxCollider ) { results [ resultCounter ] = collider ; resultCounter ++ ; } else if ( collider is CircleCollider ) { if ( collider . shape . overlaps ( _overlapTestCirce ) ) { results [ resultCounter ] = collider ; resultCounter ++ ; } } else if ( collider is PolygonCollider ) { if ( collider . shape . overlaps ( _overlapTestCirce ) ) { results [ resultCounter ] = collider ; resultCounter ++ ; } } else { throw new NotImplementedException ( " " ) ; } if ( resultCounter == results . Length ) return resultCounter ; } return resultCounter ; }
gets all the colliders that fall within the specified circle
gets all the colliders that fall within the specified circle
// if our results array is full return
the number of Colliders returned
the number of Colliders returned
circleCenter
Vector2
None
radius
float
None
results
Collider[]
None
layerMask
int
None