|
MobileRT
1.0
A multi platform C++ CPU progressive Ray Tracer.
|
#include <RegularGrid.hpp>

Public Member Functions | |
| RegularGrid ()=default | |
| RegularGrid (::std::vector< T > &&primitives, ::std::uint32_t gridSize) | |
| RegularGrid (const RegularGrid ®ularGrid)=delete | |
| RegularGrid (RegularGrid &®ularGrid) noexcept=default | |
| ~RegularGrid () | |
| RegularGrid & | operator= (const RegularGrid ®ularGrid)=delete |
| RegularGrid & | operator= (RegularGrid &®ularGrid) noexcept=default |
| Intersection | trace (Intersection intersection) |
| Intersection | shadowTrace (Intersection intersection) |
| const ::std::vector< T > & | getPrimitives () const |
Private Member Functions | |
| void | addPrimitives () |
| void | addPrimitivesThreadWork (::std::uint32_t threadId, ::std::uint32_t numberOfThreads) |
| Intersection | intersect (Intersection intersection) |
| ::std::uint32_t | bitCounter (::std::uint32_t value) const |
| ::std::int32_t | getCellIndex (::std::int32_t cellX, ::std::int32_t cellY, ::std::int32_t cellZ) const |
Private Attributes | |
| ::std::vector<::std::vector< T * > > | grid_ |
| ::std::vector< T > | primitives_ |
| ::std::int32_t | gridSize_ {} |
| ::std::uint32_t | gridShift_ {} |
| AABB | worldBoundaries_ {} |
| ::glm::vec3 | cellSizeInverted_ {} |
| ::glm::vec3 | cellSize_ {} |
| ::std::vector<::std::mutex > | mutexes_ {} |
A class which represents the Regular Grid acceleration structure.
This is a structure where all the primitives are stored in a matrix where each cell represents a 3D space of the scene. So the scene geometry is divided in many boxes (each cell of the 3D matrix) and when a ray is casted into the scene, it tries to intersect the nearest cell and then the primitives inside it until it finds the nearest intersection point.
| T | The type of the primitives. |
|
explicitdefault |
|
explicit |
The constructor.
| T | The type of the primitives. |
| primitives | The primitives in the scene. |
| gridSize | The size of the cells in all the axes. |
|
delete |
|
defaultnoexcept |
| MobileRT::RegularGrid< T >::~RegularGrid | ( | ) |
The destructor.
| T | The type of the primitives. |
|
private |
Helper method which adds the primitives into the grid.
| T | The type of the primitives. |
|
private |
Store primitives in the grid cells.
|
private |
Helper method which calculates the number bits set in an unsigned integer.
| T | The type of the primitives. |
| value | The value to count the number of the bits set. |
|
private |
Helper method which calculates the cell index in the grid.
| cellX | The index of X. |
| cellY | The index of Y. |
| cellZ | The index of Z. |
| const ::std::vector< T > & MobileRT::RegularGrid< T >::getPrimitives | ( | ) | const |
Gets the primitives.
| T | The type of the primitives. |
|
private |
Helper method which calculates the intersection point from the origin of the ray.
This method supports two modes:
| T | The type of the primitives. |
| intersection | The previous intersection point of the ray (used to update its data in case it is found a nearest intersection point. |
|
delete |
|
defaultnoexcept |
| Intersection MobileRT::RegularGrid< T >::shadowTrace | ( | Intersection | intersection | ) |
This method casts a ray into the geometry and calculates a random intersection point. The intersection point itself is not important, the important is to determine if the ray intersects some primitive in the scene or not.
| T | The type of the primitives. |
| intersection | The current intersection of the ray with previous primitives. |
| Intersection MobileRT::RegularGrid< T >::trace | ( | Intersection | intersection | ) |
This method casts a ray into the geometry and calculates the nearest intersection point from the origin of the ray.
| T | The type of the primitives. |
| intersection | The current intersection of the ray with previous primitives. |
|
private |
The size of a cell (worldBoundaries / gridSize).
|
private |
The inverted cell size (gridSize / worldBoundaries).
|
private |
The grid structure.
|
private |
The number of bits in the grid size value (minus 1).
|
private |
The size of the cells in all the axes.
|
private |
The mutexes to allow multiple threads add primitives to the grid.
|
private |
The primitives.
|
private |
The World boundaries.