Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4630 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jun 14, 2005, 5:19:23 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: the memory requirements are lowered, some strucural changes in the bv generation

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/lin_alg.h

    r4628 r4630  
    4949      for (iq=ip+1; iq<=N; iq++)
    5050        sm=sm+fabs(A[ip][iq]);
    51     if (sm==0) {
     51    if (sm==0)
     52    {
     53      free(B);
     54      free(Z);
    5255      return;       //normal return
    5356    }
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4629 r4630  
    4545OBBTree*  OBBTreeNode::obbTree = NULL;
    4646
     47float**  OBBTreeNode::coMat = NULL;
     48float**  OBBTreeNode::eigvMat = NULL;
     49float*   OBBTreeNode::eigvlMat = NULL;
     50int*     OBBTreeNode::rotCount = NULL;
     51
    4752/**
    4853   \brief standard constructor
     
    5358  this->nodeLeft = NULL;
    5459  this->nodeRight = NULL;
     60
     61  if(coMat == NULL)
     62  {
     63    coMat = new float*[4];
     64    for(int i = 0; i < 4; i++)
     65      coMat[i] = new float[4];
     66  }
     67  if(eigvMat == NULL)
     68  {
     69    eigvMat = new float*[4];
     70    for(int i = 0; i < 4; i++)
     71      eigvMat[i] = new float[4];
     72  }
     73  if( eigvlMat == NULL)
     74  {
     75    eigvlMat = new float[4];
     76  }
     77  if( rotCount == NULL)
     78    rotCount = new int;
    5579}
    5680
     
    76100  this->depth = depth;
    77101
    78   this->bvElement = this->createBox();
     102  this->bvElement = new OBB();
    79103  PRINTF(0)("Created OBBox\n");
    80104  this->calculateBoxAttributes(this->bvElement, verticesList, length);
     
    85109    this->forkBox(this->bvElement);
    86110
    87   }
    88 }
    89 
    90 
    91 OBB* OBBTreeNode::createBox()
    92 {
    93   return new OBB();
    94 }
     111    OBBTreeNode*       node1 = new OBBTreeNode();
     112    OBBTreeNode*       node2 = new OBBTreeNode();
     113
     114    this->nodeLeft = node1;
     115    this->nodeRight = node2;
     116
     117    this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
     118    this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
     119
     120  }
     121}
     122
    95123
    96124
     
    188216  vectors
    189217  */
    190  /* Matrix                V(3,3);    */                           //!< for eigenvectors
    191  /* DiagonalMatrix        D(3);   */                              //!< for eigenvalues
    192 /*  SymmetricMatrix       C(3); */                                //!< for the covariance symmetrical matrix
    193218  Vector**              axis = new Vector*[3];                //!< the references to the obb axis
    194 
     219//   float**               a = new float*[4];
     220//   float**               b = new float*[4];
     221//   float                 eigval[3];
     222//   int*                  rot = new int;
     223
     224
     225  //coMat[0] = new float[4]; coMat[1] = new float[4]; coMat[2] = new float[4]; coMat[3] = new float[4];
     226  //eigvMat[0] = new float[4]; eigvMat[1] = new float[4]; eigvMat[2] = new float[4]; eigvMat[3] = new float[4];
     227
     228  coMat[1][1] = covariance[0][0]; coMat[1][2] = covariance[0][1]; coMat[1][3] = covariance[0][2];
     229  coMat[2][1] = covariance[1][0]; coMat[2][2] = covariance[1][1]; coMat[2][3] = covariance[1][2];
     230  coMat[3][1] = covariance[2][0]; coMat[3][2] = covariance[2][1]; coMat[3][3] = covariance[2][2];
    195231
    196232  /* new jacobi tests */
    197   float** a = new float*[4];
    198   a[0] = new float[4]; a[1] = new float[4]; a[2] = new float[4]; a[3] = new float[4];
    199 
    200   float** b = new float*[4];
    201   b[0] = new float[4]; b[1] = new float[4]; b[2] = new float[4]; b[3] = new float[4];
    202 
    203   float eigval[3];
    204 
    205   int* rot = new int;
    206 
    207 
    208   a[1][1] = covariance[0][0];
    209   a[1][2] = covariance[0][1];
    210   a[1][3] = covariance[0][2];
    211   a[2][1] = covariance[1][0];
    212   a[2][2] = covariance[1][1];
    213   a[2][3] = covariance[1][2];
    214   a[3][1] = covariance[2][0];
    215   a[3][2] = covariance[2][1];
    216   a[3][3] = covariance[2][2];
    217 
    218 
    219   JacobI(a, 3, eigval, b, rot);
     233  JacobI(coMat, 3, eigvlMat, eigvMat, rotCount);
    220234  PRINTF(0)("-- Done Jacobi Decomposition\n");
    221235
     
    228242//     for(int k = 1; k < 4; ++k)
    229243//     {
    230 //       printf(" \b%f ", b[j][k]);
     244//       printf(" \b%f ", eigvMat[j][k]);
    231245//     }
    232246//     printf(" |\n");
    233247//   }
    234248
    235   axis[0] = new Vector(b[1][1], b[2][1], b[3][1]);
    236   axis[1] = new Vector(b[1][2], b[2][2], b[3][2]);
    237   axis[2] = new Vector(b[1][3], b[2][3], b[3][3]);
     249  axis[0] = new Vector(eigvMat[1][1], eigvMat[2][1], eigvMat[3][1]);
     250  axis[1] = new Vector(eigvMat[1][2], eigvMat[2][2], eigvMat[3][2]);
     251  axis[2] = new Vector(eigvMat[1][3], eigvMat[2][3], eigvMat[3][3]);
    238252  box->axis = axis;
    239253  PRINTF(0)("-- Got Axis\n");
    240 
    241   delete [] a[0];
    242   delete [] a[1];
    243   delete [] a[2];
    244   delete [] a[3];
    245   delete [] a;
    246 
    247   delete [] b[0];
    248   delete [] b[1];
    249   delete [] b[2];
    250   delete [] b[3];
    251   delete [] b;
    252 
    253254
    254255//   printf("\neigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
    255256//   printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
    256257//   printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
     258
     259
     260//   delete [] a[0]; delete [] a[1]; delete [] a[2]; delete [] a[3];
     261//   delete [] a;
     262//
     263//   delete [] b[0]; delete [] b[1]; delete [] b[2]; delete [] b[3];
     264//   delete [] b;
     265//
     266//   delete rot;
    257267
    258268
     
    291301  box->halfLength = halfLength;
    292302  PRINTF(0)("-- Written Axis to obb\n");
    293 
     303  PRINTF(0)("-- Finished Calculating Attributes\n");
    294304
    295305//   printf("\nwe got length: \n");
     
    403413    element = iterator->nextElement();
    404414  }
     415
     416  this->tmpVert1 = vertList1;
     417  this->tmpVert2 = vertList2;
     418  this->tmpLen1 = partition1.getSize();
     419  this->tmpLen2 = partition2.getSize();
    405420
    406421  //delete iterator;
     
    412427//     printf("v[%i][2] = %f\n", i, vertList2[i][2]);
    413428//   }
    414 
    415   /* now spawn the obb tree: create the nodes and descent */
    416   OBBTreeNode*       node1 = new OBBTreeNode();
    417   OBBTreeNode*       node2 = new OBBTreeNode();
    418 
    419   this->nodeLeft = node1;
    420   this->nodeRight = node2;
    421 
    422   this->nodeLeft->spawnBVTree(depth - 1, vertList1, partition1.getSize());
    423   this->nodeRight->spawnBVTree(depth - 1, vertList2, partition2.getSize());
    424429}
    425430
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.h

    r4622 r4630  
    4141
    4242  private:
    43     OBB* createBox();
    4443    void calculateBoxAttributes(OBB* box, sVec3D* verticesList, int length);
    4544    void forkBox(OBB* box);
     
    5857    int                 depth;                      //!< the depth of the node in the tree
    5958    static OBBTree*     obbTree;                    //!< reference to the obb tree
     59
     60    /* tmp saving place for obb variables */
     61    sVec3D*             tmpVert1;
     62    sVec3D*             tmpVert2;
     63    int                 tmpLen1;
     64    int                 tmpLen2;
     65
     66    static float**       coMat;
     67    static float**       eigvMat;
     68    static float*        eigvlMat;
     69    static int*          rotCount;
    6070};
    6171
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4629 r4630  
    3535  model = new MD2Model("models/tris.md2", "models/tris.pcx");
    3636  model->tick(0.1f);
    37   CDEngine::getInstance()->debugSpawnTree(2, model->data->pVertices, model->data->numVertices);
     37
     38//   int const length = 6;
     39//   sVec3D* vertList = new sVec3D[length];
     40//   sVec3D data[length]  = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}};
     41//
     42//   for(int i = 0; i < length; ++i)
     43//   {
     44//     vertList[i][0] = data[i][0];
     45//     vertList[i][1] = data[i][1];
     46//     vertList[i][2] = data[i][2];
     47//   }
     48
     49  CDEngine::getInstance()->debugSpawnTree(1, model->data->pVertices, model->data->numVertices);
    3850
    3951
     
    7082void Framework::moduleDraw() const
    7183{
    72   CDEngine::getInstance()->drawBV(2);
     84  CDEngine::getInstance()->drawBV(1);
    7385
    7486  LightManager::getInstance()->draw();
Note: See TracChangeset for help on using the changeset viewer.