spatial_data_structure

class SpatialDataStructure

An abstract class used to implement some kind of spatial querying accelleration, such as a spatial hash-map or quadtree.

abstract add(
item: SpatialLike,
merge: bool = False,
) SpatialLike | None

Add a SpatialLike instance to the SpatialDataStructure.

Parameters:
item: SpatialLike

The object to add.

merge: bool = False

Whether or not to attempt to merge the added item with any existing item, if possible.

Returns:

The input SpatialLike if properly added, or None if the input object was merged.

abstract clear() None

Deletes all entries in the structure.

abstract get_all() list[SpatialLike]

Get all the entities in the hash map. Iterates over every cell and returns the contents sequentially. Useful if you want to get all the Entities in a Blueprint without including structural ones like Groups.

Returns:

A list of all entities inside the hash map.

abstract get_in_aabb(
aabb: AABB,
limit: int | None = None,
) list[SpatialLike]

Get all the entities whose collision_set overlaps an AABB.

Parameters:
aabb: AABB

The AABB to examine.

limit: int | None = None

A maximum amount of entities to return.

Returns:

A list of all entities that intersect the area. Can be empty.

abstract get_in_radius(
radius: float,
point: tuple[int | float, int | float],
limit: int | None = None,
) list[SpatialLike]

Get all the entities whose collision_set overlaps a circle.

Parameters:
radius: float

The radius of the circle.

point: tuple[int | float, int | float]

The center of the circle.

limit: int | None = None

A maximum amount of entities to return.

Returns:

A list of all entities that intersect the region. Can be empty.

abstract get_on_point(
point: tuple[int | float, int | float],
limit: int | None = None,
) list[SpatialLike]

Get all the entities whose collision_set overlaps a point.

Parameters:
point: tuple[int | float, int | float]

The position to examine.

limit: int | None = None

A maximum amount of entities to return.

Returns:

A list of all entities that intersect the point. Can be empty.

abstract remove(item: SpatialLike) None

Remove the SpatialLike instance from the SpatialHashMap.

Parameters:
item: SpatialLike

The object to remove.

abstract validate_insert(
item: SpatialLike,
merge: bool,
) None

Checks to see if the added object overlaps any other objects currently contained within the map, and issues errors or warnings correspondingly.