Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4697 was 4695, checked in by patrick, 19 years ago

orxonox/trunk: no only the overlap test is missing

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->setClassName("CDEngine");
34   this->setClassID(CL_CD_ENGINE, "CDEngine");
35
36   /* testing purposes only: */
37   //this->rootTree = new OBBTree();
38}
39
40/**
41   \brief the singleton reference to this class
42*/
43CDEngine* CDEngine::singletonRef = NULL;
44
45/**
46   \brief standard deconstructor
47
48*/
49CDEngine::~CDEngine ()
50{
51  CDEngine::singletonRef = NULL;
52
53}
54
55
56/**
57  \brief this is the collision checking function
58
59  there are some speed improvements that can be done here. a rewrite of the list a would be appropriate to
60  be able to enhance iteration speed.
61 */
62void CDEngine::checkCollisions()
63{
64  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
65  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
66  WorldEntity* entity1 = iterator1->nextElement();
67  WorldEntity* entity2 = iterator2->seekElement(entity1);
68  printf("checking for collisions\n");
69  while( entity1 != NULL)
70  {
71    printf("entering l1\n");
72    while( entity2 != NULL)
73    {
74      printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName());
75      entity1->collideWith(entity2);
76      entity2 = iterator2->nextElement();
77
78    }
79    entity1 = iterator1->nextElement();
80    entity2 = iterator2->seekElement(entity1);
81
82  }
83  delete iterator1;
84  delete iterator2;
85}
86
87
88
89void CDEngine::checkCollisionObjects()
90{}
91
92
93void CDEngine::checkCollisionGround()
94{}
95
96
97void CDEngine::drawBV(int depth, int drawMode) const
98{
99  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
100  //this->rootTree->drawBV(depth, drawMode);
101
102  tIterator<WorldEntity>* iterator = entityList->getIterator();
103  WorldEntity* entity = iterator->nextElement();
104  while( entity != NULL)
105  {
106    entity->drawBVTree(depth, drawMode);
107    entity = iterator->nextElement();
108  }
109  delete iterator;
110  //model->draw();
111}
112
113
114
115
116
117void CDEngine::debug()
118{
119  PRINT(0)("\n=============================| CDEngine::debug() |===\n");
120  PRINT(0)("=  CDEngine: Spawning Tree Start\n");
121  //this->rootTree->debug();
122  PRINT(0)("=  CDEngine: Spawning Tree: Finished\n");
123  PRINT(0)("=======================================================\n");
124
125}
126
127void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
128{
129  if ( this->rootTree == NULL)
130    this->rootTree = new OBBTree();
131  this->rootTree->spawnBVTree(depth, vertices, numVertices);
132}
Note: See TracBrowser for help on using the repository browser.