group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
BroadphaseTree.hpp File Reference

Dynamic AABB tree for O(log n) overlap queries. More...

#include "ecs/physics/SweptCollision.hpp"
#include <cstdint>
#include <entt/entt.hpp>
#include <functional>
#include <glm/vec3.hpp>
#include <vector>
Include dependency graph for BroadphaseTree.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::broadphase::Proxy
 Stable handle to a tree leaf. More...
class  physics::broadphase::Tree
 Dynamic AABB tree. More...
struct  physics::broadphase::Tree::Node

Namespaces

namespace  physics
 Pure physics math — no ECS types, no registry.
namespace  physics::broadphase

Detailed Description

Dynamic AABB tree for O(log n) overlap queries.

Box2D-style b2DynamicTree: a binary tree of "fat" AABBs (padded by a margin so small movements don't require re-insertion). Each leaf stores a stable Proxy handle plus user data (an entt::entity). Internal nodes track the union AABB of their children.

Operations.

  • insertProxy(aabb, entity) → returns a Proxy handle.
  • updateProxy(p, newAabb) → re-positions if it left its fat AABB.
  • removeProxy(p) → destroys the leaf.
  • queryAABB(aabb, visit) → calls visit(entity) for every overlapping leaf.
  • raycast(origin, dir, maxT, visit) → calls visit for every leaf the ray segment intersects (Slab test).

Determinism. Tree topology depends on insertion order; for reproducible behaviour, callers insert proxies in stable entity-id order (see Phase 15 audit checklist).

Memory. Nodes are stored in a pool indexed by 32-bit ids; the free list reuses slots so capacity stays bounded.