Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
BVH.h
Go to the documentation of this file.
1#pragma once
2
3#include <glm/glm.hpp>
4
5#include "../bounding/AABB.h"
6#include "NodeIndex.h"
8
9struct BVHNode {
14
15 bool isLeaf() const {
16 return body != nullptr;
17 }
18};
19
20class BVH {
21private:
22 std::vector<BVHNode> nodes;
23
24 void clear();
25 NodeIndex allocateNode();
26 NodeIndex build(std::vector<Physics::PhysicsBody*>& bodies, NodeIndex start, NodeIndex end);
27public:
28 BVH() = default;
29 void build(std::vector<Physics::PhysicsBody*> bodies);
30 std::vector<std::pair<Physics::PhysicsBody*, Physics::PhysicsBody*>> getPotentialCollisions() const;
31};
Definition BVH.h:20
std::vector< std::pair< Physics::PhysicsBody *, Physics::PhysicsBody * > > getPotentialCollisions() const
Definition BVH.cpp:88
BVH()=default
Definition BVH.h:9
NodeIndex left
Definition BVH.h:11
NodeIndex right
Definition BVH.h:12
Physics::PhysicsBody * body
Definition BVH.h:13
Physics::Bounding::AABB bounds
Definition BVH.h:10
bool isLeaf() const
Definition BVH.h:15