Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5713 in orxonox.OLD for branches/collision_detection


Ignore:
Timestamp:
Nov 22, 2005, 7:01:42 PM (19 years ago)
Author:
patrick
Message:

collision_bibischen: more interface changes, more covariance building

Location:
branches/collision_detection/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/collision_detection/src/defs/debug.h

    r5476 r5713  
    7575  #define DEBUG_MODULE_OBJECT_MANAGER        2
    7676  #define DEBUG_MODULE_ANIM                  2
    77   #define DEBUG_MODULE_COLLISON_DETECTION    2
     77  #define DEBUG_MODULE_COLLISON_DETECTION    5
    7878  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
    7979  #define DEBUG_MODULE_GUI                   2
  • branches/collision_detection/src/lib/collision_detection/cd_engine.cc

    r5134 r5713  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION
    1717
    1818#include "cd_engine.h"
  • branches/collision_detection/src/lib/collision_detection/obb_tree.cc

    r5705 r5713  
    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"
     
    7676      this->flushTree();
    7777    }
    78   OBBTreeNode* node = new OBBTreeNode(this);
     78  OBBTreeNode* node = new OBBTreeNode(*this, depth);
    7979  this->rootNode = node;
    8080  this->rootNode->spawnBVTree(--depth, verticesList, length);
     
    8989    this->flushTree();
    9090  }
    91   OBBTreeNode* node = new OBBTreeNode(this);
     91  OBBTreeNode* node = new OBBTreeNode(*this, depth);
    9292  this->rootNode = node;
    93  
     93
    9494  /* triangles indexes created */
    9595  int* triangleIndexes = new int[modelInf.numTriangles];
    9696  for(int i = 0; i < modelInf.numTriangles; ++i)
    9797    triangleIndexes[i] = i;
    98  
     98
    9999  this->rootNode->spawnBVTree(--depth, modelInf, triangleIndexes, modelInf.numTriangles);
    100100}
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc

    r5712 r5713  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION
    1717
    1818#include "obb_tree_node.h"
     
    4242 *  standard constructor
    4343 */
    44 OBBTreeNode::OBBTreeNode (const OBBTree* tree)
     44OBBTreeNode::OBBTreeNode (const OBBTree& tree, unsigned int depth)
    4545  : BVTreeNode()
    4646{
    4747  this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode");
    48   this->obbTree = tree;
     48
     49  this->obbTree = &tree;
     50  this->depth = depth;
     51
    4952  this->nodeLeft = NULL;
    5053  this->nodeRight = NULL;
    5154  this->bvElement = NULL;
     55
    5256  this->tmpVert1 = NULL;
    5357  this->tmpVert2 = NULL;
     
    7579    OBBTreeNode_sphereObj = gluNewQuadric();
    7680}
    77 
    7881
    7982/**
     
    117120
    118121  PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
     122  printf("OBBTreeNode::spawnBVTree()\n");
    119123  this->depth = depth;
    120124
     
    132136  if( likely( this->depth > 0))
    133137  {
    134     this->forkBox(*this->bvElement);
     138    //this->forkBox(*this->bvElement);
    135139
    136140
     
    170174void OBBTreeNode::spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length)
    171175{
    172 //   PRINT(3)("\n");
     176//   PRINTF(3)("\n");
    173177//   PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
    174178//   this->depth = depth;
     
    239243  for( int i = 0; i < length ; ++i)
    240244  {
    241     sVec3D* a = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[i].indexToVertices[0]]);
    242     p = *a;
    243     p.debug();
    244     //q = modelInf.pVertices[modelInf.pTriangles[i][1]];     //verticesList[i + 1];
    245     //r = modelInf.pVertices[modelInf.pTriangles[i][2]];     //verticesList[i + 2];
    246 
     245    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]);
     246    p = *tmpVec;
     247    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]);
     248    q = *tmpVec;
     249    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]);
     250    r = *tmpVec;
     251
     252    /* finding the facelet surface via cross-product */
    247253    t1 = p - q; t2 = p - r;
    248 
    249     /* finding the facelet surface via cross-product */
    250254    facelet[i] = 0.5f * fabs( t1.cross(t2).len() );
    251255    /* update the entire convex hull surface */
     
    270274      for( int i = 0; i + 3 < length; i+=3)
    271275      {
    272         p = verticesList[i];
    273         q = verticesList[i + 1];
    274         r = verticesList[i + 2];
     276        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]);
     277        p = *tmpVec;
     278        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]);
     279        q = *tmpVec;
     280        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]);
     281        r = *tmpVec;
     282
    275283
    276284        covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j] * p[k] +
     
    286294    PRINTF(3)(" Vertex[%i]: %f, %f, %f\n", i, box.vertices[i][0], box.vertices[i][1], box.vertices[i][2]);
    287295  PRINTF(3)("\nOBB Covariance Matrix:\n");
    288   for(int j = 0; j < 3; ++j) { PRINT(3)(" |"); for(int k = 0; k < 3; ++k) { PRINT(3)(" \b%f ", covariance[j][k]); } PRINT(3)(" |\n"); }
     296  for(int j = 0; j < 3; ++j) { PRINTF(3)(" |"); for(int k = 0; k < 3; ++k) { PRINTF(3)(" \b%f ", covariance[j][k]); } PRINTF(3)(" |\n"); }
    289297  PRINTF(3)("OBB Center: %f, %f, %f\n", center.x, center.y, center.z);
    290298
     
    357365void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modInfo, const int* triangleIndexes, unsigned int length)
    358366{
    359   this->calculateBoxAxis(box, (const sVec3D*)modInfo.pVertices, modInfo.numVertices);
     367  //this->calculateBoxAxis(box, (const sVec3D*)modInfo.pVertices, modInfo.numVertices);
    360368}
    361369
     
    597605  PRINTF(3)("collideWith\n");
    598606  /* if the obb overlap, make subtests: check which node is realy overlaping  */
    599   PRINT(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
     607  PRINTF(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
    600608  if( unlikely(treeNode == NULL)) return;
    601609
     
    607615    if( likely( this->nodeLeft != NULL))
    608616    {
    609       PRINT(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
     617      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
    610618      if( this->overlapTest(this->nodeLeft->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB))
    611619      {
     
    617625    if( likely( this->nodeRight != NULL))
    618626    {
    619       PRINT(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
     627      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
    620628      if(this->overlapTest(this->nodeRight->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB))
    621629      {
     
    691699    if( (rA + rB) < fabs(t.dot(l)))
    692700    {
    693       PRINT(3)("no Collision\n");
     701      PRINTF(3)("no Collision\n");
    694702      return false;
    695703    }
     
    715723    if( (rA + rB) < fabs(t.dot(l)))
    716724    {
    717       PRINT(3)("no Collision\n");
     725      PRINTF(3)("no Collision\n");
    718726      return false;
    719727    }
     
    743751      if( (rA + rB) < fabs(t.dot(l)))
    744752      {
    745         PRINT(3)("keine Kollision\n");
     753        PRINTF(3)("keine Kollision\n");
    746754        return false;
    747755      }
     
    752760  boxA->bCollided = true; /* use this ONLY(!!!!) for drawing operations */
    753761  boxB->bCollided = true;
    754   PRINT(3)("Kollision!\n");
     762  PRINTF(3)("Kollision!\n");
    755763  return true;
    756764}
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.h

    r5712 r5713  
    2525
    2626  public:
    27     OBBTreeNode(const OBBTree* tree);
    28     OBBTreeNode(const OBBTree* tree, bool bRoot);
     27    OBBTreeNode(const OBBTree& tree, unsigned int depth);
    2928    virtual ~OBBTreeNode();
    3029
  • branches/collision_detection/src/world_entities/world_entity.cc

    r5684 r5713  
    119119  {
    120120    PRINTF(4)("creating obb tree\n");
    121    
    122    
    123     this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     121
     122
     123    //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     124    this->obbTree = new OBBTree(depth, *model->getModelInfo());
    124125    return true;
    125126  }
Note: See TracChangeset for help on using the changeset viewer.