1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

BVH - add option for expanded AABBs in leaves

This PR adds a define BVH_EXPAND_LEAF_AABBS which is set, which stores expanded AABBs in the tree instead of exact AABBs.

This makes the logic less error prone when considering reciprocal collisions in the pairing, as all collision detect is now taking place between expanded AABB against expanded AABB, rather than expanded AABB against exact AABB.

The flip side of this is that the intersection tests will now be less exact when expanded margins are set.

All margins are now user customizable via project settings, and take account of collision pairing density to adjust the margin dynamically.

(cherry picked from commit 211dc8cd2d)
This commit is contained in:
lawnjelly
2021-11-18 14:32:33 +00:00
committed by Rémi Verschelde
parent f667afc8b2
commit 07e5022cce
10 changed files with 74 additions and 1 deletions

View File

@@ -175,8 +175,11 @@ static String get_full_version_string() {
// FIXME: Could maybe be moved to PhysicsServerManager and Physics2DServerManager directly
// to have less code in main.cpp.
void initialize_physics() {
// This must be defined BEFORE the 3d physics server is created
// This must be defined BEFORE the 3d physics server is created,
// otherwise it won't always show up in the project settings page.
GLOBAL_DEF("physics/3d/godot_physics/use_bvh", true);
GLOBAL_DEF("physics/3d/godot_physics/bvh_collision_margin", 0.1);
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/godot_physics/bvh_collision_margin", PropertyInfo(Variant::REAL, "physics/3d/godot_physics/bvh_collision_margin", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"));
/// 3D Physics Server
physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name));