Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
collisiondetector.h
1 #pragma once
2 
3 #include <memory>
4 #include <list>
5 
6 #include <glm/glm.hpp>
7 
8 #include "collision/voxelcollision.h"
9 
10 class Voxel;
11 class WorldTree;
12 class WorldTreeGeode;
13 class WorldObject;
14 class Sphere;
15 class VoxelTree;
16 class VoxelTreeNode;
17 
18 // this class contains datastructures for collision detection
20 {
21 public:
22  CollisionDetector(WorldObject& worldObject);
24 
25  void addVoxel(Voxel* voxel);
26  void removeVoxel(Voxel* voxel);
27 
28  std::list<VoxelCollision> &checkCollisions();
29  std::list<VoxelCollision> &lastCollisions();
30 
31  void reset();
32 
33  WorldTreeGeode* geode();
34  void setGeode(WorldTreeGeode* geode);
35 
36  void setWorldTree(WorldTree* worldTree);
37  WorldTree* worldTree();
38 
39  VoxelTree& voxelTree();
40 
41  void updateGeode();
42 
43 
44 protected:
45  std::unique_ptr<VoxelTree> m_voxelTree;
46  WorldObject& m_worldObject;
47  WorldTreeGeode* m_geode;
48  WorldTree* m_worldTree;
49  std::list<VoxelCollision> m_collisions;
50 
51  void checkCollisions(VoxelTreeNode* nodeA, VoxelTreeNode* nodeB);
52  const Sphere& getOrCreateSphere(VoxelTreeNode* node);
53 };
54 
Definition: worldobject.h:43
Definition: worldtreegeode.h:11
Definition: voxeltreenode.h:15
Definition: collisiondetector.h:19
Definition: voxel.h:15
Definition: voxeltree.h:9
Definition: sphere.h:11
Definition: worldtree.h:13