Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/collision_detection/cd_engine.cc @ 7903

Last change on this file since 7903 was 7739, checked in by patrick, 19 years ago

trunk: tried to add the command for bvvisibility toggling with depth level. execution results in segfault :(

File size: 3.2 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_DETECTION
17
18#include "cd_engine.h"
19#include "obb_tree.h"
20#include "debug.h"
21
22#include "model.h"
23#include "world_entity.h"
24#include "terrain.h"
25// #include "player.h"
26
27#include "spatial_separation.h"
28#include "quadtree.h"
29#include "quadtree_node.h"
30
31
32
33using namespace std;
34
35
36/**
37 *  standard constructor
38 */
39CDEngine::CDEngine ()
40{
41  this->setClassID(CL_CD_ENGINE, "CDEngine");
42
43  this->bAbordOnFirstCollision = false;
44}
45
46
47/**
48 *  the singleton reference to this class
49 */
50CDEngine* CDEngine::singletonRef = NULL;
51
52
53/**
54 *  standard deconstructor
55 */
56CDEngine::~CDEngine ()
57{
58  CDEngine::singletonRef = NULL;
59}
60
61
62/**
63 *
64 */
65void CDEngine::checkCollisions(ObjectManager::EntityList& list1, ObjectManager::EntityList& list2)
66{
67  BVTree* tree;
68  ObjectManager::EntityList::iterator entity1, entity2, pre1, pre2;
69  PRINTF(5)("checking for collisions\n");
70
71  pre1 = list1.begin();
72  while (pre1 != list1.end())
73  {
74    entity1 = pre1++;
75    if( likely((*entity1) != this->terrain))
76    {
77      pre2 = list2.begin();
78      while (pre2 != list2.end())
79      {
80        entity2 = pre2++;
81        if( likely((*entity2) != this->terrain))
82        {
83          PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName());
84          tree = (*entity1)->getOBBTree();
85          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL)
86            tree->collideWith(*entity1, *entity2);
87        }
88      }
89    }
90  }
91}
92
93
94/**
95 *  this checks the collisions with the ground
96 */
97void CDEngine::checkCollisionGround()
98{
99  if( likely( this->terrain != NULL))
100  {
101    Quadtree* q = dynamic_cast<Terrain*>(this->terrain)->ssp->getQuadtree();
102
103//    QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
104  }
105  //sTriangleExt* tri = q->getTriangleFromPosition(this->player->getAbsCoor());
106}
107
108
109/**
110 * some debug output on the class
111 */
112void CDEngine::debug()
113{
114  PRINT(0)("\n=============================| CDEngine::debug() |===\n");
115  PRINT(0)("=  CDEngine: Spawning Tree Start\n");
116  //this->rootTree->debug();
117  PRINT(0)("=  CDEngine: Spawning Tree: Finished\n");
118  PRINT(0)("=======================================================\n");
119
120}
121
122
123/**
124 * this spawns a tree for debug purposes only
125 */
126void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
127{
128//   if ( this->rootTree == NULL)
129//     this->rootTree = new OBBTree(depth, vertices, numVertices);
130}
131
132
133void CDEngine::drawBV(const ObjectManager::EntityList& drawList, int level) const
134{
135  ObjectManager::EntityList::const_iterator entity;
136  for (entity = drawList.begin(); entity != drawList.end(); entity++)
137    (*entity)->drawBVTree(level, 226);
138}
139
140/**
141 * this draws the debug spawn tree
142 */
143void CDEngine::debugDraw(int depth, int drawMode)
144{
145//   if(this-> rootTree != NULL)
146//     this->rootTree->drawBV(depth, drawMode);
147}
Note: See TracBrowser for help on using the repository browser.