btQuantizedBvh.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef BT_QUANTIZED_BVH_H
  14. #define BT_QUANTIZED_BVH_H
  15. class btSerializer;
  16. //#define DEBUG_CHECK_DEQUANTIZATION 1
  17. #ifdef DEBUG_CHECK_DEQUANTIZATION
  18. #ifdef __SPU__
  19. #define printf spu_printf
  20. #endif //__SPU__
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #endif //DEBUG_CHECK_DEQUANTIZATION
  24. #include "LinearMath/btVector3.h"
  25. #include "LinearMath/btAlignedAllocator.h"
  26. #ifdef BT_USE_DOUBLE_PRECISION
  27. #define btQuantizedBvhData btQuantizedBvhDoubleData
  28. #define btOptimizedBvhNodeData btOptimizedBvhNodeDoubleData
  29. #define btQuantizedBvhDataName "btQuantizedBvhDoubleData"
  30. #else
  31. #define btQuantizedBvhData btQuantizedBvhFloatData
  32. #define btOptimizedBvhNodeData btOptimizedBvhNodeFloatData
  33. #define btQuantizedBvhDataName "btQuantizedBvhFloatData"
  34. #endif
  35. //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp
  36. //Note: currently we have 16 bytes per quantized node
  37. #define MAX_SUBTREE_SIZE_IN_BYTES 2048
  38. // 10 gives the potential for 1024 parts, with at most 2^21 (2097152) (minus one
  39. // actually) triangles each (since the sign bit is reserved
  40. #define MAX_NUM_PARTS_IN_BITS 10
  41. ///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
  42. ///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
  43. ATTRIBUTE_ALIGNED16(struct)
  44. btQuantizedBvhNode
  45. {
  46. BT_DECLARE_ALIGNED_ALLOCATOR();
  47. //12 bytes
  48. unsigned short int m_quantizedAabbMin[3];
  49. unsigned short int m_quantizedAabbMax[3];
  50. //4 bytes
  51. int m_escapeIndexOrTriangleIndex;
  52. bool isLeafNode() const
  53. {
  54. //skipindex is negative (internal node), triangleindex >=0 (leafnode)
  55. return (m_escapeIndexOrTriangleIndex >= 0);
  56. }
  57. int getEscapeIndex() const
  58. {
  59. btAssert(!isLeafNode());
  60. return -m_escapeIndexOrTriangleIndex;
  61. }
  62. int getTriangleIndex() const
  63. {
  64. btAssert(isLeafNode());
  65. unsigned int x = 0;
  66. unsigned int y = (~(x & 0)) << (31 - MAX_NUM_PARTS_IN_BITS);
  67. // Get only the lower bits where the triangle index is stored
  68. return (m_escapeIndexOrTriangleIndex & ~(y));
  69. }
  70. int getPartId() const
  71. {
  72. btAssert(isLeafNode());
  73. // Get only the highest bits where the part index is stored
  74. return (m_escapeIndexOrTriangleIndex >> (31 - MAX_NUM_PARTS_IN_BITS));
  75. }
  76. };
  77. /// btOptimizedBvhNode contains both internal and leaf node information.
  78. /// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
  79. ATTRIBUTE_ALIGNED16(struct)
  80. btOptimizedBvhNode
  81. {
  82. BT_DECLARE_ALIGNED_ALLOCATOR();
  83. //32 bytes
  84. btVector3 m_aabbMinOrg;
  85. btVector3 m_aabbMaxOrg;
  86. //4
  87. int m_escapeIndex;
  88. //8
  89. //for child nodes
  90. int m_subPart;
  91. int m_triangleIndex;
  92. //pad the size to 64 bytes
  93. char m_padding[20];
  94. };
  95. ///btBvhSubtreeInfo provides info to gather a subtree of limited size
  96. ATTRIBUTE_ALIGNED16(class)
  97. btBvhSubtreeInfo
  98. {
  99. public:
  100. BT_DECLARE_ALIGNED_ALLOCATOR();
  101. //12 bytes
  102. unsigned short int m_quantizedAabbMin[3];
  103. unsigned short int m_quantizedAabbMax[3];
  104. //4 bytes, points to the root of the subtree
  105. int m_rootNodeIndex;
  106. //4 bytes
  107. int m_subtreeSize;
  108. int m_padding[3];
  109. btBvhSubtreeInfo()
  110. {
  111. //memset(&m_padding[0], 0, sizeof(m_padding));
  112. }
  113. void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
  114. {
  115. m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
  116. m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
  117. m_quantizedAabbMin[2] = quantizedNode.m_quantizedAabbMin[2];
  118. m_quantizedAabbMax[0] = quantizedNode.m_quantizedAabbMax[0];
  119. m_quantizedAabbMax[1] = quantizedNode.m_quantizedAabbMax[1];
  120. m_quantizedAabbMax[2] = quantizedNode.m_quantizedAabbMax[2];
  121. }
  122. };
  123. class btNodeOverlapCallback
  124. {
  125. public:
  126. virtual ~btNodeOverlapCallback(){};
  127. virtual void processNode(int subPart, int triangleIndex) = 0;
  128. };
  129. #include "LinearMath/btAlignedAllocator.h"
  130. #include "LinearMath/btAlignedObjectArray.h"
  131. ///for code readability:
  132. typedef btAlignedObjectArray<btOptimizedBvhNode> NodeArray;
  133. typedef btAlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
  134. typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
  135. ///The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
  136. ///It is used by the btBvhTriangleMeshShape as midphase.
  137. ///It is recommended to use quantization for better performance and lower memory requirements.
  138. ATTRIBUTE_ALIGNED16(class)
  139. btQuantizedBvh
  140. {
  141. public:
  142. enum btTraversalMode
  143. {
  144. TRAVERSAL_STACKLESS = 0,
  145. TRAVERSAL_STACKLESS_CACHE_FRIENDLY,
  146. TRAVERSAL_RECURSIVE
  147. };
  148. protected:
  149. btVector3 m_bvhAabbMin;
  150. btVector3 m_bvhAabbMax;
  151. btVector3 m_bvhQuantization;
  152. int m_bulletVersion; //for serialization versioning. It could also be used to detect endianess.
  153. int m_curNodeIndex;
  154. //quantization data
  155. bool m_useQuantization;
  156. NodeArray m_leafNodes;
  157. NodeArray m_contiguousNodes;
  158. QuantizedNodeArray m_quantizedLeafNodes;
  159. QuantizedNodeArray m_quantizedContiguousNodes;
  160. btTraversalMode m_traversalMode;
  161. BvhSubtreeInfoArray m_SubtreeHeaders;
  162. //This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray
  163. mutable int m_subtreeHeaderCount;
  164. ///two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!)
  165. ///this might be refactored into a virtual, it is usually not calculated at run-time
  166. void setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin)
  167. {
  168. if (m_useQuantization)
  169. {
  170. quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0], aabbMin, 0);
  171. }
  172. else
  173. {
  174. m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin;
  175. }
  176. }
  177. void setInternalNodeAabbMax(int nodeIndex, const btVector3& aabbMax)
  178. {
  179. if (m_useQuantization)
  180. {
  181. quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0], aabbMax, 1);
  182. }
  183. else
  184. {
  185. m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax;
  186. }
  187. }
  188. btVector3 getAabbMin(int nodeIndex) const
  189. {
  190. if (m_useQuantization)
  191. {
  192. return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMin[0]);
  193. }
  194. //non-quantized
  195. return m_leafNodes[nodeIndex].m_aabbMinOrg;
  196. }
  197. btVector3 getAabbMax(int nodeIndex) const
  198. {
  199. if (m_useQuantization)
  200. {
  201. return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMax[0]);
  202. }
  203. //non-quantized
  204. return m_leafNodes[nodeIndex].m_aabbMaxOrg;
  205. }
  206. void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
  207. {
  208. if (m_useQuantization)
  209. {
  210. m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = -escapeIndex;
  211. }
  212. else
  213. {
  214. m_contiguousNodes[nodeIndex].m_escapeIndex = escapeIndex;
  215. }
  216. }
  217. void mergeInternalNodeAabb(int nodeIndex, const btVector3& newAabbMin, const btVector3& newAabbMax)
  218. {
  219. if (m_useQuantization)
  220. {
  221. unsigned short int quantizedAabbMin[3];
  222. unsigned short int quantizedAabbMax[3];
  223. quantize(quantizedAabbMin, newAabbMin, 0);
  224. quantize(quantizedAabbMax, newAabbMax, 1);
  225. for (int i = 0; i < 3; i++)
  226. {
  227. if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i])
  228. m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] = quantizedAabbMin[i];
  229. if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] < quantizedAabbMax[i])
  230. m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] = quantizedAabbMax[i];
  231. }
  232. }
  233. else
  234. {
  235. //non-quantized
  236. m_contiguousNodes[nodeIndex].m_aabbMinOrg.setMin(newAabbMin);
  237. m_contiguousNodes[nodeIndex].m_aabbMaxOrg.setMax(newAabbMax);
  238. }
  239. }
  240. void swapLeafNodes(int firstIndex, int secondIndex);
  241. void assignInternalNodeFromLeafNode(int internalNode, int leafNodeIndex);
  242. protected:
  243. void buildTree(int startIndex, int endIndex);
  244. int calcSplittingAxis(int startIndex, int endIndex);
  245. int sortAndCalcSplittingIndex(int startIndex, int endIndex, int splitAxis);
  246. void walkStacklessTree(btNodeOverlapCallback * nodeCallback, const btVector3& aabbMin, const btVector3& aabbMax) const;
  247. void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex, int endNodeIndex) const;
  248. void walkStacklessQuantizedTree(btNodeOverlapCallback * nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax, int startNodeIndex, int endNodeIndex) const;
  249. void walkStacklessTreeAgainstRay(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex, int endNodeIndex) const;
  250. ///tree traversal designed for small-memory processors like PS3 SPU
  251. void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback * nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax) const;
  252. ///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
  253. void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode, btNodeOverlapCallback* nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax) const;
  254. ///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
  255. void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA, const btQuantizedBvhNode* treeNodeB, btNodeOverlapCallback* nodeCallback) const;
  256. void updateSubtreeHeaders(int leftChildNodexIndex, int rightChildNodexIndex);
  257. public:
  258. BT_DECLARE_ALIGNED_ALLOCATOR();
  259. btQuantizedBvh();
  260. virtual ~btQuantizedBvh();
  261. ///***************************************** expert/internal use only *************************
  262. void setQuantizationValues(const btVector3& bvhAabbMin, const btVector3& bvhAabbMax, btScalar quantizationMargin = btScalar(1.0));
  263. QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; }
  264. ///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized
  265. void buildInternal();
  266. ///***************************************** expert/internal use only *************************
  267. void reportAabbOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& aabbMin, const btVector3& aabbMax) const;
  268. void reportRayOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
  269. void reportBoxCastOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax) const;
  270. SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point, int isMax) const
  271. {
  272. btAssert(m_useQuantization);
  273. btAssert(point.getX() <= m_bvhAabbMax.getX());
  274. btAssert(point.getY() <= m_bvhAabbMax.getY());
  275. btAssert(point.getZ() <= m_bvhAabbMax.getZ());
  276. btAssert(point.getX() >= m_bvhAabbMin.getX());
  277. btAssert(point.getY() >= m_bvhAabbMin.getY());
  278. btAssert(point.getZ() >= m_bvhAabbMin.getZ());
  279. btVector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
  280. ///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative
  281. ///end-points always set the first bit, so that they are sorted properly (so that neighbouring AABBs overlap properly)
  282. ///@todo: double-check this
  283. if (isMax)
  284. {
  285. out[0] = (unsigned short)(((unsigned short)(v.getX() + btScalar(1.)) | 1));
  286. out[1] = (unsigned short)(((unsigned short)(v.getY() + btScalar(1.)) | 1));
  287. out[2] = (unsigned short)(((unsigned short)(v.getZ() + btScalar(1.)) | 1));
  288. }
  289. else
  290. {
  291. out[0] = (unsigned short)(((unsigned short)(v.getX()) & 0xfffe));
  292. out[1] = (unsigned short)(((unsigned short)(v.getY()) & 0xfffe));
  293. out[2] = (unsigned short)(((unsigned short)(v.getZ()) & 0xfffe));
  294. }
  295. #ifdef DEBUG_CHECK_DEQUANTIZATION
  296. btVector3 newPoint = unQuantize(out);
  297. if (isMax)
  298. {
  299. if (newPoint.getX() < point.getX())
  300. {
  301. printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() - point.getX(), newPoint.getX(), point.getX());
  302. }
  303. if (newPoint.getY() < point.getY())
  304. {
  305. printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() - point.getY(), newPoint.getY(), point.getY());
  306. }
  307. if (newPoint.getZ() < point.getZ())
  308. {
  309. printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() - point.getZ(), newPoint.getZ(), point.getZ());
  310. }
  311. }
  312. else
  313. {
  314. if (newPoint.getX() > point.getX())
  315. {
  316. printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() - point.getX(), newPoint.getX(), point.getX());
  317. }
  318. if (newPoint.getY() > point.getY())
  319. {
  320. printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() - point.getY(), newPoint.getY(), point.getY());
  321. }
  322. if (newPoint.getZ() > point.getZ())
  323. {
  324. printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() - point.getZ(), newPoint.getZ(), point.getZ());
  325. }
  326. }
  327. #endif //DEBUG_CHECK_DEQUANTIZATION
  328. }
  329. SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2, int isMax) const
  330. {
  331. btAssert(m_useQuantization);
  332. btVector3 clampedPoint(point2);
  333. clampedPoint.setMax(m_bvhAabbMin);
  334. clampedPoint.setMin(m_bvhAabbMax);
  335. quantize(out, clampedPoint, isMax);
  336. }
  337. SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
  338. {
  339. btVector3 vecOut;
  340. vecOut.setValue(
  341. (btScalar)(vecIn[0]) / (m_bvhQuantization.getX()),
  342. (btScalar)(vecIn[1]) / (m_bvhQuantization.getY()),
  343. (btScalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
  344. vecOut += m_bvhAabbMin;
  345. return vecOut;
  346. }
  347. ///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
  348. void setTraversalMode(btTraversalMode traversalMode)
  349. {
  350. m_traversalMode = traversalMode;
  351. }
  352. SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
  353. {
  354. return m_quantizedContiguousNodes;
  355. }
  356. SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
  357. {
  358. return m_SubtreeHeaders;
  359. }
  360. ////////////////////////////////////////////////////////////////////
  361. /////Calculate space needed to store BVH for serialization
  362. unsigned calculateSerializeBufferSize() const;
  363. /// Data buffer MUST be 16 byte aligned
  364. virtual bool serialize(void* o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const;
  365. ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
  366. static btQuantizedBvh* deSerializeInPlace(void* i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian);
  367. static unsigned int getAlignmentSerializationPadding();
  368. //////////////////////////////////////////////////////////////////////
  369. virtual int calculateSerializeBufferSizeNew() const;
  370. ///fills the dataBuffer and returns the struct name (and 0 on failure)
  371. virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
  372. virtual void deSerializeFloat(struct btQuantizedBvhFloatData & quantizedBvhFloatData);
  373. virtual void deSerializeDouble(struct btQuantizedBvhDoubleData & quantizedBvhDoubleData);
  374. ////////////////////////////////////////////////////////////////////
  375. SIMD_FORCE_INLINE bool isQuantized()
  376. {
  377. return m_useQuantization;
  378. }
  379. private:
  380. // Special "copy" constructor that allows for in-place deserialization
  381. // Prevents btVector3's default constructor from being called, but doesn't inialize much else
  382. // ownsMemory should most likely be false if deserializing, and if you are not, don't call this (it also changes the function signature, which we need)
  383. btQuantizedBvh(btQuantizedBvh & other, bool ownsMemory);
  384. };
  385. // clang-format off
  386. // parser needs * with the name
  387. struct btBvhSubtreeInfoData
  388. {
  389. int m_rootNodeIndex;
  390. int m_subtreeSize;
  391. unsigned short m_quantizedAabbMin[3];
  392. unsigned short m_quantizedAabbMax[3];
  393. };
  394. struct btOptimizedBvhNodeFloatData
  395. {
  396. btVector3FloatData m_aabbMinOrg;
  397. btVector3FloatData m_aabbMaxOrg;
  398. int m_escapeIndex;
  399. int m_subPart;
  400. int m_triangleIndex;
  401. char m_pad[4];
  402. };
  403. struct btOptimizedBvhNodeDoubleData
  404. {
  405. btVector3DoubleData m_aabbMinOrg;
  406. btVector3DoubleData m_aabbMaxOrg;
  407. int m_escapeIndex;
  408. int m_subPart;
  409. int m_triangleIndex;
  410. char m_pad[4];
  411. };
  412. struct btQuantizedBvhNodeData
  413. {
  414. unsigned short m_quantizedAabbMin[3];
  415. unsigned short m_quantizedAabbMax[3];
  416. int m_escapeIndexOrTriangleIndex;
  417. };
  418. struct btQuantizedBvhFloatData
  419. {
  420. btVector3FloatData m_bvhAabbMin;
  421. btVector3FloatData m_bvhAabbMax;
  422. btVector3FloatData m_bvhQuantization;
  423. int m_curNodeIndex;
  424. int m_useQuantization;
  425. int m_numContiguousLeafNodes;
  426. int m_numQuantizedContiguousNodes;
  427. btOptimizedBvhNodeFloatData *m_contiguousNodesPtr;
  428. btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
  429. btBvhSubtreeInfoData *m_subTreeInfoPtr;
  430. int m_traversalMode;
  431. int m_numSubtreeHeaders;
  432. };
  433. struct btQuantizedBvhDoubleData
  434. {
  435. btVector3DoubleData m_bvhAabbMin;
  436. btVector3DoubleData m_bvhAabbMax;
  437. btVector3DoubleData m_bvhQuantization;
  438. int m_curNodeIndex;
  439. int m_useQuantization;
  440. int m_numContiguousLeafNodes;
  441. int m_numQuantizedContiguousNodes;
  442. btOptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
  443. btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
  444. int m_traversalMode;
  445. int m_numSubtreeHeaders;
  446. btBvhSubtreeInfoData *m_subTreeInfoPtr;
  447. };
  448. // clang-format on
  449. SIMD_FORCE_INLINE int btQuantizedBvh::calculateSerializeBufferSizeNew() const
  450. {
  451. return sizeof(btQuantizedBvhData);
  452. }
  453. #endif //BT_QUANTIZED_BVH_H