KiCad PCB EDA Suite
bvh_packet_traversal.cpp File Reference

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

#include "bvh_pbrt.h"
#include <wx/debug.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 implementes 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 34 of file bvh_packet_traversal.cpp.

◆ MAX_TODOS

#define MAX_TODOS   64

Definition at line 38 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 48 of file bvh_packet_traversal.cpp.

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

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 73 of file bvh_packet_traversal.cpp.

75 {
76  for( unsigned int ie = (RAYPACKET_RAYS_PER_PACKET - 1); ie > ia; --ie )
77  {
78  float hitT;
79 
80  if( aBBox.Intersect( aRayPacket.m_ray[ie], &hitT )
81  && ( hitT < aHitInfoPacket[ie].m_HitInfo.m_tHit ) )
82  return ie + 1;
83  }
84 
85  return ia + 1;
86 }
RAY m_ray[RAYPACKET_RAYS_PER_PACKET]
Definition: raypacket.h:59
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
float m_tHit
( 4) distance
Definition: hitinfo.h:43
HITINFO m_HitInfo
Definition: hitinfo.h:63
#define RAYPACKET_RAYS_PER_PACKET
Definition: raypacket.h:40

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

Referenced by BVH_PBRT::Intersect().