Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2006, 3:17:20 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/cd: merged the new collision-detection back.
merged and collissions resolved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cd/src/lib/collision_detection/obb_tree.cc

    r5684 r7365  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION
    1717
    1818#include "obb_tree.h"
     
    3131 *  standard constructor
    3232*/
    33 OBBTree::OBBTree ()
     33OBBTree::OBBTree(int depth, const modelInfo* modelInf, WorldEntity* owner)
     34  : BVTree()
    3435{
     36  this->depth = depth;
    3537  this->init();
    36 }
    37 
    38 OBBTree::OBBTree(int depth, sVec3D *verticesList, const int length)
    39 {
    40   this->init();
    41   this->spawnBVTree(depth, verticesList, length);
    42 }
    43 
    44 OBBTree::OBBTree(int depth, const modelInfo& modInfo)
    45 {
    46   this->init();
    47   this->spawnBVTree(depth, modInfo);
     38  this->spawnBVTree(*modelInf);
     39  this->owner = owner;
    4840}
    4941
     
    5345{
    5446  this->setClassID(CL_OBB_TREE, "OBBTree");
    55 
    5647  this->rootNode = NULL;
    57 
    5848  this->id = 0;
    5949}
     
    6959
    7060
    71 void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length)
    72 {
    73   if( unlikely(this->rootNode != NULL))
    74     {
    75       PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n");
    76       this->flushTree();
    77     }
    78   OBBTreeNode* node = new OBBTreeNode();
    79   this->rootNode = node;
    80   this->rootNode->setTreeRef(this);
    81   this->rootNode->spawnBVTree(--depth, verticesList, length);
    82 }
    83 
    84 
    85 void OBBTree::spawnBVTree(int depth, const modelInfo& modInfo)
     61/**
     62 *  this function creates a bv tree out of a modelInf structure
     63 * @param modelInf the model info of a model (modelInfo), containing vertices, triangle and normal infos
     64 */
     65void OBBTree::spawnBVTree(const modelInfo& modelInf)
    8666{
    8767  if( unlikely(this->rootNode != NULL))
     
    9070    this->flushTree();
    9171  }
    92   OBBTreeNode* node = new OBBTreeNode();
    93   this->rootNode = node;
    94   this->rootNode->setTreeRef(this);
    95   this->rootNode->spawnBVTree(--depth, modInfo);
     72  this->rootNode = new OBBTreeNode(*this, NULL, depth-1);
     73
     74  /* triangles indexes created */
     75  int* triangleIndexes = new int[modelInf.numTriangles];
     76  for( int i = 0; i < modelInf.numTriangles; ++i)
     77    triangleIndexes[i] = i;
     78
     79  this->rootNode->spawnBVTree(modelInf, triangleIndexes, modelInf.numTriangles);
    9680}
    9781
    9882
     83/**
     84 *  release the current bv tree if any
     85 */
    9986void OBBTree:: flushTree()
    10087{}
    10188
    10289
     90/**
     91 * this collides two bvtrees together. the trees are attached to pnodes Objects A and B
     92 * @param nodeA: PNode of object A
     93 * @param nodeB: Pnode of object B
     94 */
    10395void OBBTree::collideWith(WorldEntity* entity1, WorldEntity* entity2)
    10496{
     
    109101
    110102/**
    111  * this collides two bvtrees together. the trees are attached to pnodes Objects A and B
    112  * @param tree: the other tree to collide with (Object B)
    113  * @param nodeA: PNode of object A
    114  * @param nodeB: Pnode of object B
     103 *  draw bv tree
    115104 */
    116 void OBBTree::collideWith(BVTree* tree, WorldEntity* nodeA, WorldEntity* nodeB)
    117 {
    118   this->rootNode->collideWith(((OBBTree*)tree)->getRootNode(), nodeA, nodeB);
    119 }
    120 
    121 
    122105void OBBTree::drawBV(int depth, int drawMode) const
    123106{
     
    129112
    130113
    131 
     114/**
     115 *  some debug output and creation function
     116 *
     117 * doesn't work at the moment
     118 */
    132119void OBBTree::debug()
    133120{
     
    153140    }
    154141
    155   this->spawnBVTree(3, vertList, length);
     142//   this->spawnBVTree(vertList, length);
    156143
    157144  PRINT(0)("=  Spawning Tree: Finished\n");
Note: See TracChangeset for help on using the changeset viewer.