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
"
7
#include "
physics/PhysicsBody.h
"
8
9
struct
BVHNode
{
10
Physics::Bounding::AABB
bounds
;
11
NodeIndex
left
;
12
NodeIndex
right
;
13
Physics::PhysicsBody
*
body
=
nullptr
;
14
15
bool
isLeaf
()
const
{
16
return
body
!=
nullptr
;
17
}
18
};
19
20
class
BVH
{
21
private
:
22
std::vector<BVHNode> nodes;
23
24
void
clear();
25
NodeIndex
allocateNode();
26
NodeIndex
build(std::vector<Physics::PhysicsBody*>& bodies,
NodeIndex
start,
NodeIndex
end);
27
public
:
28
BVH
() =
default
;
29
void
build(std::vector<Physics::PhysicsBody*> bodies);
30
std::vector<std::pair<Physics::PhysicsBody*, Physics::PhysicsBody*>>
getPotentialCollisions
()
const
;
31
};
NodeIndex.h
PhysicsBody.h
BVH
Definition
BVH.h:20
BVH::getPotentialCollisions
std::vector< std::pair< Physics::PhysicsBody *, Physics::PhysicsBody * > > getPotentialCollisions() const
Definition
BVH.cpp:88
BVH::BVH
BVH()=default
Physics::Bounding::AABB
Definition
AABB.h:6
Physics::PhysicsBody
Definition
PhysicsBody.h:43
BVHNode
Definition
BVH.h:9
BVHNode::left
NodeIndex left
Definition
BVH.h:11
BVHNode::right
NodeIndex right
Definition
BVH.h:12
BVHNode::body
Physics::PhysicsBody * body
Definition
BVH.h:13
BVHNode::bounds
Physics::Bounding::AABB bounds
Definition
BVH.h:10
BVHNode::isLeaf
bool isLeaf() const
Definition
BVH.h:15
NodeIndex
Definition
NodeIndex.h:3
src
physics
spatial
BVH.h
Generated by
1.9.8