public CollidableAABB(ICollidable collidable) { Collidable = collidable; IsHardCollider = Collidable.IsHardCollidable; Points = new CollidablePoint[4]; float top = Collidable.AABB.Top; float bottom = Collidable.AABB.Bottom; float left = Collidable.AABB.Left; float right = Collidable.AABB.Right; Points[0] = new CollidablePoint(CollidablePointIndex.TopLeft, new PointF(left, top), this); Points[1] = new CollidablePoint(CollidablePointIndex.TopRight, new PointF(right, top), this); Points[2] = new CollidablePoint(CollidablePointIndex.BottomRight, new PointF(right, bottom), this); Points[3] = new CollidablePoint(CollidablePointIndex.BottomLeft, new PointF(left, bottom), this); }
/// <summary> /// Adds a CollidablePoint to this bucket /// </summary> /// <param name="point"></param> public void AddPoint(CollidablePoint point) { _points.Add(point); }
/// <summary> /// Removes a CollidablePoint from this bucket, if it exists. /// </summary> /// <param name="point"></param> public void RemovePoint(CollidablePoint point) { if (_points.Contains(point)) _points.Remove(point); }
/// <summary> /// Removes an AABB point from a bucket /// </summary> /// <param name="point"></param> private void RemovePoint(CollidablePoint point) { CollidableBucket b = GetBucket(point.Coordinates); b.RemovePoint(point); }