Back to index

supertuxkart  0.5+dfsg1
Classes | Defines | Typedefs | Functions
btOptimizedBvh.h File Reference
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedAllocator.h"
#include "LinearMath/btAlignedObjectArray.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  btNodeOverlapCallback

Defines

#define MAX_SUBTREE_SIZE_IN_BYTES   2048
#define MAX_NUM_PARTS_IN_BITS   10
#define USE_BANCHLESS   1

Typedefs

typedef btAlignedObjectArray
< btOptimizedBvhNode > 
NodeArray
 for code readability:
typedef btAlignedObjectArray
< btQuantizedBvhNode > 
QuantizedNodeArray
typedef btAlignedObjectArray
< btBvhSubtreeInfo > 
BvhSubtreeInfoArray

Functions

 ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
 btQuantizedBvhNode is a compressed aabb node, 16 bytes. Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
 ATTRIBUTE_ALIGNED16 (class) btBvhSubtreeInfo
 btBvhSubtreeInfo provides info to gather a subtree of limited size

Define Documentation

#define MAX_NUM_PARTS_IN_BITS   10

Definition at line 44 of file btOptimizedBvh.h.

#define MAX_SUBTREE_SIZE_IN_BYTES   2048

Definition at line 40 of file btOptimizedBvh.h.

#define USE_BANCHLESS   1

Typedef Documentation

typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray

Definition at line 156 of file btOptimizedBvh.h.

typedef btAlignedObjectArray<btOptimizedBvhNode> NodeArray

for code readability:

Definition at line 154 of file btOptimizedBvh.h.

typedef btAlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray

Definition at line 155 of file btOptimizedBvh.h.


Function Documentation

ATTRIBUTE_ALIGNED16 ( struct  )

btQuantizedBvhNode is a compressed aabb node, 16 bytes. Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).

btOptimizedBvhNode contains both internal and leaf node information. Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.

Definition at line 48 of file btOptimizedBvh.h.

{
       BT_DECLARE_ALIGNED_ALLOCATOR();

       //12 bytes
       unsigned short int   m_quantizedAabbMin[3];
       unsigned short int   m_quantizedAabbMax[3];
       //4 bytes
       int    m_escapeIndexOrTriangleIndex;

       bool isLeafNode() const
       {
              //skipindex is negative (internal node), triangleindex >=0 (leafnode)
              return (m_escapeIndexOrTriangleIndex >= 0);
       }
       int getEscapeIndex() const
       {
              btAssert(!isLeafNode());
              return -m_escapeIndexOrTriangleIndex;
       }
       int    getTriangleIndex() const
       {
              btAssert(isLeafNode());
              // Get only the lower bits where the triangle index is stored
              return (m_escapeIndexOrTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
       }
       int    getPartId() const
       {
              btAssert(isLeafNode());
              // Get only the highest bits where the part index is stored
              return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
       }
}
ATTRIBUTE_ALIGNED16 ( class  )

btBvhSubtreeInfo provides info to gather a subtree of limited size

OptimizedBvh store an AABB tree that can be quickly traversed on CPU (and SPU,GPU in future)

two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!) this might be refactored into a virtual, it is usually not calculated at run-time

tree traversal designed for small-memory processors like PS3 SPU

use the 16-byte stackless 'skipindex' node tree to do a recursive traversal

use the 16-byte stackless 'skipindex' node tree to do a recursive traversal

***************************************** expert/internal use only *************************

buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized

***************************************** expert/internal use only *************************

Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative end-points always set the first bit, so that they are sorted properly (so that neighbouring AABBs overlap properly) todo: double-check this

setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.

Data buffer MUST be 16 byte aligned

deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'

Definition at line 107 of file btOptimizedBvh.h.

{
public:
       BT_DECLARE_ALIGNED_ALLOCATOR();

       //12 bytes
       unsigned short int   m_quantizedAabbMin[3];
       unsigned short int   m_quantizedAabbMax[3];
       //4 bytes, points to the root of the subtree
       int                  m_rootNodeIndex;
       //4 bytes
       int                  m_subtreeSize;
       int                  m_padding[3];

       btBvhSubtreeInfo()
       {
              //memset(&m_padding[0], 0, sizeof(m_padding));
       }


       void   setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
       {
              m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
              m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
              m_quantizedAabbMin[2] = quantizedNode.m_quantizedAabbMin[2];
              m_quantizedAabbMax[0] = quantizedNode.m_quantizedAabbMax[0];
              m_quantizedAabbMax[1] = quantizedNode.m_quantizedAabbMax[1];
              m_quantizedAabbMax[2] = quantizedNode.m_quantizedAabbMax[2];
       }
}