33#define BVH_RANGED_TRAVERSAL
70#ifdef BVH_RANGED_TRAVERSAL
101 int todoOffset = 0, nodeNum = 0;
119 nodeNum = nodeNum + 1;
133 for(
unsigned int i = ia; i < ie; ++i )
150 if( todoOffset == 0 )
153 const StackNode& node = todo[--todoOffset];
168#ifdef BVH_PARTITION_TRAVERSAL
171 unsigned int ia,
const unsigned int* aRayIndex,
179 && ( hitT < aHitInfoPacket[ aRayIndex[ie] ].m_HitInfo.m_tHit ) )
187static inline unsigned int partRays(
const RAYPACKET& aRayPacket,
const BBOX_3D& aBBox,
188 unsigned int ia,
unsigned int* aRayIndex,
197 for(
unsigned int i = 0; i < ia; ++i )
202 && ( hitT < aHitInfoPacket[ aRayIndex[i] ].m_HitInfo.m_tHit ) )
203 std::swap( aRayIndex[ie++], aRayIndex[i] );
213 int todoOffset = 0, nodeNum = 0;
226 ia = partRays( aRayPacket, curCell->
bounds, ia,
I, aHitInfoPacket );
235 nodeNum = nodeNum + 1;
249 for(
unsigned int i = 0; i < ie; ++i )
251 unsigned int idx =
I[i];
254 aHitInfoPacket[idx].m_HitInfo );
268 if( todoOffset == 0 )
271 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]
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
CONST_VECTOR_OBJECT m_primitives
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]