Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) where appropriate for 32 bit calculations, and cast to (real_t) or (float) as appropriate.
This ensures that appropriate calculations will be done at 32 bits when real_t is compiled as float, rather than promoted to 64 bits.
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.
Although the expanded bounds were working in normal use, for moving and growing objects, there was one case which was not dealt with properly - significant shrinkage of exact bounds within an expanded bound.
This PR detects significant shrinkage and forces a new expanded bound to be created.
List of changes:
- Modified bvh class to handle 2D and 3D as a template
- Changes in Rect2, Vector2, Vector3 interface to uniformize template
calls
- New option in Project Settings to enable BVH for 2D Physics (enabled
by default like in 3D)
Fix bug whereby AABBs were reused from previous items due to use of a pool, resulting in missed collisions.
Also use full mask collision checks for all cases except generic update.
Change render BVH update scheme from once per update_dirty_instances to a new update_scenarios function called once per draw.
Fix lights not being properly unpaired.
Fixed bug in add_changed_item where AABBs were not being updated due to more than one update per tick.
Complete rewrite of spatial partitioning using a bounding volume hierarchy rather than octree.
Switchable in project settings between using octree or BVH for rendering and physics.