12 #include <Moeller/TriangleBoxIntersect.h> 
   34     if (pos.
x < 0) pos.
x = 0;
 
   36     if (pos.
y < 0) pos.
y = 0;
 
   38     if (pos.
z < 0) pos.
z = 0;
 
   57     for (
SLuint i = 1; i < 3; ++i)
 
   59         auto& vertex = triangle[i];
 
   83     assert(callback && 
"No callback function passed");
 
   88         { 
return _m->
I16.size()
 
   90                    : 
_m->
I32[i * 3 + j]; };
 
   97         for (pos.
z = min.
z; pos.
z <= max.
z; ++pos.
z)
 
   99             for (pos.
y = min.
y; pos.
y <= max.
y; ++pos.
y)
 
  101                 for (pos.
x = min.
x; pos.
x <= max.
x; ++pos.
x)
 
  105                     if (triBoxOverlap(*((
float(*)[3]) & voxCenter),
 
  107                                       *((
float(*)[3][3]) & triangle)))
 
  109                         callback(i, voxIndex);
 
  137     if (volume < FLT_EPSILON)
 
  139         SL_WARN_MSG(
"\n\n **** SLCompactGrid::build: Zero Volume. ****");
 
  293             if (ray->
tmin > 0) startPoint += ray->
tmin * D;
 
  301             SLint stepX = (D.
x > 0) ? 1 : (D.
x < 0) ? -1 : 0;
 
  302             SLint stepY = (D.
y > 0) ? 1 : (D.
y < 0) ? -1 : 0;
 
  303             SLint stepZ = (D.
z > 0) ? 1 : (D.
z < 0) ? -1 : 0;
 
  312             SLfloat tMaxX = FLT_MAX, tMaxY = FLT_MAX, tMaxZ = FLT_MAX;
 
  313             if (stepX ==  1) tMaxX = (maxVox.
x - O.
x) * invD.
x; 
else 
  314             if (stepX == -1) tMaxX = (minVox.
x - O.
x) * invD.
x;
 
  315             if (stepY ==  1) tMaxY = (maxVox.
y - O.
y) * invD.
y; 
else 
  316             if (stepY == -1) tMaxY = (minVox.
y - O.
y) * invD.
y;
 
  317             if (stepZ ==  1) tMaxZ = (maxVox.
z - O.
z) * invD.
z; 
else 
  318             if (stepZ == -1) tMaxZ = (minVox.
z - O.
z) * invD.
z;
 
  322             SLfloat tMax = std::min(tMaxX, std::min(tMaxY, tMaxZ));
 
  325             SLint incIDX = stepX;
 
  343                             if (ray->
length <= tMax && !wasHit)
 
  354                             if (ray->
length <= tMax && !wasHit)
 
  366                         if (startVox.
x >= (
SLint)
_size.
x || startVox.
x < 0) 
return wasHit;
 
  374                         if (startVox.
z >= (
SLint)
_size.
z || startVox.
z < 0) 
return wasHit;
 
  385                         if (startVox.
y >= (
SLint)
_size.
y || startVox.
y < 0) 
return wasHit;
 
  393                         if (startVox.
z >= (
SLint)
_size.
z || startVox.
z < 0) 
return wasHit;
 
#define PROFILE_FUNCTION()
 
#define SL_WARN_MSG(message)
 
SLuint SL_sizeOfVector(const T &vector)
 
std::function< void(const SLuint, const SLuint)> triVoxCallback
 
vector< SLVec3f > SLVVec3f
 
SLVec3< SLfloat > SLVec3f
 
SLbool isHitInOS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.
 
SLAccelStruct is an abstract base class for acceleration structures.
 
SLuint _voxelCntEmpty
NO. of empty voxels.
 
SLMesh * _m
Pointer to the mesh.
 
SLVec3f _maxV
max. point of AABB
 
SLfloat _voxelAvgTria
avg. no. of triangles per voxel
 
SLuint _voxelCnt
NO. of voxels in accelerator.
 
SLuint _voxelMaxTria
max. no. of triangles pre voxel
 
SLVec3f _minV
min. point of AABB
 
SLVec3f _voxelSizeHalf
half size of a voxel
 
SLVec3f voxelCenter(const SLVec3i &pos) const
Returns the voxel center point for a given voxel by index.
 
SLVec3f _voxelSize
size of a voxel
 
SLuint _numTriangles
NO. of triangles in the mesh.
 
void build(SLVec3f minV, SLVec3f maxV)
 
SLuint indexAtPos(const SLVec3i &p) const
 
void updateStats(SLNodeStats &stats)
Updates the statistics in the parent node.
 
SLVuint _voxelOffsets
Offset array (C in the paper)
 
void deleteAll()
Deletes the entire uniform grid data.
 
SLVec3ui _size
num. of voxel in grid dir.
 
SLVushort _triangleIndexes16
16 bit triangle index array (L in the paper)
 
SLVuint _triangleIndexes32
32 bit triangle index array (L in the paper)
 
SLbool intersect(SLRay *ray, SLNode *node)
 
void draw(SLSceneView *sv)
SLCompactGrid::draw draws the non-empty voxels of the uniform grid.
 
SLGLVertexArrayExt _vao
Vertex array object for rendering.
 
void getMinMaxVoxel(const Triangle &triangle, SLVec3i &minCell, SLVec3i &maxCell)
Returns the min. and max. voxel of a triangle.
 
SLVec3i containingVoxel(const SLVec3f &p) const
Returns the indices of the voxel around a given point.
 
void ifTriangleInVoxelDo(triVoxCallback cb)
Loops over triangles gets their voxels and calls the callback function.
 
std::array< SLVec3f, 3 > Triangle
 
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
 
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
 
SLuint vaoID() const
Returns either the VAO id or the VBO id.
 
An SLMesh object is a triangulated mesh, drawn with one draw call.
 
SLVuint I32
Vector of vertex indices 32 bit.
 
SLVushort I16
Vector of vertex indices 16 bit.
 
SLbool hitTriangleOS(SLRay *ray, SLNode *node, SLuint iT)
 
SLNode represents a node in a hierarchical scene graph.
 
Ray class with ray and intersection properties.
 
SLVec3f invDirOS
Inverse ray dir for fast AABB hit in OS.
 
SLfloat tmin
min. dist. of last AABB intersection
 
SLfloat length
length from origin to an intersection
 
SLVec3f dirOS
Direction vector of ray in OS.
 
SLVec3f originOS
Vector to the origin of ray in OS.
 
SceneView class represents a dynamic real time 3D view onto the scene.
 
3D vector template class for standard 3D vector algebra.
 
void setMax(const SLVec3 &v)
 
void setMin(const SLVec3 &v)
 
Struct for scene graph statistics.
 
SLuint numVoxMaxTria
Max. no. of triangles per voxel.
 
SLuint numBytesAccel
NO. of bytes in accel. structs.
 
SLuint numVoxels
NO. of voxels.
 
SLfloat numVoxEmpty
NO. of empty voxels.