#include "bvh_pbrt.h"
#include "../../../3d_fastmath.h"
#include <macros.h>
#include <boost/range/algorithm/nth_element.hpp>
#include <boost/range/algorithm/partition.hpp>
#include <cstdlib>
#include <vector>
#include <stack>
#include <wx/debug.h>
Go to the source code of this file.
◆ MAX_TODOS
◆ EncodeMorton3()
uint32_t EncodeMorton3 |
( |
const SFVEC3F & |
v | ) |
|
|
inline |
Definition at line 168 of file bvh_pbrt.cpp.
170 wxASSERT( v.x >= 0 && v.x <= ( 1 << 10 ) );
171 wxASSERT( v.y >= 0 && v.y <= ( 1 << 10 ) );
172 wxASSERT( v.z >= 0 && v.z <= ( 1 << 10 ) );
uint32_t LeftShift3(uint32_t x)
References LeftShift3().
Referenced by BVH_PBRT::HLBVHBuild().
◆ LeftShift3()
uint32_t LeftShift3 |
( |
uint32_t |
x | ) |
|
|
inline |
Definition at line 148 of file bvh_pbrt.cpp.
150 wxASSERT( x <= (1 << 10) );
152 if( x == ( 1 << 10 ) )
155 x = ( x | ( x << 16 ) ) & 0b00000011000000000000000011111111;
157 x = ( x | ( x << 8 ) ) & 0b00000011000000001111000000001111;
159 x = ( x | ( x << 4 ) ) & 0b00000011000011000011000011000011;
161 x = ( x | ( x << 2 ) ) & 0b00001001001001001001001001001001;
Referenced by EncodeMorton3().
◆ RadixSort()
Definition at line 178 of file bvh_pbrt.cpp.
180 std::vector<MortonPrimitive> tempVector( v->size() );
182 const int bitsPerPass = 6;
183 const int nBits = 30;
185 wxASSERT( ( nBits % bitsPerPass ) == 0 );
187 const int nPasses = nBits / bitsPerPass;
189 for(
int pass = 0; pass < nPasses; ++pass )
192 const int lowBit = pass * bitsPerPass;
195 std::vector<MortonPrimitive>& in = ( pass & 1 ) ? tempVector : *v;
196 std::vector<MortonPrimitive>& out = ( pass & 1 ) ? *v : tempVector;
199 const int nBuckets = 1 << bitsPerPass;
200 int bucketCount[nBuckets] = {0};
201 const int bitMask = ( 1 << bitsPerPass ) - 1;
203 for( uint32_t i = 0; i < in.size(); ++i )
206 int bucket = ( mp.
mortonCode >> lowBit ) & bitMask;
208 wxASSERT( ( bucket >= 0 ) && ( bucket < nBuckets ) );
210 ++bucketCount[bucket];
214 int startIndex[nBuckets];
217 for(
int i = 1; i < nBuckets; ++i )
218 startIndex[i] = startIndex[i - 1] + bucketCount[i - 1];
221 for( uint32_t i = 0; i < in.size(); ++i )
224 int bucket = (mp.
mortonCode >> lowBit) & bitMask;
225 out[startIndex[bucket]++] = mp;
231 std::swap( *v, tempVector );
References MortonPrimitive::mortonCode.
Referenced by BVH_PBRT::HLBVHBuild().