44 NodeTriangleCallback& operator=(NodeTriangleCallback& other)
50 NodeTriangleCallback(
NodeArray& triangleNodes)
51 :m_triangleNodes(triangleNodes)
55 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
61 aabbMin.
setMin(triangle[0]);
62 aabbMax.
setMax(triangle[0]);
63 aabbMin.
setMin(triangle[1]);
64 aabbMax.
setMax(triangle[1]);
65 aabbMin.
setMin(triangle[2]);
66 aabbMax.
setMax(triangle[2]);
85 QuantizedNodeTriangleCallback& operator=(QuantizedNodeTriangleCallback& other)
88 m_optimizedTree = other.m_optimizedTree;
93 :m_triangleNodes(triangleNodes),m_optimizedTree(tree)
97 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
109 aabbMin.
setMin(triangle[0]);
110 aabbMax.
setMax(triangle[0]);
111 aabbMin.
setMin(triangle[1]);
112 aabbMax.
setMax(triangle[1]);
113 aabbMin.
setMin(triangle[2]);
114 aabbMax.
setMax(triangle[2]);
119 if (aabbMax.
x() - aabbMin.
x() < MIN_AABB_DIMENSION)
121 aabbMax.
setX(aabbMax.
x() + MIN_AABB_HALF_DIMENSION);
122 aabbMin.
setX(aabbMin.
x() - MIN_AABB_HALF_DIMENSION);
124 if (aabbMax.
y() - aabbMin.
y() < MIN_AABB_DIMENSION)
126 aabbMax.
setY(aabbMax.
y() + MIN_AABB_HALF_DIMENSION);
127 aabbMin.
setY(aabbMin.
y() - MIN_AABB_HALF_DIMENSION);
129 if (aabbMax.
z() - aabbMin.
z() < MIN_AABB_DIMENSION)
131 aabbMax.
setZ(aabbMax.
z() + MIN_AABB_HALF_DIMENSION);
132 aabbMin.
setZ(aabbMin.
z() - MIN_AABB_HALF_DIMENSION);
146 int numLeafNodes = 0;
249 unsigned short quantizedQueryAabbMin[3];
250 unsigned short quantizedQueryAabbMax[3];
252 quantize(&quantizedQueryAabbMin[0],aabbMin,0);
253 quantize(&quantizedQueryAabbMax[0],aabbMax,1);
278 int curNodeSubPart=-1;
281 const unsigned char *vertexbase = 0;
285 const unsigned char *indexbase = 0;
295 for (i=endNode-1;i>=firstNode;i--)
305 if (nodeSubPart != curNodeSubPart)
307 if (curNodeSubPart >= 0)
311 curNodeSubPart = nodeSubPart;
316 unsigned int* gfxbase = (
unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
319 for (
int j=2;j>=0;j--)
322 int graphicsindex = indicestype==
PHY_SHORT?((
unsigned short*)gfxbase)[j]:gfxbase[j];
325 float* graphicsbase = (
float*)(vertexbase+graphicsindex*stride);
327 graphicsbase[0]*meshScaling.
getX(),
328 graphicsbase[1]*meshScaling.
getY(),
329 graphicsbase[2]*meshScaling.
getZ());
333 double* graphicsbase = (
double*)(vertexbase+graphicsindex*stride);
342 aabbMin.
setMin(triangleVerts[0]);
343 aabbMax.
setMax(triangleVerts[0]);
344 aabbMin.
setMin(triangleVerts[1]);
345 aabbMax.
setMax(triangleVerts[1]);
346 aabbMin.
setMin(triangleVerts[2]);
347 aabbMax.
setMax(triangleVerts[2]);
363 for (
int i=0;i<3;i++)
378 if (curNodeSubPart >= 0)
SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(const unsigned short int *aabbMin1, const unsigned short int *aabbMax1, const unsigned short int *aabbMin2, const unsigned short int *aabbMax2)
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
btAlignedObjectArray< btOptimizedBvhNode > NodeArray
for code readability:
#define MAX_NUM_PARTS_IN_BITS
btAlignedObjectArray< btQuantizedBvhNode > QuantizedNodeArray
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
void copyFromArray(const btAlignedObjectArray &otherArray)
void push_back(const T &_Val)
btBvhSubtreeInfo provides info to gather a subtree of limited size
unsigned short int m_quantizedAabbMax[3]
unsigned short int m_quantizedAabbMin[3]
void setAabbFromQuantizeNode(const btQuantizedBvhNode &quantizedNode)
static btOptimizedBvh * deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian)
deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
void updateBvhNodes(btStridingMeshInterface *meshInterface, int firstNode, int endNode, int index)
virtual ~btOptimizedBvh()
void refitPartial(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
void build(btStridingMeshInterface *triangles, bool useQuantizedAabbCompression, const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax)
void setQuantizationValues(const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax, btScalar quantizationMargin=btScalar(1.0))
***************************************** expert/internal use only *************************
void buildTree(int startIndex, int endIndex)
QuantizedNodeArray m_quantizedLeafNodes
void quantize(unsigned short *out, const btVector3 &point, int isMax) const
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'
BvhSubtreeInfoArray m_SubtreeHeaders
NodeArray m_contiguousNodes
QuantizedNodeArray m_quantizedContiguousNodes
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
const btVector3 & getScaling() const
virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &stride, const unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0) const =0
virtual void unLockReadOnlyVertexBase(int subpart) const =0
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
void setZ(btScalar _z)
Set the z value.
const btScalar & z() const
Return the z value.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
void setY(btScalar _y)
Set the y value.
void setX(btScalar _x)
Set the x value.
const btScalar & getY() const
Return the y value.
const btScalar & x() const
Return the x value.
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
const btScalar & getX() const
Return the x value.
const btScalar & y() const
Return the y value.
btOptimizedBvhNode contains both internal and leaf node information.
btQuantizedBvhNode is a compressed aabb node, 16 bytes.
unsigned short int m_quantizedAabbMin[3]
unsigned short int m_quantizedAabbMax[3]
int getEscapeIndex() const
int m_escapeIndexOrTriangleIndex
int getTriangleIndex() const