Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 25, 2005, 12:40:36 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: PNode is now std::list-conform

Location:
trunk/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/null_parent.h

    r5039 r5770  
    1919
    2020  private:
    21     NullParent (const Vector& absCoordinate = Vector());
     21    NullParent (const Vector& absCoordinate = Vector(0.0, 0.0, 0.0));
    2222
    2323  private:
  • trunk/src/lib/coord/p_node.cc

    r5769 r5770  
    8585 *    then deletes the Element.
    8686 */
     87
     88#include "class_list.h"
    8789PNode::~PNode ()
    8890{
    8991  // remove the Node, delete it's children.
    90   tIterator<PNode>* iterator = this->children->getIterator();
    91   PNode* child = iterator->firstElement();
    92 
    93   while( child != NULL)
    94   {
    95     delete child;
    96     child = iterator->nextElement();
    97   }
    98   delete iterator;
    99 
     92  PNode* tmp;
     93  while (this->children.size() > 0)
     94  {
     95    tmp = this->children.front();
     96    this->children.pop_front();
     97      delete tmp;
     98  }
    10099  if (this->parent != NULL)
    101   {
    102     this->parent->children->remove(this);
    103     this->parent = NULL;
    104   }
    105   delete this->children;
     100   {
     101     this->parent->children.remove(this);
     102     this->parent = NULL;
     103   }
    106104
    107105  // remove all other allocated memory.
     
    121119  this->setClassID(CL_PARENT_NODE, "PNode");
    122120
    123   this->children = new tList<PNode>();
    124121  this->bRelCoorChanged = true;
    125122  this->bRelDirChanged = true;
     
    467464    {
    468465      PRINTF(5)("PNode::addChild() - reparenting node: removing it and adding it again\n");
    469       child->parent->children->remove(child);
     466      child->parent->children.remove(child);
    470467    }
    471468  child->parent = this;
    472469  if (unlikely(this != NULL))
    473     this->children->add(child);
     470    this->children.push_back(child);
    474471  child->parentCoorChanged();
    475472}
     
    509506void PNode::removeNode()
    510507{
    511   tIterator<PNode>* iterator = this->children->getIterator();
    512   PNode* pn = iterator->firstElement();
    513 
    514   while( pn != NULL)
    515   {
    516       NullParent::getInstance()->addChild(pn);
    517       pn = iterator->nextElement();
    518     }
    519   delete iterator;
     508  list<PNode*>::iterator child;
     509  for (child = this->children.begin(); child != this->children.end(); child ++)
     510    NullParent::getInstance()->addChild(*child);
     511
    520512  if (this->parent != NULL)
    521     this->parent->children->remove(this);
     513    this->parent->children.remove(this);
    522514}
    523515
     
    686678    }
    687679
    688     if(this->children->getSize() > 0)
     680    if(this->children.size() > 0)
    689681    {
    690       tIterator<PNode>* iterator = this->children->getIterator();
    691       PNode* pn = iterator->firstElement();
    692       while( pn != NULL)
     682      list<PNode*>::iterator child;
     683      for (child = this->children.begin(); child != this->children.end(); child ++)
    693684      {
    694685        /* if this node has changed, make sure, that all children are updated also */
    695686        if( likely(this->bRelCoorChanged))
    696           pn->parentCoorChanged ();
     687          (*child)->parentCoorChanged ();
    697688        if( likely(this->bRelDirChanged))
    698           pn->parentDirChanged ();
    699 
    700         pn->updateNode(dt);
    701         pn = iterator->nextElement();
     689          (*child)->parentDirChanged ();
     690
     691        (*child)->updateNode(dt);
    702692      }
    703       delete iterator;
    704693    }
    705694    this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
     
    712701{
    713702  nodes++;
    714   tIterator<PNode>* it = this->children->getIterator();
    715   PNode* node = it->firstElement();
    716   while(node != NULL)
    717   {
    718     node->countChildNodes(nodes);
    719     node = it->nextElement();
    720   }
    721 
     703  list<PNode*>::const_iterator child;
     704  for (child = this->children.begin(); child != this->children.end(); child ++)
     705    (*child)->countChildNodes(nodes);
    722706}
    723707
     
    733717  for (unsigned int i = 0; i < level; i++)
    734718    PRINT(0)(" |");
    735   if (this->children->getSize() > 0)
     719  if (this->children.size() > 0)
    736720    PRINT(0)(" +");
    737721  else
     
    757741  if (depth >= 2 || depth == 0)
    758742  {
    759     tIterator<PNode>* iterator = this->children->getIterator();
    760       //PNode* pn = this->children->enumerate ();
    761     PNode* pn = iterator->firstElement();
    762     while( pn != NULL)
     743    list<PNode*>::const_iterator child;
     744    for (child = this->children.begin(); child != this->children.end(); child ++)
    763745    {
    764746      if (depth == 0)
    765         pn->debugNode(0, level + 1);
     747        (*child)->debugNode(0, level + 1);
    766748      else
    767         pn->debugNode(depth - 1, level +1);
    768       pn = iterator->nextElement();
     749        (*child)->debugNode(depth - 1, level +1);
    769750    }
    770     delete iterator;
    771751  }
    772752}
     
    839819    /* rotate the current color in HSV space around 20 degree */
    840820    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
    841     tIterator<PNode>* iterator = this->children->getIterator();
    842     PNode* pn = iterator->firstElement();
    843     while( pn != NULL)
     821    list<PNode*>::const_iterator child;
     822    for (child = this->children.begin(); child != this->children.end(); child ++)
    844823    {
    845824      // drawing the Dependency graph
     
    852831                  this->getAbsCoor ().z);
    853832        glColor3f(childColor.x, childColor.y, childColor.z);
    854         glVertex3f(pn->getAbsCoor ().x,
    855                    pn->getAbsCoor ().y,
    856                    pn->getAbsCoor ().z);
     833        glVertex3f((*child)->getAbsCoor ().x,
     834                   (*child)->getAbsCoor ().y,
     835                   (*child)->getAbsCoor ().z);
    857836        glEnd();
    858837      }
    859838      /* if we want to draw the children too */
    860839      if (depth == 0) /* -> all of them */
    861         pn->debugDraw(0, size, childColor, level+1);
     840        (*child)->debugDraw(0, size, childColor, level+1);
    862841      else            /* -> only the Next one */
    863         pn->debugDraw(depth - 1, size, childColor, level +1);
    864       pn = iterator->nextElement();
     842        (*child)->debugDraw(depth - 1, size, childColor, level +1);
    865843    }
    866     delete iterator;
    867844  }
    868845  if (level == 0)
  • trunk/src/lib/coord/p_node.h

    r5769 r5770  
    2121#include "base_object.h"
    2222#include "vector.h"
     23#include <list>
    2324
    2425// FORWARD DECLARATION
     
    155156
    156157 private:
    157   bool            bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
    158   bool            bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     158  bool               bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
     159  bool               bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
    159160
    160   Vector          relCoordinate;      //!< coordinates relative to the parent
    161   Vector          absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
    162   Quaternion      relDirection;       //!< direction relative to the parent
    163   Quaternion      absDirection;       //!< absolute direvtion in the world ( from (0,0,1) )
     161  Vector             relCoordinate;      //!< coordinates relative to the parent
     162  Vector             absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
     163  Quaternion         relDirection;       //!< direction relative to the parent
     164  Quaternion         absDirection;       //!< absolute direvtion in the world ( from (0,0,1) )
    164165
    165   Vector          prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
    166   Vector          lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    167   Quaternion      prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    168 //  Quaternion      lastAbsDirection;
     166  Vector             prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
     167  Vector             lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
     168  Quaternion         prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
     169//  Quaternion         lastAbsDirection;
    169170
    170   Vector          velocity;           //!< Saves the velocity.
     171  Vector             velocity;           //!< Saves the velocity.
    171172
    172   Vector*         toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
    173   Quaternion*     toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
    174   float           bias;               //!< how fast to iterate to the given position (default is 1)
     173  Vector*            toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
     174  Quaternion*        toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
     175  float              bias;               //!< how fast to iterate to the given position (default is 1)
    175176
    176   PNode*          parent;             //!< a pointer to the parent node
    177   tList<PNode>*   children;           //!< list of the children of this PNode
     177  PNode*             parent;             //!< a pointer to the parent node
     178  std::list<PNode*>  children;           //!< list of the children of this PNode
    178179
    179   unsigned int    parentMode;         //!< the mode of the binding
     180  unsigned int       parentMode;         //!< the mode of the binding
    180181};
    181182
  • trunk/src/lib/lang/class_list.cc

    r5513 r5770  
    262262          enumBO = iterator->nextElement();
    263263        }
    264         delete iterator;
    265         break;
     264        if (likely(tmp->classID == classID))
     265        {
     266          delete iterator;
     267          break;
     268        }
    266269      }
    267270      tmp = tmp->next;
Note: See TracChangeset for help on using the changeset viewer.