Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/collision_detection/cd_engine.cc @ 4746

Last change on this file since 4746 was 4742, checked in by bensch, 19 years ago

orxonox/trunk: BaseObject now only knows setClassID → standartisation

File size: 3.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
17
18#include "cd_engine.h"
19#include "obb_tree.h"
20#include "debug.h"
21#include "abstract_model.h"
22#include "world_entity.h"
23#include "list.h"
24
25using namespace std;
26
27
28/**
29   \brief standard constructor
30*/
31CDEngine::CDEngine ()
32{
33   this->setClassID(CL_CD_ENGINE, "CDEngine");
34
35   /* testing purposes only: */
36   //this->rootTree = new OBBTree();
37}
38
39/**
40   \brief the singleton reference to this class
41*/
42CDEngine* CDEngine::singletonRef = NULL;
43
44/**
45   \brief standard deconstructor
46
47*/
48CDEngine::~CDEngine ()
49{
50  CDEngine::singletonRef = NULL;
51
52}
53
54
55/**
56  \brief this is the collision checking function
57
58  there are some speed improvements that can be done here. a rewrite of the list a would be appropriate to
59  be able to enhance iteration speed.
60 */
61void CDEngine::checkCollisions()
62{
63  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
64  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
65  WorldEntity* entity1 = iterator1->nextElement();
66  WorldEntity* entity2 = iterator2->seekElement(entity1);
67  PRINTF(3)("checking for collisions\n");
68  while( entity1 != NULL)
69  {
70    while( entity2 != NULL)
71    {
72      PRINTF(3)("checking object %s against %s\n", entity1->getName(), entity2->getName());
73      entity1->collideWith(entity2);
74      entity2 = iterator2->nextElement();
75
76    }
77    entity1 = iterator1->nextElement();
78    entity2 = iterator2->seekElement(entity1);
79
80  }
81  delete iterator1;
82  delete iterator2;
83}
84
85
86
87void CDEngine::checkCollisionObjects()
88{}
89
90
91void CDEngine::checkCollisionGround()
92{}
93
94
95void CDEngine::drawBV(int depth, int drawMode) const
96{
97  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
98  //this->rootTree->drawBV(depth, drawMode);
99
100  tIterator<WorldEntity>* iterator = entityList->getIterator();
101  WorldEntity* entity = iterator->nextElement();
102  while( entity != NULL)
103  {
104    entity->drawBVTree(depth, drawMode);
105    entity = iterator->nextElement();
106  }
107  delete iterator;
108  //model->draw();
109}
110
111
112
113
114
115void CDEngine::debug()
116{
117  PRINT(0)("\n=============================| CDEngine::debug() |===\n");
118  PRINT(0)("=  CDEngine: Spawning Tree Start\n");
119  //this->rootTree->debug();
120  PRINT(0)("=  CDEngine: Spawning Tree: Finished\n");
121  PRINT(0)("=======================================================\n");
122
123}
124
125void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
126{
127  if ( this->rootTree == NULL)
128    this->rootTree = new OBBTree();
129  this->rootTree->spawnBVTree(depth, vertices, numVertices);
130}
131
132void CDEngine::debugDraw(int depth, int drawMode)
133{
134  if(this-> rootTree != NULL)
135    this->rootTree->drawBV(depth, drawMode);
136}
Note: See TracBrowser for help on using the repository browser.