gim_box_set.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. #ifndef GIM_BOX_SET_H_INCLUDED
  2. #define GIM_BOX_SET_H_INCLUDED
  3. /*! \file gim_box_set.h
  4. \author Francisco Leon Najera
  5. */
  6. /*
  7. -----------------------------------------------------------------------------
  8. This source file is part of GIMPACT Library.
  9. For the latest info, see http://gimpact.sourceforge.net/
  10. Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
  11. email: projectileman@yahoo.com
  12. This library is free software; you can redistribute it and/or
  13. modify it under the terms of EITHER:
  14. (1) The GNU Lesser General Public License as published by the Free
  15. Software Foundation; either version 2.1 of the License, or (at
  16. your option) any later version. The text of the GNU Lesser
  17. General Public License is included with this library in the
  18. file GIMPACT-LICENSE-LGPL.TXT.
  19. (2) The BSD-style license that is included with this library in
  20. the file GIMPACT-LICENSE-BSD.TXT.
  21. (3) The zlib/libpng license that is included with this library in
  22. the file GIMPACT-LICENSE-ZLIB.TXT.
  23. This library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
  26. GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
  27. -----------------------------------------------------------------------------
  28. */
  29. #include "gim_array.h"
  30. #include "gim_radixsort.h"
  31. #include "gim_box_collision.h"
  32. #include "gim_tri_collision.h"
  33. //! Overlapping pair
  34. struct GIM_PAIR
  35. {
  36. GUINT m_index1;
  37. GUINT m_index2;
  38. GIM_PAIR()
  39. {}
  40. GIM_PAIR(const GIM_PAIR & p)
  41. {
  42. m_index1 = p.m_index1;
  43. m_index2 = p.m_index2;
  44. }
  45. GIM_PAIR(GUINT index1, GUINT index2)
  46. {
  47. m_index1 = index1;
  48. m_index2 = index2;
  49. }
  50. };
  51. //! A pairset array
  52. class gim_pair_set: public gim_array<GIM_PAIR>
  53. {
  54. public:
  55. gim_pair_set():gim_array<GIM_PAIR>(32)
  56. {
  57. }
  58. inline void push_pair(GUINT index1,GUINT index2)
  59. {
  60. push_back(GIM_PAIR(index1,index2));
  61. }
  62. inline void push_pair_inv(GUINT index1,GUINT index2)
  63. {
  64. push_back(GIM_PAIR(index2,index1));
  65. }
  66. };
  67. //! Prototype Base class for primitive classification
  68. /*!
  69. This class is a wrapper for primitive collections.
  70. This tells relevant info for the Bounding Box set classes, which take care of space classification.
  71. This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for getting optimal results and less Per Box compairisons.
  72. */
  73. class GIM_PRIMITIVE_MANAGER_PROTOTYPE
  74. {
  75. public:
  76. virtual ~GIM_PRIMITIVE_MANAGER_PROTOTYPE() {}
  77. //! determines if this manager consist on only triangles, which special case will be optimized
  78. virtual bool is_trimesh() = 0;
  79. virtual GUINT get_primitive_count() = 0;
  80. virtual void get_primitive_box(GUINT prim_index ,GIM_AABB & primbox) = 0;
  81. virtual void get_primitive_triangle(GUINT prim_index,GIM_TRIANGLE & triangle) = 0;
  82. };
  83. struct GIM_AABB_DATA
  84. {
  85. GIM_AABB m_bound;
  86. GUINT m_data;
  87. };
  88. //! Node Structure for trees
  89. struct GIM_BOX_TREE_NODE
  90. {
  91. GIM_AABB m_bound;
  92. GUINT m_left;//!< Left subtree
  93. GUINT m_right;//!< Right subtree
  94. GUINT m_escapeIndex;//!< Scape index for traversing
  95. GUINT m_data;//!< primitive index if apply
  96. GIM_BOX_TREE_NODE()
  97. {
  98. m_left = 0;
  99. m_right = 0;
  100. m_escapeIndex = 0;
  101. m_data = 0;
  102. }
  103. SIMD_FORCE_INLINE bool is_leaf_node() const
  104. {
  105. return (!m_left && !m_right);
  106. }
  107. };
  108. //! Basic Box tree structure
  109. class GIM_BOX_TREE
  110. {
  111. protected:
  112. GUINT m_num_nodes;
  113. gim_array<GIM_BOX_TREE_NODE> m_node_array;
  114. protected:
  115. GUINT _sort_and_calc_splitting_index(
  116. gim_array<GIM_AABB_DATA> & primitive_boxes,
  117. GUINT startIndex, GUINT endIndex, GUINT splitAxis);
  118. GUINT _calc_splitting_axis(gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex, GUINT endIndex);
  119. void _build_sub_tree(gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex, GUINT endIndex);
  120. public:
  121. GIM_BOX_TREE()
  122. {
  123. m_num_nodes = 0;
  124. }
  125. //! prototype functions for box tree management
  126. //!@{
  127. void build_tree(gim_array<GIM_AABB_DATA> & primitive_boxes);
  128. SIMD_FORCE_INLINE void clearNodes()
  129. {
  130. m_node_array.clear();
  131. m_num_nodes = 0;
  132. }
  133. //! node count
  134. SIMD_FORCE_INLINE GUINT getNodeCount() const
  135. {
  136. return m_num_nodes;
  137. }
  138. //! tells if the node is a leaf
  139. SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
  140. {
  141. return m_node_array[nodeindex].is_leaf_node();
  142. }
  143. SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
  144. {
  145. return m_node_array[nodeindex].m_data;
  146. }
  147. SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound) const
  148. {
  149. bound = m_node_array[nodeindex].m_bound;
  150. }
  151. SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound)
  152. {
  153. m_node_array[nodeindex].m_bound = bound;
  154. }
  155. SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const
  156. {
  157. return m_node_array[nodeindex].m_left;
  158. }
  159. SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const
  160. {
  161. return m_node_array[nodeindex].m_right;
  162. }
  163. SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
  164. {
  165. return m_node_array[nodeindex].m_escapeIndex;
  166. }
  167. //!@}
  168. };
  169. //! Generic Box Tree Template
  170. /*!
  171. This class offers an structure for managing a box tree of primitives.
  172. Requires a Primitive prototype (like GIM_PRIMITIVE_MANAGER_PROTOTYPE ) and
  173. a Box tree structure ( like GIM_BOX_TREE).
  174. */
  175. template<typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE, typename _GIM_BOX_TREE_PROTOTYPE>
  176. class GIM_BOX_TREE_TEMPLATE_SET
  177. {
  178. protected:
  179. _GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager;
  180. _GIM_BOX_TREE_PROTOTYPE m_box_tree;
  181. protected:
  182. //stackless refit
  183. SIMD_FORCE_INLINE void refit()
  184. {
  185. GUINT nodecount = getNodeCount();
  186. while(nodecount--)
  187. {
  188. if(isLeafNode(nodecount))
  189. {
  190. GIM_AABB leafbox;
  191. m_primitive_manager.get_primitive_box(getNodeData(nodecount),leafbox);
  192. setNodeBound(nodecount,leafbox);
  193. }
  194. else
  195. {
  196. //get left bound
  197. GUINT childindex = getLeftNodeIndex(nodecount);
  198. GIM_AABB bound;
  199. getNodeBound(childindex,bound);
  200. //get right bound
  201. childindex = getRightNodeIndex(nodecount);
  202. GIM_AABB bound2;
  203. getNodeBound(childindex,bound2);
  204. bound.merge(bound2);
  205. setNodeBound(nodecount,bound);
  206. }
  207. }
  208. }
  209. public:
  210. GIM_BOX_TREE_TEMPLATE_SET()
  211. {
  212. }
  213. SIMD_FORCE_INLINE GIM_AABB getGlobalBox() const
  214. {
  215. GIM_AABB totalbox;
  216. getNodeBound(0, totalbox);
  217. return totalbox;
  218. }
  219. SIMD_FORCE_INLINE void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & primitive_manager)
  220. {
  221. m_primitive_manager = primitive_manager;
  222. }
  223. const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
  224. {
  225. return m_primitive_manager;
  226. }
  227. _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
  228. {
  229. return m_primitive_manager;
  230. }
  231. //! node manager prototype functions
  232. ///@{
  233. //! this attemps to refit the box set.
  234. SIMD_FORCE_INLINE void update()
  235. {
  236. refit();
  237. }
  238. //! this rebuild the entire set
  239. SIMD_FORCE_INLINE void buildSet()
  240. {
  241. //obtain primitive boxes
  242. gim_array<GIM_AABB_DATA> primitive_boxes;
  243. primitive_boxes.resize(m_primitive_manager.get_primitive_count(),false);
  244. for (GUINT i = 0;i<primitive_boxes.size() ;i++ )
  245. {
  246. m_primitive_manager.get_primitive_box(i,primitive_boxes[i].m_bound);
  247. primitive_boxes[i].m_data = i;
  248. }
  249. m_box_tree.build_tree(primitive_boxes);
  250. }
  251. //! returns the indices of the primitives in the m_primitive_manager
  252. SIMD_FORCE_INLINE bool boxQuery(const GIM_AABB & box, gim_array<GUINT> & collided_results) const
  253. {
  254. GUINT curIndex = 0;
  255. GUINT numNodes = getNodeCount();
  256. while (curIndex < numNodes)
  257. {
  258. GIM_AABB bound;
  259. getNodeBound(curIndex,bound);
  260. //catch bugs in tree data
  261. bool aabbOverlap = bound.has_collision(box);
  262. bool isleafnode = isLeafNode(curIndex);
  263. if (isleafnode && aabbOverlap)
  264. {
  265. collided_results.push_back(getNodeData(curIndex));
  266. }
  267. if (aabbOverlap || isleafnode)
  268. {
  269. //next subnode
  270. curIndex++;
  271. }
  272. else
  273. {
  274. //skip node
  275. curIndex+= getScapeNodeIndex(curIndex);
  276. }
  277. }
  278. if(collided_results.size()>0) return true;
  279. return false;
  280. }
  281. //! returns the indices of the primitives in the m_primitive_manager
  282. SIMD_FORCE_INLINE bool boxQueryTrans(const GIM_AABB & box,
  283. const btTransform & transform, gim_array<GUINT> & collided_results) const
  284. {
  285. GIM_AABB transbox=box;
  286. transbox.appy_transform(transform);
  287. return boxQuery(transbox,collided_results);
  288. }
  289. //! returns the indices of the primitives in the m_primitive_manager
  290. SIMD_FORCE_INLINE bool rayQuery(
  291. const btVector3 & ray_dir,const btVector3 & ray_origin ,
  292. gim_array<GUINT> & collided_results) const
  293. {
  294. GUINT curIndex = 0;
  295. GUINT numNodes = getNodeCount();
  296. while (curIndex < numNodes)
  297. {
  298. GIM_AABB bound;
  299. getNodeBound(curIndex,bound);
  300. //catch bugs in tree data
  301. bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir);
  302. bool isleafnode = isLeafNode(curIndex);
  303. if (isleafnode && aabbOverlap)
  304. {
  305. collided_results.push_back(getNodeData( curIndex));
  306. }
  307. if (aabbOverlap || isleafnode)
  308. {
  309. //next subnode
  310. curIndex++;
  311. }
  312. else
  313. {
  314. //skip node
  315. curIndex+= getScapeNodeIndex(curIndex);
  316. }
  317. }
  318. if(collided_results.size()>0) return true;
  319. return false;
  320. }
  321. //! tells if this set has hierarcht
  322. SIMD_FORCE_INLINE bool hasHierarchy() const
  323. {
  324. return true;
  325. }
  326. //! tells if this set is a trimesh
  327. SIMD_FORCE_INLINE bool isTrimesh() const
  328. {
  329. return m_primitive_manager.is_trimesh();
  330. }
  331. //! node count
  332. SIMD_FORCE_INLINE GUINT getNodeCount() const
  333. {
  334. return m_box_tree.getNodeCount();
  335. }
  336. //! tells if the node is a leaf
  337. SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
  338. {
  339. return m_box_tree.isLeafNode(nodeindex);
  340. }
  341. SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
  342. {
  343. return m_box_tree.getNodeData(nodeindex);
  344. }
  345. SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound) const
  346. {
  347. m_box_tree.getNodeBound(nodeindex, bound);
  348. }
  349. SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound)
  350. {
  351. m_box_tree.setNodeBound(nodeindex, bound);
  352. }
  353. SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const
  354. {
  355. return m_box_tree.getLeftNodeIndex(nodeindex);
  356. }
  357. SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const
  358. {
  359. return m_box_tree.getRightNodeIndex(nodeindex);
  360. }
  361. SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
  362. {
  363. return m_box_tree.getScapeNodeIndex(nodeindex);
  364. }
  365. SIMD_FORCE_INLINE void getNodeTriangle(GUINT nodeindex,GIM_TRIANGLE & triangle) const
  366. {
  367. m_primitive_manager.get_primitive_triangle(getNodeData(nodeindex),triangle);
  368. }
  369. };
  370. //! Class for Box Tree Sets
  371. /*!
  372. this has the GIM_BOX_TREE implementation for bounding boxes.
  373. */
  374. template<typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
  375. class GIM_BOX_TREE_SET: public GIM_BOX_TREE_TEMPLATE_SET< _GIM_PRIMITIVE_MANAGER_PROTOTYPE, GIM_BOX_TREE>
  376. {
  377. public:
  378. };
  379. /// GIM_BOX_SET collision methods
  380. template<typename BOX_SET_CLASS0,typename BOX_SET_CLASS1>
  381. class GIM_TREE_TREE_COLLIDER
  382. {
  383. public:
  384. gim_pair_set * m_collision_pairs;
  385. BOX_SET_CLASS0 * m_boxset0;
  386. BOX_SET_CLASS1 * m_boxset1;
  387. GUINT current_node0;
  388. GUINT current_node1;
  389. bool node0_is_leaf;
  390. bool node1_is_leaf;
  391. bool t0_is_trimesh;
  392. bool t1_is_trimesh;
  393. bool node0_has_triangle;
  394. bool node1_has_triangle;
  395. GIM_AABB m_box0;
  396. GIM_AABB m_box1;
  397. GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0;
  398. btTransform trans_cache_0to1;
  399. GIM_TRIANGLE m_tri0;
  400. btVector4 m_tri0_plane;
  401. GIM_TRIANGLE m_tri1;
  402. btVector4 m_tri1_plane;
  403. public:
  404. GIM_TREE_TREE_COLLIDER()
  405. {
  406. current_node0 = G_UINT_INFINITY;
  407. current_node1 = G_UINT_INFINITY;
  408. }
  409. protected:
  410. SIMD_FORCE_INLINE void retrieve_node0_triangle(GUINT node0)
  411. {
  412. if(node0_has_triangle) return;
  413. m_boxset0->getNodeTriangle(node0,m_tri0);
  414. //transform triangle
  415. m_tri0.m_vertices[0] = trans_cache_0to1(m_tri0.m_vertices[0]);
  416. m_tri0.m_vertices[1] = trans_cache_0to1(m_tri0.m_vertices[1]);
  417. m_tri0.m_vertices[2] = trans_cache_0to1(m_tri0.m_vertices[2]);
  418. m_tri0.get_plane(m_tri0_plane);
  419. node0_has_triangle = true;
  420. }
  421. SIMD_FORCE_INLINE void retrieve_node1_triangle(GUINT node1)
  422. {
  423. if(node1_has_triangle) return;
  424. m_boxset1->getNodeTriangle(node1,m_tri1);
  425. //transform triangle
  426. m_tri1.m_vertices[0] = trans_cache_1to0.transform(m_tri1.m_vertices[0]);
  427. m_tri1.m_vertices[1] = trans_cache_1to0.transform(m_tri1.m_vertices[1]);
  428. m_tri1.m_vertices[2] = trans_cache_1to0.transform(m_tri1.m_vertices[2]);
  429. m_tri1.get_plane(m_tri1_plane);
  430. node1_has_triangle = true;
  431. }
  432. SIMD_FORCE_INLINE void retrieve_node0_info(GUINT node0)
  433. {
  434. if(node0 == current_node0) return;
  435. m_boxset0->getNodeBound(node0,m_box0);
  436. node0_is_leaf = m_boxset0->isLeafNode(node0);
  437. node0_has_triangle = false;
  438. current_node0 = node0;
  439. }
  440. SIMD_FORCE_INLINE void retrieve_node1_info(GUINT node1)
  441. {
  442. if(node1 == current_node1) return;
  443. m_boxset1->getNodeBound(node1,m_box1);
  444. node1_is_leaf = m_boxset1->isLeafNode(node1);
  445. node1_has_triangle = false;
  446. current_node1 = node1;
  447. }
  448. SIMD_FORCE_INLINE bool node_collision(GUINT node0 ,GUINT node1)
  449. {
  450. retrieve_node0_info(node0);
  451. retrieve_node1_info(node1);
  452. bool result = m_box0.overlapping_trans_cache(m_box1,trans_cache_1to0,true);
  453. if(!result) return false;
  454. if(t0_is_trimesh && node0_is_leaf)
  455. {
  456. //perform primitive vs box collision
  457. retrieve_node0_triangle(node0);
  458. //do triangle vs box collision
  459. m_box1.increment_margin(m_tri0.m_margin);
  460. result = m_box1.collide_triangle_exact(
  461. m_tri0.m_vertices[0],m_tri0.m_vertices[1],m_tri0.m_vertices[2],m_tri0_plane);
  462. m_box1.increment_margin(-m_tri0.m_margin);
  463. if(!result) return false;
  464. return true;
  465. }
  466. else if(t1_is_trimesh && node1_is_leaf)
  467. {
  468. //perform primitive vs box collision
  469. retrieve_node1_triangle(node1);
  470. //do triangle vs box collision
  471. m_box0.increment_margin(m_tri1.m_margin);
  472. result = m_box0.collide_triangle_exact(
  473. m_tri1.m_vertices[0],m_tri1.m_vertices[1],m_tri1.m_vertices[2],m_tri1_plane);
  474. m_box0.increment_margin(-m_tri1.m_margin);
  475. if(!result) return false;
  476. return true;
  477. }
  478. return true;
  479. }
  480. //stackless collision routine
  481. void find_collision_pairs()
  482. {
  483. gim_pair_set stack_collisions;
  484. stack_collisions.reserve(32);
  485. //add the first pair
  486. stack_collisions.push_pair(0,0);
  487. while(stack_collisions.size())
  488. {
  489. //retrieve the last pair and pop
  490. GUINT node0 = stack_collisions.back().m_index1;
  491. GUINT node1 = stack_collisions.back().m_index2;
  492. stack_collisions.pop_back();
  493. if(node_collision(node0,node1)) // a collision is found
  494. {
  495. if(node0_is_leaf)
  496. {
  497. if(node1_is_leaf)
  498. {
  499. m_collision_pairs->push_pair(m_boxset0->getNodeData(node0),m_boxset1->getNodeData(node1));
  500. }
  501. else
  502. {
  503. //collide left
  504. stack_collisions.push_pair(node0,m_boxset1->getLeftNodeIndex(node1));
  505. //collide right
  506. stack_collisions.push_pair(node0,m_boxset1->getRightNodeIndex(node1));
  507. }
  508. }
  509. else
  510. {
  511. if(node1_is_leaf)
  512. {
  513. //collide left
  514. stack_collisions.push_pair(m_boxset0->getLeftNodeIndex(node0),node1);
  515. //collide right
  516. stack_collisions.push_pair(m_boxset0->getRightNodeIndex(node0),node1);
  517. }
  518. else
  519. {
  520. GUINT left0 = m_boxset0->getLeftNodeIndex(node0);
  521. GUINT right0 = m_boxset0->getRightNodeIndex(node0);
  522. GUINT left1 = m_boxset1->getLeftNodeIndex(node1);
  523. GUINT right1 = m_boxset1->getRightNodeIndex(node1);
  524. //collide left
  525. stack_collisions.push_pair(left0,left1);
  526. //collide right
  527. stack_collisions.push_pair(left0,right1);
  528. //collide left
  529. stack_collisions.push_pair(right0,left1);
  530. //collide right
  531. stack_collisions.push_pair(right0,right1);
  532. }// else if node1 is not a leaf
  533. }// else if node0 is not a leaf
  534. }// if(node_collision(node0,node1))
  535. }//while(stack_collisions.size())
  536. }
  537. public:
  538. void find_collision(BOX_SET_CLASS0 * boxset1, const btTransform & trans1,
  539. BOX_SET_CLASS1 * boxset2, const btTransform & trans2,
  540. gim_pair_set & collision_pairs, bool complete_primitive_tests = true)
  541. {
  542. m_collision_pairs = &collision_pairs;
  543. m_boxset0 = boxset1;
  544. m_boxset1 = boxset2;
  545. trans_cache_1to0.calc_from_homogenic(trans1,trans2);
  546. trans_cache_0to1 = trans2.inverse();
  547. trans_cache_0to1 *= trans1;
  548. if(complete_primitive_tests)
  549. {
  550. t0_is_trimesh = boxset1->getPrimitiveManager().is_trimesh();
  551. t1_is_trimesh = boxset2->getPrimitiveManager().is_trimesh();
  552. }
  553. else
  554. {
  555. t0_is_trimesh = false;
  556. t1_is_trimesh = false;
  557. }
  558. find_collision_pairs();
  559. }
  560. };
  561. #endif // GIM_BOXPRUNING_H_INCLUDED