16#ifndef BT_QUANTIZED_BVH_H
17#define BT_QUANTIZED_BVH_H
22#ifdef DEBUG_CHECK_DEQUANTIZATION
24#define printf spu_printf
34#ifdef BT_USE_DOUBLE_PRECISION
35#define btQuantizedBvhData btQuantizedBvhDoubleData
36#define btOptimizedBvhNodeData btOptimizedBvhNodeDoubleData
37#define btQuantizedBvhDataName "btQuantizedBvhDoubleData"
39#define btQuantizedBvhData btQuantizedBvhFloatData
40#define btOptimizedBvhNodeData btOptimizedBvhNodeFloatData
41#define btQuantizedBvhDataName "btQuantizedBvhFloatData"
47#define MAX_SUBTREE_SIZE_IN_BYTES 2048
51#define MAX_NUM_PARTS_IN_BITS 10
61 unsigned short int m_quantizedAabbMin[3];
62 unsigned short int m_quantizedAabbMax[3];
69 return (m_escapeIndexOrTriangleIndex >= 0);
74 return -m_escapeIndexOrTriangleIndex;
82 return (m_escapeIndexOrTriangleIndex & ~(y));
123 unsigned short int m_quantizedAabbMin[3];
124 unsigned short int m_quantizedAabbMax[3];
172 TRAVERSAL_STACKLESS = 0,
203 if (m_useQuantization)
205 quantize(&m_quantizedContiguousNodes[
nodeIndex].m_quantizedAabbMin[0],
aabbMin, 0);
214 if (m_useQuantization)
216 quantize(&m_quantizedContiguousNodes[
nodeIndex].m_quantizedAabbMax[0],
aabbMax, 1);
226 if (m_useQuantization)
228 return unQuantize(&m_quantizedLeafNodes[
nodeIndex].m_quantizedAabbMin[0]);
231 return m_leafNodes[
nodeIndex].m_aabbMinOrg;
235 if (m_useQuantization)
237 return unQuantize(&m_quantizedLeafNodes[
nodeIndex].m_quantizedAabbMax[0]);
240 return m_leafNodes[
nodeIndex].m_aabbMaxOrg;
245 if (m_useQuantization)
257 if (m_useQuantization)
263 for (
int i = 0; i < 3; i++)
319 void buildInternal();
338 btVector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
350 out[0] = (
unsigned short)(((
unsigned short)(v.
getX()) & 0xfffe));
351 out[1] = (
unsigned short)(((
unsigned short)(v.
getY()) & 0xfffe));
352 out[2] = (
unsigned short)(((
unsigned short)(v.
getZ()) & 0xfffe));
355#ifdef DEBUG_CHECK_DEQUANTIZATION
420 return m_quantizedContiguousNodes;
425 return m_SubtreeHeaders;
431 unsigned calculateSerializeBufferSize()
const;
439 static unsigned int getAlignmentSerializationPadding();
442 virtual int calculateSerializeBufferSizeNew()
const;
455 return m_useQuantization;
const T & btMax(const T &a, const T &b)
btAlignedObjectArray< btOptimizedBvhNode > NodeArray
for code readability:
btAlignedObjectArray< btBvhSubtreeInfo > BvhSubtreeInfoArray
#define MAX_NUM_PARTS_IN_BITS
btAlignedObjectArray< btQuantizedBvhNode > QuantizedNodeArray
#define btQuantizedBvhData
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
#define SIMD_FORCE_INLINE
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
btBvhSubtreeInfo provides info to gather a subtree of limited size
BT_DECLARE_ALIGNED_ALLOCATOR()
void setAabbFromQuantizeNode(const btQuantizedBvhNode &quantizedNode)
virtual ~btNodeOverlapCallback()
virtual void processNode(int subPart, int triangleIndex)=0
The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
void setInternalNodeAabbMax(int nodeIndex, const btVector3 &aabbMax)
QuantizedNodeArray & getLeafNodeArray()
QuantizedNodeArray m_quantizedLeafNodes
btTraversalMode m_traversalMode
void quantize(unsigned short *out, const btVector3 &point, int isMax) const
BvhSubtreeInfoArray & getSubtreeInfoArray()
btVector3 m_bvhQuantization
void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
@ TRAVERSAL_STACKLESS_CACHE_FRIENDLY
BvhSubtreeInfoArray m_SubtreeHeaders
NodeArray m_contiguousNodes
QuantizedNodeArray & getQuantizedNodeArray()
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode *treeNodeA, const btQuantizedBvhNode *treeNodeB, btNodeOverlapCallback *nodeCallback) const
use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
void setInternalNodeAabbMin(int nodeIndex, const btVector3 &aabbMin)
two versions, one for quantized and normal nodes.
void mergeInternalNodeAabb(int nodeIndex, const btVector3 &newAabbMin, const btVector3 &newAabbMax)
BT_DECLARE_ALIGNED_ALLOCATOR()
virtual int calculateSerializeBufferSizeNew() const
void quantizeWithClamp(unsigned short *out, const btVector3 &point2, int isMax) const
void setTraversalMode(btTraversalMode traversalMode)
setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree trave...
btVector3 getAabbMax(int nodeIndex) const
btVector3 getAabbMin(int nodeIndex) const
QuantizedNodeArray m_quantizedContiguousNodes
btVector3 unQuantize(const unsigned short *vecIn) const
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
unsigned short m_quantizedAabbMin[3]
unsigned short m_quantizedAabbMax[3]
btVector3DoubleData m_aabbMaxOrg
btVector3DoubleData m_aabbMinOrg
btVector3FloatData m_aabbMaxOrg
btVector3FloatData m_aabbMinOrg
btOptimizedBvhNode contains both internal and leaf node information.
BT_DECLARE_ALIGNED_ALLOCATOR()
btBvhSubtreeInfoData * m_subTreeInfoPtr
int m_numContiguousLeafNodes
btVector3DoubleData m_bvhAabbMin
btVector3DoubleData m_bvhAabbMax
int m_numQuantizedContiguousNodes
btVector3DoubleData m_bvhQuantization
btQuantizedBvhNodeData * m_quantizedContiguousNodesPtr
btOptimizedBvhNodeDoubleData * m_contiguousNodesPtr
btOptimizedBvhNodeFloatData * m_contiguousNodesPtr
btVector3FloatData m_bvhAabbMin
int m_numQuantizedContiguousNodes
btBvhSubtreeInfoData * m_subTreeInfoPtr
int m_numContiguousLeafNodes
btVector3FloatData m_bvhQuantization
btQuantizedBvhNodeData * m_quantizedContiguousNodesPtr
btVector3FloatData m_bvhAabbMax
int m_escapeIndexOrTriangleIndex
unsigned short m_quantizedAabbMax[3]
unsigned short m_quantizedAabbMin[3]
btQuantizedBvhNode is a compressed aabb node, 16 bytes.
int getEscapeIndex() const
int m_escapeIndexOrTriangleIndex
BT_DECLARE_ALIGNED_ALLOCATOR()
int getTriangleIndex() const