2021-05-11 05:43:13 +08:00
|
|
|
public:
|
|
|
|
#ifdef BVH_VERBOSE
|
|
|
|
void _debug_recursive_print_tree(int p_tree_id) const {
|
2022-02-16 20:56:32 +08:00
|
|
|
if (_root_node_id[p_tree_id] != BVHCommon::INVALID) {
|
2021-05-11 05:43:13 +08:00
|
|
|
_debug_recursive_print_tree_node(_root_node_id[p_tree_id]);
|
2022-02-16 20:56:32 +08:00
|
|
|
}
|
2021-05-11 05:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
|
2022-02-05 00:46:10 +08:00
|
|
|
POINT size = aabb.calculate_size();
|
2021-05-11 05:43:13 +08:00
|
|
|
|
2021-09-30 01:32:33 +08:00
|
|
|
String sz;
|
2024-03-30 07:44:12 +08:00
|
|
|
real_t vol = 0.0;
|
2021-05-11 05:43:13 +08:00
|
|
|
|
2022-02-05 00:46:10 +08:00
|
|
|
for (int i = 0; i < POINT::AXIS_COUNT; ++i) {
|
2021-09-30 01:32:33 +08:00
|
|
|
sz += "(";
|
|
|
|
sz += itos(aabb.min[i]);
|
|
|
|
sz += " ~ ";
|
|
|
|
sz += itos(-aabb.neg_max[i]);
|
|
|
|
sz += ") ";
|
|
|
|
|
|
|
|
vol += size[i];
|
|
|
|
}
|
2021-05-11 05:43:13 +08:00
|
|
|
|
|
|
|
sz += "vol " + itos(vol);
|
|
|
|
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const {
|
|
|
|
const TNode &tnode = _nodes[p_node_id];
|
|
|
|
|
2023-01-29 07:52:05 +08:00
|
|
|
String sz = String("\t").repeat(depth) + itos(p_node_id);
|
2021-05-11 05:43:13 +08:00
|
|
|
|
|
|
|
if (tnode.is_leaf()) {
|
|
|
|
sz += " L";
|
|
|
|
sz += itos(tnode.height) + " ";
|
|
|
|
const TLeaf &leaf = _node_get_leaf(tnode);
|
|
|
|
|
|
|
|
sz += "[";
|
|
|
|
for (int n = 0; n < leaf.num_items; n++) {
|
2022-02-16 20:56:32 +08:00
|
|
|
if (n) {
|
2021-05-11 05:43:13 +08:00
|
|
|
sz += ", ";
|
2022-02-16 20:56:32 +08:00
|
|
|
}
|
2021-05-11 05:43:13 +08:00
|
|
|
sz += "r";
|
|
|
|
sz += itos(leaf.get_item_ref_id(n));
|
|
|
|
}
|
|
|
|
sz += "] ";
|
|
|
|
} else {
|
|
|
|
sz += " N";
|
|
|
|
sz += itos(tnode.height) + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
sz += _debug_aabb_to_string(tnode.aabb);
|
|
|
|
print_line(sz);
|
|
|
|
|
|
|
|
if (!tnode.is_leaf()) {
|
|
|
|
for (int n = 0; n < tnode.num_children; n++) {
|
|
|
|
_debug_recursive_print_tree_node(tnode.children[n], depth + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|