39 NodeTriangleCallback&
operator=(NodeTriangleCallback& other)
45 NodeTriangleCallback(
NodeArray& triangleNodes)
46 : m_triangleNodes(triangleNodes)
50 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
56 aabbMin.setMin(triangle[0]);
57 aabbMax.setMax(triangle[0]);
58 aabbMin.setMin(triangle[1]);
59 aabbMax.setMax(triangle[1]);
60 aabbMin.setMin(triangle[2]);
61 aabbMax.setMax(triangle[2]);
64 node.m_aabbMinOrg = aabbMin;
65 node.m_aabbMaxOrg = aabbMax;
67 node.m_escapeIndex = -1;
70 node.m_subPart = partId;
71 node.m_triangleIndex = triangleIndex;
80 QuantizedNodeTriangleCallback&
operator=(QuantizedNodeTriangleCallback& other)
83 m_optimizedTree = other.m_optimizedTree;
88 : m_triangleNodes(triangleNodes), m_optimizedTree(
tree)
92 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
104 aabbMin.setMin(triangle[0]);
105 aabbMax.setMax(triangle[0]);
106 aabbMin.setMin(triangle[1]);
107 aabbMax.setMax(triangle[1]);
108 aabbMin.setMin(triangle[2]);
109 aabbMax.setMax(triangle[2]);
114 if (aabbMax.x() - aabbMin.x() < MIN_AABB_DIMENSION)
116 aabbMax.setX(aabbMax.x() + MIN_AABB_HALF_DIMENSION);
117 aabbMin.setX(aabbMin.x() - MIN_AABB_HALF_DIMENSION);
119 if (aabbMax.y() - aabbMin.y() < MIN_AABB_DIMENSION)
121 aabbMax.setY(aabbMax.y() + MIN_AABB_HALF_DIMENSION);
122 aabbMin.setY(aabbMin.y() - MIN_AABB_HALF_DIMENSION);
124 if (aabbMax.z() - aabbMin.z() < MIN_AABB_DIMENSION)
126 aabbMax.setZ(aabbMax.z() + MIN_AABB_HALF_DIMENSION);
127 aabbMin.setZ(aabbMin.z() - MIN_AABB_HALF_DIMENSION);
130 m_optimizedTree->quantize(&
node.m_quantizedAabbMin[0], aabbMin, 0);
131 m_optimizedTree->quantize(&
node.m_quantizedAabbMax[0], aabbMax, 1);
139 int numLeafNodes = 0;
162 triangles->InternalProcessAllTriangles(&
callback, aabbMin, aabbMax);
179 subtree.m_rootNodeIndex = 0;
229 unsigned short quantizedQueryAabbMin[3];
230 unsigned short quantizedQueryAabbMax[3];
232 quantize(&quantizedQueryAabbMin[0], aabbMin, 0);
233 quantize(&quantizedQueryAabbMax[0], aabbMax, 1);
244 updateBvhNodes(meshInterface, subtree.m_rootNodeIndex, subtree.m_rootNodeIndex + subtree.m_subtreeSize, i);
257 int curNodeSubPart = -1;
260 const unsigned char* vertexbase = 0;
264 const unsigned char* indexbase = 0;
271 const btVector3& meshScaling = meshInterface->getScaling();
274 for (i = endNode - 1; i >= firstNode; i--)
277 if (curNode.isLeafNode())
280 int nodeSubPart = curNode.getPartId();
281 int nodeTriangleIndex = curNode.getTriangleIndex();
282 if (nodeSubPart != curNodeSubPart)
284 if (curNodeSubPart >= 0)
285 meshInterface->unLockReadOnlyVertexBase(curNodeSubPart);
286 meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase, numverts,
type,
stride, &indexbase, indexstride, numfaces, indicestype, nodeSubPart);
288 curNodeSubPart = nodeSubPart;
292 unsigned int* gfxbase = (
unsigned int*)(indexbase + nodeTriangleIndex * indexstride);
294 for (
int j = 2; j >= 0; j--)
297 switch (indicestype) {
298 case PHY_INTEGER: graphicsindex = gfxbase[j];
break;
299 case PHY_SHORT: graphicsindex = ((
unsigned short*)gfxbase)[j];
break;
300 case PHY_UCHAR: graphicsindex = ((
unsigned char*)gfxbase)[j];
break;
305 float* graphicsbase = (
float*)(vertexbase + graphicsindex *
stride);
307 graphicsbase[0] * meshScaling.getX(),
308 graphicsbase[1] * meshScaling.getY(),
309 graphicsbase[2] * meshScaling.getZ());
313 double* graphicsbase = (
double*)(vertexbase + graphicsindex *
stride);
314 triangleVerts[j] =
btVector3(
btScalar(graphicsbase[0] * meshScaling.getX()),
btScalar(graphicsbase[1] * meshScaling.getY()),
btScalar(graphicsbase[2] * meshScaling.getZ()));
320 aabbMin.setMin(triangleVerts[0]);
321 aabbMax.setMax(triangleVerts[0]);
322 aabbMin.setMin(triangleVerts[1]);
323 aabbMax.setMax(triangleVerts[1]);
324 aabbMin.setMin(triangleVerts[2]);
325 aabbMax.setMax(triangleVerts[2]);
327 quantize(&curNode.m_quantizedAabbMin[0], aabbMin, 0);
328 quantize(&curNode.m_quantizedAabbMax[0], aabbMax, 1);
339 for (
int i = 0; i < 3; i++)
341 curNode.m_quantizedAabbMin[i] = leftChildNode->m_quantizedAabbMin[i];
342 if (curNode.m_quantizedAabbMin[i] > rightChildNode->m_quantizedAabbMin[i])
343 curNode.m_quantizedAabbMin[i] = rightChildNode->m_quantizedAabbMin[i];
345 curNode.m_quantizedAabbMax[i] = leftChildNode->m_quantizedAabbMax[i];
346 if (curNode.m_quantizedAabbMax[i] < rightChildNode->m_quantizedAabbMax[i])
347 curNode.m_quantizedAabbMax[i] = rightChildNode->m_quantizedAabbMax[i];
353 if (curNodeSubPart >= 0)
354 meshInterface->unLockReadOnlyVertexBase(curNodeSubPart);
_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 type
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
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)
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
void updateBvhNodes(btStridingMeshInterface *meshInterface, int firstNode, int endNode, int index)
virtual ~btOptimizedBvh()
void refitPartial(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
void build(btStridingMeshInterface *triangles, bool useQuantizedAabbCompression, const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax)
SIMD_FORCE_INLINE void quantize(unsigned short *out, const btVector3 &point, int isMax) const
void setQuantizationValues(const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax, btScalar quantizationMargin=btScalar(1.0))
***************************************** expert/internal use only *************************
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'
NodeArray m_contiguousNodes
#define MAX_NUM_PARTS_IN_BITS
btBvhSubtreeInfo
btBvhSubtreeInfo provides info to gather a subtree of limited size
BvhSubtreeInfoArray m_SubtreeHeaders
QuantizedNodeArray m_quantizedContiguousNodes
void buildTree(int startIndex, int endIndex)
QuantizedNodeArray m_quantizedLeafNodes
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
SIMD_FORCE_INLINE void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
void copyFromArray(const btAlignedObjectArray &otherArray)
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
SIMD_FORCE_INLINE void resize(int newsize, const T &fillData=T())
SIMD_FORCE_INLINE void push_back(const T &_Val)
SIMD_FORCE_INLINE T & expand(const T &fillValue=T())
DEGForeachIDComponentCallback callback
SyclQueue void void size_t num_bytes void