Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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