CellSpacePartitioning class

This class is used for cell-space partitioning, a basic approach for implementing a spatial index. The 3D space is divided up into a number of cells. A cell contains a list of references to all the entities it contains. Compared to other spatial indices like octrees, the division of the 3D space is coarse and often not balanced but the computational overhead for calculating the index of a specific cell based on a position vector is very fast.

@author {@link https://github.com/Mugen87|Mugen87}

Constructors

CellSpacePartitioning(double width, double height, double depth, int cellsX, int cellsY, int cellsZ)
Constructs a new spatial index with the given values.

Properties

aabb AABB
final
cells List<Cell>
getter/setter pair
cellsX int
getter/setter pair
cellsY int
getter/setter pair
cellsZ int
getter/setter pair
clampedPosition Vector3
final
contour List<Vector3>
final
depth double
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
height double
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width double
getter/setter pair

Methods

addEntityToPartition(GameEntity entity, int index) CellSpacePartitioning
Adds an entity to a specific partition.
addPolygon(Polygon polygon) CellSpacePartitioning
Adds a polygon to the spatial index. A polygon is approximated with an AABB.
fromJSON(Map<String, dynamic> json) CellSpacePartitioning
Restores this instance from the given JSON object.
getIndexForPosition(Vector3 position) int
Computes the partition index for the given position vector.
makeEmpty() CellSpacePartitioning
Removes all entities from all partitions.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(Vector3 position, double radius, List result) List
Performs a query to the spatial index according the the given position and radius. The method approximates the query position and radius with an AABB and then performs an intersection test with all non-empty cells in order to determine relevant partitions. Stores the result in the given result array.
removeEntityFromPartition(GameEntity entity, int index) CellSpacePartitioning
Removes an entity from a specific partition.
resolveReferences(Map<String, GameEntity> entities) CellSpacePartitioning
Restores UUIDs with references to GameEntity objects.
toJSON() Map<String, dynamic>
Transforms this instance into a JSON object.
toString() String
A string representation of this object.
inherited
updateEntity(GameEntity entity, [int currentIndex = -1]) int
Updates the partitioning index of a given game entity.

Operators

operator ==(Object other) bool
The equality operator.
inherited