KiCad PCB EDA Suite
bvh_packet_traversal.cpp File Reference

This file implements packet traversal over the BVH PBRT implementation. More...

#include "bvh_pbrt.h"

Go to the source code of this file.

Classes

struct  StackNode
 

Macros

#define BVH_RANGED_TRAVERSAL
 
#define MAX_TODOS   64
 

Functions

static unsigned int getFirstHit (const RAYPACKET &aRayPacket, const BBOX_3D &aBBox, unsigned int ia, HITINFO_PACKET *aHitInfoPacket)
 
static unsigned int getLastHit (const RAYPACKET &aRayPacket, const BBOX_3D &aBBox, unsigned int ia, HITINFO_PACKET *aHitInfoPacket)
 

Detailed Description

This file implements packet traversal over the BVH PBRT implementation.

Definition in file bvh_packet_traversal.cpp.

Macro Definition Documentation

◆ BVH_RANGED_TRAVERSAL

#define BVH_RANGED_TRAVERSAL

Definition at line 33 of file bvh_packet_traversal.cpp.

◆ MAX_TODOS

#define MAX_TODOS   64

Definition at line 37 of file bvh_packet_traversal.cpp.

Function Documentation

◆ getFirstHit()

static unsigned int getFirstHit ( const RAYPACKET aRayPacket,
const BBOX_3D aBBox,
unsigned int  ia,
HITINFO_PACKET aHitInfoPacket 
)
inlinestatic

Definition at line 47 of file bvh_packet_traversal.cpp.

49{
50 float hitT;
51
52 if( aBBox.Intersect( aRayPacket.m_ray[ia], &hitT )
53 && ( hitT < aHitInfoPacket[ia].m_HitInfo.m_tHit ) )
54 return ia;
55
56 if( !aRayPacket.m_Frustum.Intersect( aBBox ) )
58
59 for( unsigned int i = ia + 1; i < RAYPACKET_RAYS_PER_PACKET; ++i )
60 {
61 if( aBBox.Intersect( aRayPacket.m_ray[i], &hitT )
62 && ( hitT < aHitInfoPacket[i].m_HitInfo.m_tHit ) )
63 return i;
64 }
65
67}
#define RAYPACKET_RAYS_PER_PACKET
Definition: raypacket.h:35
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
bool Intersect(const BBOX_3D &aBBox) const
Intersect aBBox with this frustum.
Definition: frustum.cpp:58
RAY m_ray[RAYPACKET_RAYS_PER_PACKET]
Definition: raypacket.h:54
FRUSTUM m_Frustum
Definition: raypacket.h:53

References FRUSTUM::Intersect(), BBOX_3D::Intersect(), RAYPACKET::m_Frustum, HITINFO_PACKET::m_HitInfo, RAYPACKET::m_ray, HITINFO::m_tHit, and RAYPACKET_RAYS_PER_PACKET.

Referenced by BVH_PBRT::Intersect().

◆ getLastHit()

static unsigned int getLastHit ( const RAYPACKET aRayPacket,
const BBOX_3D aBBox,
unsigned int  ia,
HITINFO_PACKET aHitInfoPacket 
)
inlinestatic

Definition at line 72 of file bvh_packet_traversal.cpp.

74{
75 for( unsigned int ie = (RAYPACKET_RAYS_PER_PACKET - 1); ie > ia; --ie )
76 {
77 float hitT;
78
79 if( aBBox.Intersect( aRayPacket.m_ray[ie], &hitT )
80 && ( hitT < aHitInfoPacket[ie].m_HitInfo.m_tHit ) )
81 return ie + 1;
82 }
83
84 return ia + 1;
85}

References BBOX_3D::Intersect(), HITINFO_PACKET::m_HitInfo, RAYPACKET::m_ray, HITINFO::m_tHit, and RAYPACKET_RAYS_PER_PACKET.

Referenced by BVH_PBRT::Intersect().