bvh_misc.inc 1.1 KB

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