Support Forum G3D Web Page |
Computes conservative line raster/voxelization across a grid for use in walking a grid spatial data structure or or voxel scene searching for intersections.
More...
Public Member Functions | |
RayGridIterator (Ray ray, const Vector3int32 &numCells, const Vector3 &cellSize=Vector3(1, 1, 1), const Point3 &minBoundsLocation=Point3(0, 0, 0), const Point3int32 &minBoundsCellIndex=Point3int32(0, 0, 0)) | |
Initialize the iterator to the first grid cell hit by the ray and precompute traversal variables. More... | |
const Vector3 & | cellSize () const |
Size of each cell along each axis. More... | |
bool | containsRayOrigin () const |
True if this cell contains the ray origin. More... | |
int | enterAxis () const |
The axis along which the ray entered the cell; X = 0, Y = 1, Z = 2. More... | |
float | enterDistance () const |
Distance along the ray of the first intersection with the current cell (i.e., that given by m_index). More... | |
Vector3int32 | enterNormal () const |
Outward-facing normal to the current grid cell along the partition just entered. More... | |
Point3 | enterPoint () const |
Location where the ray entered the current grid cell. More... | |
float | exitDistance () const |
Distance from the ray origin to the exit point in this cell. More... | |
Point3 | exitPoint () const |
Location where the ray exits the current grid cell. More... | |
const Vector3int32 & | index () const |
Current grid cell m_index. More... | |
bool | insideGrid () const |
True if index() refers to a valid cell inside the grid. More... | |
Vector3int32 | numCells () const |
Extent of the grid in each dimension, in grid cell units. More... | |
RayGridIterator & | operator++ () |
Increment the iterator, moving to the next grid cell. More... | |
const Ray & | ray () const |
The original ray. More... | |
const Vector3int32 & | step () const |
Sign of the direction that the ray moves along each axis; +/-1 or 0. More... | |
const Vector3 & | tDelta () const |
Size of one cell in units of t along each axis. More... | |
Protected Attributes | |
Vector3int32 | m_boundaryIndex |
The value that the index will take on along each boundary when it just leaves the grid. More... | |
Vector3 | m_cellSize |
Size of each cell along each axis. More... | |
bool | m_containsRayOrigin |
True if this cell contains the ray origin. More... | |
int | m_enterAxis |
The axis along which the ray entered the cell; X = 0, Y = 1, Z = 2. More... | |
float | m_enterDistance |
Distance along the ray of the first intersection with the current cell (i.e., that given by m_index). More... | |
Vector3 | m_exitDistance |
Distance along the ray to the intersection with the next grid cell. More... | |
Vector3int32 | m_index |
Current grid cell m_index. More... | |
bool | m_insideGrid |
True if index() refers to a valid cell inside the grid. More... | |
Vector3int32 | m_numCells |
Extent of the grid in each dimension, in grid cell units. More... | |
Ray | m_ray |
The original ray. More... | |
Vector3int32 | m_step |
Sign of the direction that the ray moves along each axis; +/-1 or 0. More... | |
Vector3 | m_tDelta |
Size of one cell in units of t along each axis. More... | |
Computes conservative line raster/voxelization across a grid for use in walking a grid spatial data structure or or voxel scene searching for intersections.
At each iteration, the iterator steps exactly one cell in exactly one dimension.
Example of this iterator applied to ray-primitive intersection in a grid:
G3D::RayGridIterator::RayGridIterator | ( | Ray | ray, |
const Vector3int32 & | numCells, | ||
const Vector3 & | cellSize = Vector3(1, 1, 1) , |
||
const Point3 & | minBoundsLocation = Point3(0, 0, 0) , |
||
const Point3int32 & | minBoundsCellIndex = Point3int32(0, 0, 0) |
||
) |
Initialize the iterator to the first grid cell hit by the ray and precompute traversal variables.
The grid is assumed to have a corner at (0,0,0) and extend along the canonical axes. For intersections grids transformed by a rigid body transformation, first transform the ray into the grid's object space with CFrame::rayToObjectSpace.
If the ray never passes through the grid, insideGrid() will be false immediately after intialization.
If using for 2D iteration, set numCells.z = 1
and ray.origin().z = 0.5
cellSize | The extent of one cell |
minBoundsLocation | The location of the lowest corner of grid cell minBoundsCellIndex along each axis. This translates the grid relative to the ray's coordinate frame. |
minBoundsCellIndex | The index of the first grid cell. This allows operation with grids defined on negative indices. This translates all grid indices. |
|
inline |
Size of each cell along each axis.
|
inline |
True if this cell contains the ray origin.
|
inline |
The axis along which the ray entered the cell; X = 0, Y = 1, Z = 2.
This is always set to X for the cell that contains the ray origin.
|
inline |
Distance along the ray of the first intersection with the current cell (i.e., that given by m_index).
Zero for the cell that contains the ray origin.
|
inline |
Outward-facing normal to the current grid cell along the partition just entered.
Initially zero.
|
inline |
Location where the ray entered the current grid cell.
|
inline |
Distance from the ray origin to the exit point in this cell.
|
inline |
Location where the ray exits the current grid cell.
|
inline |
Current grid cell m_index.
|
inline |
True if index() refers to a valid cell inside the grid.
This is usually employed as the loop termination condition.
|
inline |
Extent of the grid in each dimension, in grid cell units.
|
inline |
Increment the iterator, moving to the next grid cell.
|
inline |
The original ray.
|
inline |
Sign of the direction that the ray moves along each axis; +/-1 or 0.
|
inline |
Size of one cell in units of t along each axis.
|
protected |
The value that the index will take on along each boundary when it just leaves the grid.
Referenced by operator++().
|
protected |
Size of each cell along each axis.
Referenced by cellSize().
|
protected |
True if this cell contains the ray origin.
Referenced by containsRayOrigin(), and operator++().
|
protected |
The axis along which the ray entered the cell; X = 0, Y = 1, Z = 2.
This is always set to X for the cell that contains the ray origin.
Referenced by enterAxis(), enterNormal(), and operator++().
|
protected |
Distance along the ray of the first intersection with the current cell (i.e., that given by m_index).
Zero for the cell that contains the ray origin.
Referenced by enterDistance(), enterPoint(), and operator++().
|
protected |
Distance along the ray to the intersection with the next grid cell.
enterDistance and m_exitDistance can be used to bracket ray ray-primitive intersection tests within a cell.
Referenced by exitDistance(), exitPoint(), and operator++().
|
protected |
Current grid cell m_index.
Referenced by index(), and operator++().
|
protected |
True if index() refers to a valid cell inside the grid.
This is usually employed as the loop termination condition.
Referenced by insideGrid(), and operator++().
|
protected |
Extent of the grid in each dimension, in grid cell units.
Referenced by numCells().
|
protected |
The original ray.
Referenced by enterPoint(), exitPoint(), and ray().
|
protected |
Sign of the direction that the ray moves along each axis; +/-1 or 0.
Referenced by enterNormal(), operator++(), and step().
|
protected |
Size of one cell in units of t along each axis.
Referenced by operator++(), and tDelta().