bvh_misc.inc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. int _handle_get_tree_id(BVHHandle p_handle) const {
  2. if (USE_PAIRS) {
  3. int tree = 0;
  4. if (_extra[p_handle.id()].pairable)
  5. tree = 1;
  6. return tree;
  7. }
  8. return 0;
  9. }
  10. public:
  11. void _handle_sort(BVHHandle &p_ha, BVHHandle &p_hb) const {
  12. if (p_ha.id() > p_hb.id()) {
  13. BVHHandle temp = p_hb;
  14. p_hb = p_ha;
  15. p_ha = temp;
  16. }
  17. }
  18. private:
  19. void create_root_node(int p_tree) {
  20. // if there is no root node, create one
  21. if (_root_node_id[p_tree] == BVHCommon::INVALID) {
  22. uint32_t root_node_id;
  23. TNode *node = _nodes.request(root_node_id);
  24. node->clear();
  25. _root_node_id[p_tree] = root_node_id;
  26. // make the root node a leaf
  27. uint32_t leaf_id;
  28. TLeaf *leaf = _leaves.request(leaf_id);
  29. leaf->clear();
  30. node->neg_leaf_id = -(int)leaf_id;
  31. }
  32. }
  33. bool node_is_leaf_full(TNode &tnode) const {
  34. const TLeaf &leaf = _node_get_leaf(tnode);
  35. return leaf.is_full();
  36. }
  37. public:
  38. TLeaf &_node_get_leaf(TNode &tnode) {
  39. BVH_ASSERT(tnode.is_leaf());
  40. return _leaves[tnode.get_leaf_id()];
  41. }
  42. const TLeaf &_node_get_leaf(const TNode &tnode) const {
  43. BVH_ASSERT(tnode.is_leaf());
  44. return _leaves[tnode.get_leaf_id()];
  45. }
  46. private: