diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-12-24 00:20:45 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-24 00:20:45 -0300 |
commit | 3fdf4bfe71311000bf706c16d79b475308a200ac (patch) | |
tree | 9a6cd10023c594aaaa79ab12f65fd19cbfc70db0 /core/math/dynamic_bvh.cpp | |
parent | 169159c8aac5807725594145bf029c0ff7ac8ef1 (diff) | |
parent | 83058597cf02255d7c0359a96f125010f63deff7 (diff) |
Merge pull request #44623 from reduz/rewrite-renderer-indexer
Replace Octree by DynamicBVH in cull code
Diffstat (limited to 'core/math/dynamic_bvh.cpp')
-rw-r--r-- | core/math/dynamic_bvh.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/core/math/dynamic_bvh.cpp b/core/math/dynamic_bvh.cpp index 8486415c81..5f87f75b61 100644 --- a/core/math/dynamic_bvh.cpp +++ b/core/math/dynamic_bvh.cpp @@ -49,7 +49,6 @@ DynamicBVH::Node *DynamicBVH::_create_node(Node *p_parent, void *p_data) { Node *node = memnew(Node); node->parent = p_parent; node->data = p_data; - node->childs[1] = 0; return (node); } @@ -335,6 +334,7 @@ DynamicBVH::ID DynamicBVH::insert(const AABB &p_box, void *p_userdata) { ID id; id.node = leaf; + return id; } @@ -389,12 +389,35 @@ void DynamicBVH::_extract_leaves(Node *p_node, List<ID> *r_elements) { } } +void DynamicBVH::set_index(uint32_t p_index) { + ERR_FAIL_COND(bvh_root != nullptr); + index = p_index; +} + +uint32_t DynamicBVH::get_index() const { + return index; +} + void DynamicBVH::get_elements(List<ID> *r_elements) { if (bvh_root) { _extract_leaves(bvh_root, r_elements); } } +int DynamicBVH::get_leaf_count() const { + return total_leaves; +} +int DynamicBVH::get_max_depth() const { + if (bvh_root) { + int depth = 1; + int max_depth = 0; + bvh_root->get_max_depth(depth, max_depth); + return max_depth; + } else { + return 0; + } +} + DynamicBVH::~DynamicBVH() { clear(); } |