bvh_debug.inc 1.3 KB

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