SLProject 4.0.000
SLCompactGrid Class Reference

Class for compact uniform grid acceleration structure. More...

#include <SLCompactGrid.h>

Inheritance diagram for SLCompactGrid:
[legend]

Public Types

using Triangle = std::array< SLVec3f, 3 >
 

Public Member Functions

 SLCompactGrid (SLMesh *m)
 
 ~SLCompactGrid ()
 
void build (SLVec3f minV, SLVec3f maxV)
 
void updateStats (SLNodeStats &stats)
 Updates the statistics in the parent node. More...
 
void draw (SLSceneView *sv)
 SLCompactGrid::draw draws the non-empty voxels of the uniform grid. More...
 
SLbool intersect (SLRay *ray, SLNode *node)
 
void deleteAll ()
 Deletes the entire uniform grid data. More...
 
void disposeBuffers ()
 
SLuint indexAtPos (const SLVec3i &p) const
 
SLVec3f voxelCenter (const SLVec3i &pos) const
 Returns the voxel center point for a given voxel by index. More...
 
SLVec3i containingVoxel (const SLVec3f &p) const
 Returns the indices of the voxel around a given point. More...
 
void getMinMaxVoxel (const Triangle &triangle, SLVec3i &minCell, SLVec3i &maxCell)
 Returns the min. and max. voxel of a triangle. More...
 
void ifTriangleInVoxelDo (triVoxCallback cb)
 Loops over triangles gets their voxels and calls the callback function. More...
 
- Public Member Functions inherited from SLAccelStruct
 SLAccelStruct (SLMesh *m)
 
virtual ~SLAccelStruct ()
 
virtual void build (SLVec3f minV, SLVec3f maxV)=0
 
virtual void updateStats (SLNodeStats &stats)=0
 
virtual void draw (SLSceneView *sv)=0
 
virtual SLbool intersect (SLRay *ray, SLNode *node)=0
 
virtual void disposeBuffers ()=0
 

Private Attributes

SLVec3ui _size
 num. of voxel in grid dir. More...
 
SLuint _numTriangles
 NO. of triangles in the mesh. More...
 
SLVec3f _voxelSize
 size of a voxel More...
 
SLVec3f _voxelSizeHalf
 half size of a voxel More...
 
SLVuint _voxelOffsets
 Offset array (C in the paper) More...
 
SLVushort _triangleIndexes16
 16 bit triangle index array (L in the paper) More...
 
SLVuint _triangleIndexes32
 32 bit triangle index array (L in the paper) More...
 
SLGLVertexArrayExt _vao
 Vertex array object for rendering. More...
 

Additional Inherited Members

- Protected Attributes inherited from SLAccelStruct
SLMesh_m
 Pointer to the mesh. More...
 
SLVec3f _minV
 min. point of AABB More...
 
SLVec3f _maxV
 max. point of AABB More...
 
SLuint _voxelCnt
 NO. of voxels in accelerator. More...
 
SLuint _voxelCntEmpty
 NO. of empty voxels. More...
 
SLuint _voxelMaxTria
 max. no. of triangles pre voxel More...
 
SLfloat _voxelAvgTria
 avg. no. of triangles per voxel More...
 

Detailed Description

Class for compact uniform grid acceleration structure.

This class implements the data structure proposed by Lagae & Dutre in their paper "Compact, Fast and Robust Grids for Ray Tracing". It reduces the memory footprint to 20% of a regular uniform grid implemented in SLUniformGrid.

Member Typedef Documentation

◆ Triangle

using SLCompactGrid::Triangle = std::array<SLVec3f, 3>

Constructor & Destructor Documentation

◆ SLCompactGrid()

SLCompactGrid::SLCompactGrid ( SLMesh m)

◆ ~SLCompactGrid()

SLCompactGrid::~SLCompactGrid ( )
inline

Member Function Documentation

◆ build()

void SLCompactGrid::build ( SLVec3f  minV,
SLVec3f  maxV 
)
virtual

SLCompactGrid::build implements the data structure proposed by Lagae & Dutre in their paper "Compact, Fast and Robust Grids for Ray Tracing".

Implements SLAccelStruct.

◆ containingVoxel()

SLVec3i SLCompactGrid::containingVoxel ( const SLVec3f p) const

Returns the indices of the voxel around a given point.

◆ deleteAll()

void SLCompactGrid::deleteAll ( )

Deletes the entire uniform grid data.

◆ disposeBuffers()

void SLCompactGrid::disposeBuffers ( )
inlinevirtual

Implements SLAccelStruct.

◆ draw()

void SLCompactGrid::draw ( SLSceneView sv)
virtual

SLCompactGrid::draw draws the non-empty voxels of the uniform grid.

Implements SLAccelStruct.

◆ getMinMaxVoxel()

void SLCompactGrid::getMinMaxVoxel ( const Triangle triangle,
SLVec3i minCell,
SLVec3i maxCell 
)

Returns the min. and max. voxel of a triangle.

◆ ifTriangleInVoxelDo()

void SLCompactGrid::ifTriangleInVoxelDo ( triVoxCallback  cb)

Loops over triangles gets their voxels and calls the callback function.

◆ indexAtPos()

SLuint SLCompactGrid::indexAtPos ( const SLVec3i p) const
inline

◆ intersect()

SLbool SLCompactGrid::intersect ( SLRay ray,
SLNode node 
)
virtual

Ray Mesh intersection method using the regular grid space subdivision structure and a voxel traversal algorithm described in "A Fast Voxel Traversal Algorithm for Ray Tracing" by John Amanatides and Andrew Woo.

Implements SLAccelStruct.

◆ updateStats()

void SLCompactGrid::updateStats ( SLNodeStats stats)
virtual

Updates the statistics in the parent node.

Implements SLAccelStruct.

◆ voxelCenter()

SLVec3f SLCompactGrid::voxelCenter ( const SLVec3i pos) const

Returns the voxel center point for a given voxel by index.

Member Data Documentation

◆ _numTriangles

SLuint SLCompactGrid::_numTriangles
private

NO. of triangles in the mesh.

◆ _size

SLVec3ui SLCompactGrid::_size
private

num. of voxel in grid dir.

◆ _triangleIndexes16

SLVushort SLCompactGrid::_triangleIndexes16
private

16 bit triangle index array (L in the paper)

◆ _triangleIndexes32

SLVuint SLCompactGrid::_triangleIndexes32
private

32 bit triangle index array (L in the paper)

◆ _vao

SLGLVertexArrayExt SLCompactGrid::_vao
private

Vertex array object for rendering.

◆ _voxelOffsets

SLVuint SLCompactGrid::_voxelOffsets
private

Offset array (C in the paper)

◆ _voxelSize

SLVec3f SLCompactGrid::_voxelSize
private

size of a voxel

◆ _voxelSizeHalf

SLVec3f SLCompactGrid::_voxelSizeHalf
private

half size of a voxel


The documentation for this class was generated from the following files: