29#ifndef GU_BV4_INTERNAL_H
30#define GU_BV4_INTERNAL_H
32#include "foundation/PxFPU.h"
38#ifdef GU_BV4_USE_SLABS
40 #ifdef GU_BV4_PROCESS_STREAM_NO_ORDER
41 template<
class LeafTestT,
class ParamsT>
45 return BV4_ProcessStreamSwizzledNoOrderQ<LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedQ*
>(tree.mNodes), tree.mInitData, params);
47 return BV4_ProcessStreamSwizzledNoOrderNQ<LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedNQ*
>(tree.mNodes), tree.mInitData, params);
51 #ifdef GU_BV4_PROCESS_STREAM_ORDERED
52 template<
class LeafTestT,
class ParamsT>
56 BV4_ProcessStreamSwizzledOrderedQ<LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedQ*
>(tree.mNodes), tree.mInitData, params);
58 BV4_ProcessStreamSwizzledOrderedNQ<LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedNQ*
>(tree.mNodes), tree.mInitData, params);
62 #ifdef GU_BV4_PROCESS_STREAM_RAY_NO_ORDER
63 template<
int inflateT,
class LeafTestT,
class ParamsT>
67 return BV4_ProcessStreamKajiyaNoOrderQ<inflateT, LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedQ*
>(tree.mNodes), tree.mInitData, params);
69 return BV4_ProcessStreamKajiyaNoOrderNQ<inflateT, LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedNQ*
>(tree.mNodes), tree.mInitData, params);
73 #ifdef GU_BV4_PROCESS_STREAM_RAY_ORDERED
74 template<
int inflateT,
class LeafTestT,
class ParamsT>
78 BV4_ProcessStreamKajiyaOrderedQ<inflateT, LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedQ*
>(tree.mNodes), tree.mInitData, params);
80 BV4_ProcessStreamKajiyaOrderedNQ<inflateT, LeafTestT, ParamsT>(
reinterpret_cast<const BVDataPackedNQ*
>(tree.mNodes), tree.mInitData, params);
84 #define processStreamNoOrder BV4_ProcessStreamNoOrder
85 #define processStreamOrdered BV4_ProcessStreamOrdered2
86 #define processStreamRayNoOrder(a, b) BV4_ProcessStreamNoOrder<b>
87 #define processStreamRayOrdered(a, b) BV4_ProcessStreamOrdered2<b>
90#ifndef GU_BV4_USE_SLABS
91#ifdef GU_BV4_PRECOMPUTED_NODE_SORT
107 const PxU32 X = PX_IR(dir.x)>>31;
108 const PxU32 Y = PX_IR(dir.y)>>31;
109 const PxU32 Z = PX_IR(dir.z)>>31;
110 const PxU32 bitIndex = Z|(Y<<1)|(X<<2);
122 static const PxU8 order[] = {
135 const PxU32 bit0 = (node[0].decodePNSNoShift() & dirMask) ? 1u : 0;
136 const PxU32 bit1 = (node[1].decodePNSNoShift() & dirMask) ? 1u : 0;
137 const PxU32 bit2 = (node[2].decodePNSNoShift() & dirMask) ? 1u : 0;
138 return bit2|(bit1<<1)|(bit0<<2);
142 #define PNS_BLOCK(i, a, b, c, d) \
145 if(code & (1<<a)) { stack[nb++] = node[a].getChildData(); } \
146 if(code & (1<<b)) { stack[nb++] = node[b].getChildData(); } \
147 if(code & (1<<c)) { stack[nb++] = node[c].getChildData(); } \
148 if(code & (1<<d)) { stack[nb++] = node[d].getChildData(); } \
151 #define PNS_BLOCK1(i, a, b, c, d) \
154 stack[nb] = node[a].getChildData(); nb += (code & (1<<a))?1:0; \
155 stack[nb] = node[b].getChildData(); nb += (code & (1<<b))?1:0; \
156 stack[nb] = node[c].getChildData(); nb += (code & (1<<c))?1:0; \
157 stack[nb] = node[d].getChildData(); nb += (code & (1<<d))?1:0; \
160 #define PNS_BLOCK2(a, b, c, d) { \
161 if(code & (1<<a)) { stack[nb++] = node[a].getChildData(); } \
162 if(code & (1<<b)) { stack[nb++] = node[b].getChildData(); } \
163 if(code & (1<<c)) { stack[nb++] = node[c].getChildData(); } \
164 if(code & (1<<d)) { stack[nb++] = node[d].getChildData(); } } \
166 template<
class LeafTestT,
class ParamsT>
167 static PxIntBool BV4_ProcessStreamNoOrder(
const BVDataPacked*
PX_RESTRICT node, PxU32 initData, ParamsT*
PX_RESTRICT params)
169 const BVDataPacked* root = node;
172 PxU32 stack[GU_BV4_STACK_SIZE];
177 const PxU32 childData = stack[--nb];
178 node = root + getChildOffset(childData);
179 const PxU32 nodeType = getChildType(childData);
181 if(nodeType>1 && BV4_ProcessNodeNoOrder<LeafTestT, 3>(stack, nb, node, params))
183 if(nodeType>0 && BV4_ProcessNodeNoOrder<LeafTestT, 2>(stack, nb, node, params))
185 if(BV4_ProcessNodeNoOrder<LeafTestT, 1>(stack, nb, node, params))
187 if(BV4_ProcessNodeNoOrder<LeafTestT, 0>(stack, nb, node, params))
195 template<
class LeafTestT,
class ParamsT>
196 static void BV4_ProcessStreamOrdered(
const BVDataPacked*
PX_RESTRICT node, PxU32 initData, ParamsT*
PX_RESTRICT params)
198 const BVDataPacked* root = node;
201 PxU32 stack[GU_BV4_STACK_SIZE];
204 const PxU32 dirMask = computeDirMask(params->mLocalDir)<<3;
208 const PxU32 childData = stack[--nb];
209 node = root + getChildOffset(childData);
211 const PxU8*
PX_RESTRICT ord = order + decodePNS(node, dirMask)*4;
212 const PxU32 limit = 2 + getChildType(childData);
214 BV4_ProcessNodeOrdered<LeafTestT>(stack, nb, node, params, ord[0], limit);
215 BV4_ProcessNodeOrdered<LeafTestT>(stack, nb, node, params, ord[1], limit);
216 BV4_ProcessNodeOrdered<LeafTestT>(stack, nb, node, params, ord[2], limit);
217 BV4_ProcessNodeOrdered<LeafTestT>(stack, nb, node, params, ord[3], limit);
222 template<
class LeafTestT,
class ParamsT>
223 static void BV4_ProcessStreamOrdered2(
const BVDataPacked*
PX_RESTRICT node, PxU32 initData, ParamsT*
PX_RESTRICT params)
225 const BVDataPacked* root = node;
228 PxU32 stack[GU_BV4_STACK_SIZE];
231 const PxU32 X = PX_IR(params->mLocalDir_Padded.x)>>31;
232 const PxU32 Y = PX_IR(params->mLocalDir_Padded.y)>>31;
233 const PxU32 Z = PX_IR(params->mLocalDir_Padded.z)>>31;
234 const PxU32 bitIndex = 3+(Z|(Y<<1)|(X<<2));
235 const PxU32 dirMask = 1u<<bitIndex;
239 const PxU32 childData = stack[--nb];
240 node = root + getChildOffset(childData);
241 const PxU32 nodeType = getChildType(childData);
244 BV4_ProcessNodeOrdered2<LeafTestT, 0>(code, node, params);
245 BV4_ProcessNodeOrdered2<LeafTestT, 1>(code, node, params);
247 BV4_ProcessNodeOrdered2<LeafTestT, 2>(code, node, params);
249 BV4_ProcessNodeOrdered2<LeafTestT, 3>(code, node, params);
257 if(node[0].decodePNSNoShift() & dirMask)
259 if(node[1].decodePNSNoShift() & dirMask)
261 if(node[2].decodePNSNoShift() & dirMask)
268 if(node[2].decodePNSNoShift() & dirMask)
276 if(node[1].decodePNSNoShift() & dirMask)
278 if(node[2].decodePNSNoShift() & dirMask)
285 if(node[2].decodePNSNoShift() & dirMask)
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335