b3QuantizedBvh.h 17 KB

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