Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_detection/cd_engine.h @ 10614

Last change on this file since 10614 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.8 KB
RevLine 
[4615]1/*!
[5039]2 * @file cd_engine.h
[4836]3  *  Definition of the collision detection engine
[4615]4
[4510]5*/
6
[4511]7#ifndef _CD_ENGINE_H
8#define _CD_ENGINE_H
[4510]9
10#include "base_object.h"
[4522]11#include "collision_defs.h"
[6022]12#include "model.h"
[4510]13
[6142]14#include <list>
[5026]15
[4523]16class WorldEntity;
[4551]17class OBBTree;
[4918]18class Terrain;
[8186]19class BspManager;
[5915]20//class Player;
[4510]21
[4526]22
[4523]23//! featured state options, they are all additive
[4522]24typedef enum cdState
25  {
26    CD_DEBUG_DRAW_ALL = 1,
27    CD_DEBUG_DRAW_POLYGONS = 1<<1,
28    CD_DEBUG_DRAW_BLENDED = 1<<2,
29    CD_DEBUG_DRAW_HIT_BV = 1<<3,
[4541]30    CD_DEBUG_VERBOSE = 1<<4,
31
32    CD_STORE_VERTICES = 1<<5
[4522]33  };
34
35
[4511]36//! The class representing the collision detection system of orxonox
37class CDEngine : public BaseObject {
[9869]38  ObjectListDeclaration(CDEngine);
[4510]39
[5026]40  friend class WorldEntity;
41
[4510]42 public:
[4746]43  virtual ~CDEngine();
[4836]44  /** @returns a Pointer to the only object of this Class */
[4746]45  static CDEngine* getInstance() { if (!singletonRef) singletonRef = new CDEngine(); return singletonRef; }
[4522]46  void init();
[4510]47
[4688]48  inline void setState(const int newState) { this->state = newState; }
49  inline const int getState() const { return this->state; }
50  inline void enable(const int options) { this->state |= options; }
51  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
[4522]52
[4918]53  inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
[8186]54  inline void setBSPModel(BspManager* bspManager) { this->bspManager = bspManager; }
[4688]55
[6142]56  void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2);
[8186]57  void checkCollisionGround(std::list<WorldEntity*>& list1);
[4522]58
[7739]59  void drawBV(const std::list<WorldEntity*>& drawList, int level) const;
[4546]60  void debug();
61
[7713]62  /** @returns true if cd alg returns after detecting first error (default behavour) */
63  inline bool isAbordOnFirstCollision() const { return this->bAbordOnFirstCollision; }
64  /** sets @param flag true if the alg should return after detection of the first error */
65  inline void setAbordOnFirstCollision(bool flag) { this->bAbordOnFirstCollision = flag; }
[4924]66
[7713]67
[4510]68 private:
[4746]69  CDEngine();
[4511]70  static CDEngine* singletonRef;
[4522]71
[4523]72  void spawnBVTree(int depth = MAX_BV_TREE_DEPTH);
[4522]73
[4523]74  void checkCollisionObjects();
[4522]75
[8186]76
[4924]77  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
78  void debugDraw(int depth, int drawMode);
[4523]79
[4924]80
[4522]81 private:
[4523]82  int                     state;                            //!< the current state of the cd engine
[7711]83  bool                    bAbordOnFirstCollision;           //!< abords the collision detection on first collision event => more speed but less accurate infomations
[4551]84  OBBTree*                rootTree;                         //!< for testing purposes a root tree
[4918]85
86  Terrain*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
[8186]87  BspManager*             bspManager;
[4510]88};
89
[4511]90#endif /* _CD_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.