bvh_debug.inc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. public:
  2. #ifdef BVH_VERBOSE
  3. void _debug_recursive_print_tree(int p_tree_id) const {
  4. if (_root_node_id[p_tree_id] != BVHCommon::INVALID)
  5. _debug_recursive_print_tree_node(_root_node_id[p_tree_id]);
  6. }
  7. String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
  8. POINT size = aabb.calculate_size();
  9. String sz;
  10. float vol = 0.0;
  11. for (int i = 0; i < POINT::AXIS_COUNT; ++i) {
  12. sz += "(";
  13. sz += itos(aabb.min[i]);
  14. sz += " ~ ";
  15. sz += itos(-aabb.neg_max[i]);
  16. sz += ") ";
  17. vol += size[i];
  18. }
  19. sz += "vol " + itos(vol);
  20. return sz;
  21. }
  22. void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const {
  23. const TNode &tnode = _nodes[p_node_id];
  24. String sz = "";
  25. for (int n = 0; n < depth; n++) {
  26. sz += "\t";
  27. }
  28. sz += itos(p_node_id);
  29. if (tnode.is_leaf()) {
  30. sz += " L";
  31. sz += itos(tnode.height) + " ";
  32. const TLeaf &leaf = _node_get_leaf(tnode);
  33. sz += "[";
  34. for (int n = 0; n < leaf.num_items; n++) {
  35. if (n)
  36. sz += ", ";
  37. sz += "r";
  38. sz += itos(leaf.get_item_ref_id(n));
  39. }
  40. sz += "] ";
  41. } else {
  42. sz += " N";
  43. sz += itos(tnode.height) + " ";
  44. }
  45. sz += _debug_aabb_to_string(tnode.aabb);
  46. print_line(sz);
  47. if (!tnode.is_leaf()) {
  48. for (int n = 0; n < tnode.num_children; n++) {
  49. _debug_recursive_print_tree_node(tnode.children[n], depth + 1);
  50. }
  51. }
  52. }
  53. #endif