/**************************************************************************/ /* bvh_tree.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #ifndef BVH_TREE_H #define BVH_TREE_H // BVH Tree // This is an implementation of a dynamic BVH with templated leaf size. // This differs from most dynamic BVH in that it can handle more than 1 object // in leaf nodes. This can make it far more efficient in certain circumstances. // It also means that the splitting logic etc have to be completely different // to a simpler tree. // Note that MAX_CHILDREN should be fixed at 2 for now. #include "core/math/aabb.h" #include "core/math/bvh_abb.h" #include "core/math/geometry_3d.h" #include "core/math/vector3.h" #include "core/templates/local_vector.h" #include "core/templates/pooled_list.h" #include <limits.h> #define BVHABB_CLASS … // not sure if this is better yet so making optional #define BVH_EXPAND_LEAF_AABBS // never do these checks in release #ifdef DEV_ENABLED //#define BVH_VERBOSE //#define BVH_VERBOSE_TREE //#define BVH_VERBOSE_PAIRING //#define BVH_VERBOSE_MOVES //#define BVH_VERBOSE_FRAME //#define BVH_CHECKS //#define BVH_INTEGRITY_CHECKS #endif // debug only assert #ifdef BVH_CHECKS #define BVH_ASSERT … #else #define BVH_ASSERT(a) … #endif #ifdef BVH_VERBOSE #define VERBOSE_PRINT … #else #define VERBOSE_PRINT … #endif // really just a namespace struct BVHCommon { … }; // really a handle, can be anything // note that zero is a valid reference for the BVH .. this may involve using // a plus one based ID for clients that expect 0 to be invalid. struct BVHHandle { … }; // helper class to make iterative versions of recursive functions template <typename T> class BVH_IterativeInfo { … }; template <typename T> class BVH_DummyPairTestFunction { … }; template <typename T> class BVH_DummyCullTestFunction { … }; template <typename T, int NUM_TREES, int MAX_CHILDREN, int MAX_ITEMS, typename USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, typename USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, bool USE_PAIRS = false, typename BOUNDS = AABB, typename POINT = Vector3> class BVH_Tree { … }; #undef VERBOSE_PRINT #endif // BVH_TREE_H