29#define BVH_RANGED_TRAVERSAL
66#ifdef BVH_RANGED_TRAVERSAL
97 int todoOffset = 0, nodeNum = 0;
115 nodeNum = nodeNum + 1;
129 for(
unsigned int i = ia; i < ie; ++i )
146 if( todoOffset == 0 )
149 const StackNode& node = todo[--todoOffset];
164#ifdef BVH_PARTITION_TRAVERSAL
167 unsigned int ia,
const unsigned int* aRayIndex,
175 && ( hitT < aHitInfoPacket[ aRayIndex[ie] ].m_HitInfo.m_tHit ) )
183static inline unsigned int partRays(
const RAYPACKET& aRayPacket,
const BBOX_3D& aBBox,
184 unsigned int ia,
unsigned int* aRayIndex,
193 for(
unsigned int i = 0; i < ia; ++i )
198 && ( hitT < aHitInfoPacket[ aRayIndex[i] ].m_HitInfo.m_tHit ) )
199 std::swap( aRayIndex[ie++], aRayIndex[i] );
209 int todoOffset = 0, nodeNum = 0;
220 const LinearBVHNode *curCell = &
m_nodes[nodeNum];
222 ia = partRays( aRayPacket, curCell->
bounds, ia,
I, aHitInfoPacket );
228 StackNode& node = todo[todoOffset++];
231 nodeNum = nodeNum + 1;
245 for(
unsigned int i = 0; i < ie; ++i )
247 unsigned int idx =
I[i];
250 aHitInfoPacket[idx].m_HitInfo );
264 if( todoOffset == 0 )
267 const StackNode& node = todo[--todoOffset];
static unsigned int getLastHit(const RAYPACKET &aRayPacket, const BBOX_3D &aBBox, unsigned int ia, HITINFO_PACKET *aHitInfoPacket)
static unsigned int getFirstHit(const RAYPACKET &aRayPacket, const BBOX_3D &aBBox, unsigned int ia, HITINFO_PACKET *aHitInfoPacket)
This BVH implementation is based on the source code implementation from the book "Physically Based Re...
unsigned int m_I[RAYPACKET_RAYS_PER_PACKET]
std::vector< const OBJECT_3D * > m_primitives
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
virtual bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const =0
const BBOX_3D & GetBBox() const
#define RAYPACKET_RAYS_PER_PACKET
Manage a bounding box defined by two SFVEC3F min max points.
bool Intersect(const RAY &aRay, float *t) const
bool Intersect(const BBOX_3D &aBBox) const
Intersect aBBox with this frustum.
unsigned int m_acc_node_info
( 4) The acc stores here the node that it hits
float m_tHit
( 4) distance
int secondChildOffset
interior
uint16_t nPrimitives
0 -> interior node
RAY m_ray[RAYPACKET_RAYS_PER_PACKET]