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
172 TRAVERSAL_STACKLESS = 0,
173 TRAVERSAL_STACKLESS_CACHE_FRIENDLY,
259 unsigned short int quantizedAabbMin[3];
260 unsigned short int quantizedAabbMax[3];
261 quantize(quantizedAabbMin, newAabbMin, 0);
262 quantize(quantizedAabbMax, newAabbMax, 1);
263 for (
int i = 0; i < 3; i++)
344 out[0] = (
unsigned short)(((
unsigned short)(
v.getX() +
btScalar(1.)) | 1));
345 out[1] = (
unsigned short)(((
unsigned short)(
v.getY() +
btScalar(1.)) | 1));
346 out[2] = (
unsigned short)(((
unsigned short)(
v.getZ() +
btScalar(1.)) | 1));
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
359 if (newPoint.getX() <
point.getX())
361 printf(
"unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() -
point.getX(), newPoint.getX(),
point.getX());
363 if (newPoint.getY() <
point.getY())
365 printf(
"unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() -
point.getY(), newPoint.getY(),
point.getY());
367 if (newPoint.getZ() <
point.getZ())
369 printf(
"unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() -
point.getZ(), newPoint.getZ(),
point.getZ());
374 if (newPoint.getX() >
point.getX())
376 printf(
"unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() -
point.getX(), newPoint.getX(),
point.getX());
378 if (newPoint.getY() >
point.getY())
380 printf(
"unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() -
point.getY(), newPoint.getY(),
point.getY());
382 if (newPoint.getZ() >
point.getZ())
384 printf(
"unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() -
point.getZ(), newPoint.getZ(),
point.getZ());
434 virtual bool serialize(
void* o_alignedDataBuffer,
unsigned i_dataBufferSize,
bool i_swapEndian)
const;
467 struct btBvhSubtreeInfoData
475 struct btOptimizedBvhNodeFloatData
485 struct btOptimizedBvhNodeDoubleData
496 struct btQuantizedBvhNodeData
503 struct btQuantizedBvhFloatData
510 int m_numContiguousLeafNodes;
511 int m_numQuantizedContiguousNodes;
512 btOptimizedBvhNodeFloatData *m_contiguousNodesPtr;
513 btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
514 btBvhSubtreeInfoData *m_subTreeInfoPtr;
516 int m_numSubtreeHeaders;
520 struct btQuantizedBvhDoubleData
527 int m_numContiguousLeafNodes;
528 int m_numQuantizedContiguousNodes;
529 btOptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
530 btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
533 int m_numSubtreeHeaders;
534 btBvhSubtreeInfoData *m_subTreeInfoPtr;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
ATTR_WARN_UNUSED_RESULT const BMVert * v
void reportAabbOverlappingNodex(btNodeOverlapCallback *nodeCallback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
***************************************** expert/internal use only *************************
BT_DECLARE_ALIGNED_ALLOCATOR()
SIMD_FORCE_INLINE void quantize(unsigned short *out, const btVector3 &point, int isMax) const
virtual int calculateSerializeBufferSizeNew() const
void setQuantizationValues(const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax, btScalar quantizationMargin=btScalar(1.0))
***************************************** expert/internal use only *************************
void swapLeafNodes(int firstIndex, int secondIndex)
int m_escapeIndexOrTriangleIndex
void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode *currentNode, btNodeOverlapCallback *nodeCallback, unsigned short int *quantizedQueryAabbMin, unsigned short int *quantizedQueryAabbMax) const
use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
void mergeInternalNodeAabb(int nodeIndex, const btVector3 &newAabbMin, const btVector3 &newAabbMax)
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode *treeNodeA, const btQuantizedBvhNode *treeNodeB, btNodeOverlapCallback *nodeCallback) const
use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
int getTriangleIndex() const
void updateSubtreeHeaders(int leftChildNodexIndex, int rightChildNodexIndex)
void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
static btQuantizedBvh * deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian)
deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
virtual void deSerializeFloat(struct btQuantizedBvhFloatData &quantizedBvhFloatData)
SIMD_FORCE_INLINE QuantizedNodeArray & getQuantizedNodeArray()
unsigned short int m_quantizedAabbMin[3]
btTraversalMode m_traversalMode
btAlignedObjectArray< btOptimizedBvhNode > NodeArray
for code readability:
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short *out, const btVector3 &point2, int isMax) const
NodeArray m_contiguousNodes
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback *nodeCallback, const btVector3 &raySource, const btVector3 &rayTarget, const btVector3 &aabbMin, const btVector3 &aabbMax, int startNodeIndex, int endNodeIndex) const
virtual ~btQuantizedBvh()
QuantizedNodeArray & getLeafNodeArray()
void setInternalNodeAabbMin(int nodeIndex, const btVector3 &aabbMin)
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData &quantizedBvhDoubleData)
static unsigned int getAlignmentSerializationPadding()
void reportRayOverlappingNodex(btNodeOverlapCallback *nodeCallback, const btVector3 &raySource, const btVector3 &rayTarget) const
btAlignedObjectArray< btBvhSubtreeInfo > BvhSubtreeInfoArray
void reportBoxCastOverlappingNodex(btNodeOverlapCallback *nodeCallback, const btVector3 &raySource, const btVector3 &rayTarget, const btVector3 &aabbMin, const btVector3 &aabbMax) const
unsigned calculateSerializeBufferSize() const
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback *nodeCallback, unsigned short int *quantizedQueryAabbMin, unsigned short int *quantizedQueryAabbMax) const
tree traversal designed for small-memory processors like PS3 SPU
#define MAX_NUM_PARTS_IN_BITS
void walkStacklessTree(btNodeOverlapCallback *nodeCallback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
btAlignedObjectArray< btQuantizedBvhNode > QuantizedNodeArray
btBvhSubtreeInfo
btBvhSubtreeInfo provides info to gather a subtree of limited size
btVector3 getAabbMax(int nodeIndex) const
void walkStacklessTreeAgainstRay(btNodeOverlapCallback *nodeCallback, const btVector3 &raySource, const btVector3 &rayTarget, const btVector3 &aabbMin, const btVector3 &aabbMax, int startNodeIndex, int endNodeIndex) const
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
Data buffer MUST be 16 byte aligned.
btVector3 m_bvhQuantization
BvhSubtreeInfoArray m_SubtreeHeaders
void setAabbFromQuantizeNode(const btQuantizedBvhNode &quantizedNode)
unsigned short int m_quantizedAabbMax[3]
void walkStacklessQuantizedTree(btNodeOverlapCallback *nodeCallback, unsigned short int *quantizedQueryAabbMin, unsigned short int *quantizedQueryAabbMax, int startNodeIndex, int endNodeIndex) const
void assignInternalNodeFromLeafNode(int internalNode, int leafNodeIndex)
QuantizedNodeArray m_quantizedContiguousNodes
SIMD_FORCE_INLINE BvhSubtreeInfoArray & getSubtreeInfoArray()
int sortAndCalcSplittingIndex(int startIndex, int endIndex, int splitAxis)
int getEscapeIndex() const
void setInternalNodeAabbMax(int nodeIndex, const btVector3 &aabbMax)
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short *vecIn) const
int calcSplittingAxis(int startIndex, int endIndex)
void buildTree(int startIndex, int endIndex)
SIMD_FORCE_INLINE bool isQuantized()
void buildInternal()
buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialize...
QuantizedNodeArray m_quantizedLeafNodes
void setTraversalMode(btTraversalMode traversalMode)
setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree trave...
#define btQuantizedBvhData
btVector3 getAabbMin(int nodeIndex) const
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
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
virtual ~btNodeOverlapCallback()
virtual void processNode(int subPart, int triangleIndex)=0
static const pxr::TfToken out("out", pxr::TfToken::Immortal)