Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5215 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Sep 22, 2005, 4:02:08 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: some more fixing of the Errors reported by valgrind
removed some stuff in patrick's collision-detection.
also changed Vector* to Vector in Rectangle (patrick tell me, if this is not ok - but i doubt it :))

Location:
trunk/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5214 r5215  
    438438 * use this to add a child to this node.
    439439 */
    440 void Element2D::addChild2D (Element2D* child, int parentingMod)
     440void Element2D::addChild2D (Element2D* child, int parentingMode)
    441441{
    442442  if( likely(child->parent != NULL))
     
    445445    child->parent->children->remove(child);
    446446  }
    447   child->parentMode = parentMode;
     447  if (parentingMode != E2D_PARENT_NONE)
     448    child->parentMode = parentingMode;
    448449  child->parent = this;
    449450  this->children->add(child);
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5211 r5215  
    4242typedef enum
    4343{
     44  E2D_PARENT_NONE               =   0,
    4445  E2D_PARENT_LOCAL_ROTATE       =   1,    //!< Rotates all the children around their centers.
    4546  E2D_PARENT_ROTATE_MOVEMENT    =   2,    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
     
    138139
    139140
    140     void addChild2D (Element2D* child, int parentingMode = E2D_DEFAULT_PARENTING_MODE);
     141    void addChild2D (Element2D* child, int parentingMode = E2D_PARENT_NONE);
    141142    void addChild2D (const char* childName);
    142143    void removeChild2D (Element2D* child);
  • trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r5075 r5215  
    5353  /* make an array with access to the leafs of the Quad-Tree */
    5454  this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
    55   int* index = new int; *index = 0;
     55  int index = 0; //new int; *index = 0; // !!changed by bensch!!
    5656  for(int i = 0; i < (int)pow(2, treeDepth); ++i)
    5757  {
    58     this->rootNode->buildHashTable(this->nodes, index);
     58    this->rootNode->buildHashTable(this->nodes, &index);
    5959  }
    6060  /* sort and revert the hash table to fit the right position */
     
    6565  this->quadLength = this->nodes[0]->getDimension()->getAxis() * 2.0f;
    6666  Rectangle* r = this->rootNode->getDimension();
    67   Vector* offset = new Vector();
    68   float xOff = r->getCenter()->x - r->getAxis();
    69   float yOff = r->getCenter()->z - r->getAxis();
     67  //  Vector* offset = new Vector(); // unused removed by bensch
     68  float xOff = r->getCenter().x - r->getAxis();
     69  float yOff = r->getCenter().z - r->getAxis();
    7070  this->offset = new Vector();
    7171  this->offset->x = xOff;
     
    136136      for( int k = j + 1; k < len; ++k)
    137137      {
    138         a = this->nodes[i * len + j]->getDimension()->getCenter()->z;
    139         b = this->nodes[i * len + k]->getDimension()->getCenter()->z;
     138        a = this->nodes[i * len + j]->getDimension()->getCenter().z;
     139        b = this->nodes[i * len + k]->getDimension()->getCenter().z;
    140140
    141141        if( b > a)
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r5115 r5215  
    5757    PRINT(3)(" |");
    5858  PRINT(3)(" | +-| (II) Rectangle Center (%5.2f, %5.2f), half axis length: %5.2f\n",
    59   this->pDimension->getCenter()->x, this->pDimension->getCenter()->z, this->pDimension->getAxis());
     59  this->pDimension->getCenter().x, this->pDimension->getCenter().z, this->pDimension->getAxis());
    6060
    6161  this->init();
     
    205205  tList<sTriangleExt*>*           listD = new tList<sTriangleExt*>();    //!< triangle list of nodeD
    206206  const float*                    pVert;                                 //!< pointer to the vertices
    207   const Vector*                   rectCenter;                            //!< vector to the center of the rect
     207  Vector                          rectCenter;                            //!< vector to the center of the rect
    208208
    209209  rectCenter = this->pDimension->getCenter();
     
    213213    {
    214214      pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
    215       if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
     215      if( pVert[0] > rectCenter.x + this->offset && pVert[2] > rectCenter.z + this->offset)
    216216        listA->add(&this->pTriangles[i]);
    217       if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
     217      if( pVert[0] < rectCenter.x + this->offset && pVert[2] > rectCenter.z + this->offset)
    218218        listB->add(&this->pTriangles[i]);
    219       if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
     219      if( pVert[0] < rectCenter.x + this->offset && pVert[2] < rectCenter.z + this->offset)
    220220        listC->add(&this->pTriangles[i]);
    221       if( pVert[0] > rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
     221      if( pVert[0] > rectCenter.x + this->offset && pVert[2] < rectCenter.z + this->offset)
    222222        listD->add(&this->pTriangles[i]);
    223223    }
     
    304304
    305305
    306   v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f;
     306  v.x = this->pDimension->getCenter().x + this->pDimension->getAxis() / 2.0f;
    307307  v.y = 0.0;
    308   v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
     308  v.z = this->pDimension->getCenter().z + this->pDimension->getAxis() / 2.0f;
    309309  rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    310   v.z = this->pDimension->getCenter()->z - this->pDimension->getAxis() / 2.0f;
     310  v.z = this->pDimension->getCenter().z - this->pDimension->getAxis() / 2.0f;
    311311  rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    312   v.x = this->pDimension->getCenter()->x - this->pDimension->getAxis() / 2.0f;
     312  v.x = this->pDimension->getCenter().x - this->pDimension->getAxis() / 2.0f;
    313313  rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    314   v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
     314  v.z = this->pDimension->getCenter().z + this->pDimension->getAxis() / 2.0f;
    315315  rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    316316
     
    371371  for( int i = 0; i < this->treeDepth; ++i)
    372372    PRINT(3)(" |");
    373   PRINT(3)(" | +-| (II) Rectangle Dimension  (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());
     373  PRINT(3)(" | +-| (II) Rectangle Dimension  (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter().x, rect->getCenter().z, rect->getAxis());
    374374  return rect;
    375375}
     
    383383bool QuadtreeNode::includesPoint(const Vector& v) const
    384384{
    385   Vector center = *this->pDimension->getCenter();
     385  Vector center = this->pDimension->getCenter();
    386386  float ax = this->pDimension->getAxis();
    387387
     
    492492  if( this->treeDepth == this->maxDepth)
    493493  {
    494     Vector t1 = *this->pDimension->getCenter();
     494    Vector t1 = this->pDimension->getCenter();
    495495    float ax = this->pDimension->getAxis();
    496496    float h = 50.0f;
     
    525525    return;
    526526
    527   Vector t1 = *this->pDimension->getCenter();
     527  Vector t1 = this->pDimension->getCenter();
    528528  float ax = this->pDimension->getAxis();
    529529  float h = 70.0f;
  • trunk/src/lib/graphics/text_engine.cc

    r5208 r5215  
    405405  // setting default values.
    406406  this->font = NULL;
    407   this->fontFile = NULL;
    408407  this->glyphArray = NULL;
    409408  this->fastTextureID = 0;
     
    446445bool Font::loadFont(const char* fontFile)
    447446{
    448   if (!this->fontFile)
     447  if (!this->getName())
    449448    {
    450449      this->setName(fontFile);
    451       this->fontFile = new char[strlen(fontFile)+1];
    452       strcpy(this->fontFile, fontFile);
    453 
    454       this->font = TTF_OpenFont(this->fontFile, this->fontSize);
     450
     451      this->font = TTF_OpenFont(this->getName(), this->fontSize);
    455452      if(!this->font)
    456453        {
  • trunk/src/lib/graphics/text_engine.h

    r5181 r5215  
    190190  // information about the Font
    191191  TTF_Font*     font;                //!< The font we use for this.
    192   char*         fontFile;            //!< The fontfile from whitch the font was loaded.
    193192  unsigned int  fontSize;            //!< The size of the font in pixels. each Font has one size.
    194193  int           renderStyle;         //!< The Renderstyle
  • trunk/src/lib/math/vector.h

    r5053 r5215  
    268268
    269269  public:
    270     Rectangle() { this->center = new Vector(); }
    271     Rectangle(const Vector &center, float len) { this->center = new Vector(center.x, center.y, center.z); this->axis[0] = len; this->axis[1] = len; }
     270    Rectangle() { this->center = Vector(); }
     271    Rectangle(const Vector &center, float len) { this->center = Vector(center.x, center.y, center.z); this->axis[0] = len; this->axis[1] = len; }
    272272    virtual ~Rectangle() {}
    273273
    274274    /** \brief sets the center of the rectangle to a defined vector @param center the new center */
    275    inline void setCenter(const Vector &center) { *this->center = center;}
     275   inline void setCenter(const Vector &center) { this->center = center;}
    276276    /** \brief sets the center of the rectangle to a defined vector @param x coord of the center @param y coord of the center @param z coord of the center */
    277    inline void setCenter(float x, float y, float z) { this->center->x = x; this->center->y = y; this->center->z = z; }
     277   inline void setCenter(float x, float y, float z) { this->center.x = x; this->center.y = y; this->center.z = z; }
    278278   /** \brief returns the center of the rectangle to a defined vector @returns center the new center */
    279    inline const Vector* getCenter() const { return this->center; }
     279   inline const Vector& getCenter() const { return this->center; }
    280280
    281281   /** \brief sets both axis of the rectangle to a defined vector @param unityLength the new center */
     
    287287
    288288  private:
    289     Vector*         center;
     289    Vector          center;
    290290    float           axis[2];
    291291};
  • trunk/src/lib/shell/shell_buffer.cc

    r5214 r5215  
    3737  this->lineCount = 0;
    3838  this->keepBufferArray[0] = '\0';
     39  this->bufferArray[0] = '\0';
    3940  this->keepBuffer = false;
    4041  this->buffer = new tList<char>;
     
    101102  this->buffer = new tList<char>;
    102103  this->bufferIterator = this->buffer->getIterator();
     104
    103105}
    104106
     
    165167    {
    166168//       newLineEnd = newLineBegin + strlen(newLineBegin);
    167       strcpy(this->keepBufferArray, newLineBegin);
     169      unsigned int len = strlen(newLineBegin);
     170      strncpy(this->keepBufferArray, newLineBegin, len);
     171      this->keepBufferArray[len] = '\0';
    168172      this->keepBuffer = true;
    169173      break;
Note: See TracChangeset for help on using the changeset viewer.