2020-10-21 14:13:20 +02:00
|
|
|
public:
|
|
|
|
#ifdef BVH_VERBOSE
|
|
|
|
void _debug_recursive_print_tree(int p_tree_id) const {
|
|
|
|
if (_root_node_id[p_tree_id] != BVHCommon::INVALID)
|
|
|
|
_debug_recursive_print_tree_node(_root_node_id[p_tree_id]);
|
|
|
|
}
|
|
|
|
|
2021-04-27 22:56:23 +02:00
|
|
|
String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
|
2020-10-21 14:13:20 +02:00
|
|
|
String sz = "(";
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(aabb.min.x);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += " ~ ";
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(-aabb.neg_max.x);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += ") (";
|
|
|
|
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(aabb.min.y);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += " ~ ";
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(-aabb.neg_max.y);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += ") (";
|
|
|
|
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(aabb.min.z);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += " ~ ";
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(-aabb.neg_max.z);
|
2020-10-21 14:13:20 +02:00
|
|
|
sz += ") ";
|
|
|
|
|
|
|
|
Vector3 size = aabb.calculate_size();
|
|
|
|
float vol = size.x * size.y * size.z;
|
|
|
|
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];
|
|
|
|
|
|
|
|
String sz = "";
|
|
|
|
for (int n = 0; n < depth; n++) {
|
|
|
|
sz += "\t";
|
|
|
|
}
|
|
|
|
sz += itos(p_node_id);
|
|
|
|
|
|
|
|
if (tnode.is_leaf()) {
|
|
|
|
sz += " L";
|
|
|
|
sz += itos(tnode.height) + " ";
|
2021-01-14 13:56:28 +01:00
|
|
|
const TLeaf &leaf = _node_get_leaf(tnode);
|
2020-10-21 14:13:20 +02:00
|
|
|
|
|
|
|
sz += "[";
|
2021-01-14 13:56:28 +01:00
|
|
|
for (int n = 0; n < leaf.num_items; n++) {
|
2020-10-21 14:13:20 +02:00
|
|
|
if (n)
|
|
|
|
sz += ", ";
|
|
|
|
sz += "r";
|
2021-01-14 13:56:28 +01:00
|
|
|
sz += itos(leaf.get_item_ref_id(n));
|
2020-10-21 14:13:20 +02:00
|
|
|
}
|
|
|
|
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
|