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)
I had missed a special case check for userdata of two colliding objects being equal. In this case, collisions should not be reported. This is used in the physics to prevent self intersection in composite objects.
When making items visible from the visual server, the collision check is deferred to prevent two identical collision checks when set_pairable is called shortly after.
It turns out that for some items (especially meshes), set_pairable is never called. This PR detects this occurrence and forces a collision check at the end of the routine.
A major feature lacking in the octree was proper support for setting visibility / activation. This meant that invisible objects were still causing lots of processing in the tree unnecessarily.
This PR adds proper support for activation, items are temporarily removed from the tree and collision detection when inactive.
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.
In the octree collisions are flushed as objects are moved, whereas in the BVH they are usually flushed once per frame.
This was causing problems in the render tree in some rare situations where objects were being created (perhaps deleted and recreated using the same handle in the same frame). This PR flushes the collisions before creating objects, and set_pairable.
set_pairable may not be necessary but it is done for safety until proven not necessary.
Also a small potential for a bug is closed in remove_unordered use.
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.
Calling set_pairable now will update collisions (rather than waiting for the next item_move).
Mask behaviour used for pairing now (hopefully) matches octree.
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.