addPolygon method

CellSpacePartitioning addPolygon(
  1. Polygon polygon
)

Adds a polygon to the spatial index. A polygon is approximated with an AABB.

Implementation

CellSpacePartitioning addPolygon(Polygon polygon ) {
	final cells = this.cells;

	polygon.getContour( contour );
	aabb.fromPoints( contour );

	for ( int i = 0, l = cells.length; i < l; i ++ ) {
		final cell = cells[ i ];

		if ( cell.intersects( aabb ) == true ) {
			cell.add( polygon );
		}
	}

	return this;
}