From 83058597cf02255d7c0359a96f125010f63deff7 Mon Sep 17 00:00:00 2001 From: reduz Date: Wed, 23 Dec 2020 13:52:58 -0300 Subject: Replace Octree by DynamicBVH in cull code -Much greater pairing/unpairing performance -For now, using it for culling too, but this will change in a couple of days. -Added a paged allocator, to efficiently alloc/free some types of objects. --- core/math/dynamic_bvh.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'core/math/dynamic_bvh.cpp') 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 *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 *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(); } -- cgit v1.2.3