Polarith AI
1.8
RegularGrid Class Reference

Description

A regular grid to speed up the access to relevant SteeringPercept instances, whereby it can be used for arbitrary scenarios, 2D and 3D as well, since it can be adapted as required.

Both the resolution and the cell size of the grid can be controlled individually for each axis via CellCountX, CellCountY, CellCountZ, CellSizeX, CellSizeY and CellSizeZ. When this documentation speaks of a grid size (for one axis), the cell size multiplied by the cell count is meant.

A percept must be located within the bounds defined by the grid size for being integrated into the grid structure. The GridGizmo can be used to display the grid and to check the bounds accordingly.

This class is serializable so that it is suitable for the direct use in MonoBehaviour instances supporting Unity's inspector.

Public Fields

int CellCountX = 16
 Defines the number of cells along the x-axis, needs to be at least 1. More...
 
int CellCountY = 16
 Defines the number of cells along the y-axis, needs to be at least 1. More...
 
int CellCountZ = 16
 Defines the number of cells along the z-axis, needs to be at least 1. More...
 
float CellSizeX = 8.0f
 Defines the size of single cells along the x-axis in Unity units, needs to be greater than 0. More...
 
float CellSizeY = 8.0f
 Defines the size of single cells along the y-axis in Unity units, needs to be greater than 0. More...
 
float CellSizeZ = 8.0f
 Defines the size of single cells along the z-axis in Unity units, needs to be greater than 0. More...
 
GridGizmo GridGizmo = new GridGizmo()
 A gizmo that displays the grid in the scene view. More...
 

Public Methods

void DrawGizmo (Vector3 center)
 Displays a gizmo for visualizing this grid at the given center point. More...
 
void Initialize (IList< AIMEnvironment > environments)
 Initializes the grid structure based on the currently known environments . More...
 
void Initialize (IList< AIMEnvironment > environments, int cellCountX, int cellCountY, int cellCountZ)
 Initializes the grid structure based on the currently known environments and the specified sizes. More...
 
void Query (Vector3 point, float range, IList< string > environments, IList< SteeringPercept > percepts)
 Given the point and the range , this method iterates all cells of the grid that may hold relevant SteeringPercept instances. More...
 
void PrepareUpdate (Vector3 center, IList< AIMEnvironment > environments)
 Needs to be called at the beginning of an update cycle before Update(AIMEnvironment, IList<SteeringPercept>) is called accordingly for all available AIMEnvironment instances. More...
 
void Update (AIMEnvironment environment, IList< SteeringPercept > percepts)
 Updates the positions of all percepts within the grid with respect to the given environment . More...
 
Imprint