Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5699 in orxonox.OLD for branches


Ignore:
Timestamp:
Nov 22, 2005, 2:26:46 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/collision_detection: switched from pointers to Values, to save debug-time deleting all the nice little new Pointer-arrays

@patrick: hope you approve

Location:
branches/collision_detection/src/lib/collision_detection
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/collision_detection/src/lib/collision_detection/obb.cc

    r5120 r5699  
    2929{
    3030   this->setClassID(CL_OBB, "OBB");
    31    this->axis = new Vector[3];
    32    this->halfLength = new float[3];
     31   this->halfLength[0] = this->halfLength[1] = this->halfLength[2] = 0.0f;
    3332   this->bCollided = false;
    3433}
     
    4140OBB::~OBB ()
    4241{
    43   delete [] this->axis;
    44   delete [] this->halfLength;
    4542}
    4643
  • branches/collision_detection/src/lib/collision_detection/obb.h

    r5039 r5699  
    2121
    2222
    23   inline Vector* getAxis () const { return this->axis; }
     23  inline Vector getAxisX () const { return this->axis[0]; }
     24  inline Vector getAxisY () const { return this->axis[1]; }
     25  inline Vector getAxisZ () const { return this->axis[2]; }
     26
    2427  inline const float* getHalfLength() const { return this->halfLength; }
    2528
     
    3134
    3235 public:
    33   Vector*          axis;                       //!< Axes of oriented box [x,y,z]
    34   float*           halfLength;                 //!< Half lengths of the box along the axis
     36  Vector           axis[3];                    //!< Axes of oriented box [x,y,z]
     37  float            halfLength[3];              //!< Half lengths of the box along the axis
    3538  float            covarianceMatrix[3][3];     //!< the covariance matrix
    3639
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc

    r5694 r5699  
    5050  this->nodeRight = NULL;
    5151  this->bvElement = NULL;
     52  this->tmpVert1 = NULL;
     53  this->tmpVert2 = NULL;
    5254
    5355  if( OBBTreeNode::coMat == NULL)
     
    9395    delete this->bvElement;
    9496  this->bvElement = NULL;
     97
     98  if (this->tmpVert1 != NULL)
     99    delete this->tmpVert1;
     100  if (this->tmpVert2 != NULL)
     101    delete this->tmpVert2;
    95102}
    96103
     
    426433  vectors
    427434  */
    428   Vector*              axis = new Vector[3];                //!< the references to the obb axis
     435  Vector axis[3];                //!< the references to the obb axis
    429436
    430437  Matrix covMat(  box->covarianceMatrix  );
     
    454461  axis[1].normalize();
    455462  axis[2].normalize();*/
    456   box->axis = axis;
     463  box->axis[0] = axis[0];
     464  box->axis[1] = axis[1];
     465  box->axis[2] = axis[2];
    457466
    458467//   PRINTF(0)("-- Got Axis\n");
     
    476485  /* now get the axis length */
    477486  Line                ax[3];                                 //!< the axis
    478   float*              halfLength = new float[3];             //!< half length of the axis
     487  float               halfLength[3];                         //!< half length of the axis
    479488  float               tmpLength;                             //!< tmp save point for the length
    480   Plane               p0(box->axis[0], *box->center);       //!< the axis planes
     489  Plane               p0(box->axis[0], *box->center);        //!< the axis planes
    481490  Plane               p1(box->axis[1], *box->center);
    482491  Plane               p2(box->axis[2], *box->center);
     
    561570
    562571
    563   box->halfLength = halfLength;
     572  box->halfLength[0] = halfLength[0];
     573  box->halfLength[1] = halfLength[1];
     574  box->halfLength[2] = halfLength[2];
    564575  PRINTF(3)("-- Written Axis to obb\n");
    565576  PRINTF(3)("-- Finished Calculating Attributes\n");
     
    620631
    621632  PRINTF(3)("vertex index: %i, of %i\n", vertexIndex, box->numOfVertices);
    622   this->separationPlane = new Plane(box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
     633  this->separationPlane = Plane(box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
    623634  this->sepPlaneCenter = &box->vertices[vertexIndex];
    624635  this->longestAxisIndex = axisIndex;
     
    627638  {
    628639    if( i == vertexIndex) continue;
    629     tmpDist = this->separationPlane->distancePoint(box->vertices[i]);
     640    tmpDist = this->separationPlane.distancePoint(box->vertices[i]);
    630641    if( tmpDist > 0.0)
    631642      partition1.add(&box->vertices[i]); /* positive numbers plus zero */
     
    660671    element = iterator->nextElement();
    661672  }
    662 
     673  delete iterator;
    663674//   PRINTF(0)("\npartition 1:\n");
    664675//   for(int i = 0; i < partition1.getSize(); ++i)
     
    679690  }
    680691
     692  if (this->tmpVert1 != NULL)
     693    delete[] this->tmpVert1;
    681694  this->tmpVert1 = vertList1;
     695  if (this->tmpVert2 != NULL)
     696    delete[] this->tmpVert2;
    682697  this->tmpVert2 = vertList2;
    683698  this->tmpLen1 = partition1.getSize();
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.h

    r5693 r5699  
    6666    int                 depth;                      //!< the depth of the node in the tree
    6767    static OBBTree*     obbTree;                    //!< reference to the obb tree
    68     Plane*              separationPlane;            //!< the separation plane of the obb
     68    Plane               separationPlane;            //!< the separation plane of the obb
    6969    const sVec3D*       sepPlaneCenter;             //!< only needed to draw plane
    7070    int                 longestAxisIndex;           //!< only needed to draw plane
Note: See TracChangeset for help on using the changeset viewer.