File: bvh_debug.inc

package info (click to toggle)
godot 3.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 270,588 kB
  • sloc: cpp: 971,579; ansic: 617,953; xml: 80,302; asm: 17,498; cs: 14,559; python: 11,744; java: 9,681; javascript: 4,654; pascal: 1,176; sh: 896; objc: 529; makefile: 176
file content (65 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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]);
}

String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
	POINT size = aabb.calculate_size();

	String sz;
	float vol = 0.0;

	for (int i = 0; i < POINT::AXIS_COUNT; ++i) {
		sz += "(";
		sz += itos(aabb.min[i]);
		sz += " ~ ";
		sz += itos(-aabb.neg_max[i]);
		sz += ") ";

		vol += size[i];
	}

	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) + " ";
		const TLeaf &leaf = _node_get_leaf(tnode);

		sz += "[";
		for (int n = 0; n < leaf.num_items; n++) {
			if (n)
				sz += ", ";
			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