bvh_debug.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 = String("\t").repeat(depth) + itos(p_node_id);
  26. if (tnode.is_leaf()) {
  27. sz += " L";
  28. sz += itos(tnode.height) + " ";
  29. const TLeaf &leaf = _node_get_leaf(tnode);
  30. sz += "[";
  31. for (int n = 0; n < leaf.num_items; n++) {
  32. if (n) {
  33. sz += ", ";
  34. }
  35. sz += "r";
  36. sz += itos(leaf.get_item_ref_id(n));
  37. }
  38. sz += "] ";
  39. } else {
  40. sz += " N";
  41. sz += itos(tnode.height) + " ";
  42. }
  43. sz += _debug_aabb_to_string(tnode.aabb);
  44. print_line(sz);
  45. if (!tnode.is_leaf()) {
  46. for (int n = 0; n < tnode.num_children; n++) {
  47. _debug_recursive_print_tree_node(tnode.children[n], depth + 1);
  48. }
  49. }
  50. }
  51. #endif