OctTree.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /***************************************************************************
  2. OctTree.h - description
  3. -------------------
  4. begin : Sun Mar 19 2000
  5. copyright : (C) 2000 by Henrik Enqvist
  6. email : henqvist@excite.com
  7. ***************************************************************************/
  8. #ifndef OCTTREE_H
  9. #define OCTTREE_H
  10. using namespace std;
  11. #include <vector>
  12. #include "EMath.h"
  13. #include "Node.h"
  14. class Group;
  15. class CollisionBounds;
  16. /** An global octtree used for speeding up collision detection and
  17. * hidden surface test. */
  18. class OctTree {
  19. public:
  20. OctTree(int level, float size, float x=0.0f, float y=0.0f, float z=0.0f);
  21. ~OctTree();
  22. private:
  23. friend class CollisionVisitor;
  24. void split(int depth);
  25. bool surround(CollisionBounds * cb);
  26. bool collide(CollisionBounds * cb);
  27. bool insertGroup(Group * g);
  28. void clear();
  29. void printTree(int depth=0);
  30. float m_fSize;
  31. Vertex3D m_vtx;
  32. vector<OctTree*> m_vOctTree;
  33. vector<Group*> m_vGroup;
  34. };
  35. #endif // OCTTREE_H