Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5776 in orxonox.OLD for trunk/src/lib/physics


Ignore:
Timestamp:
Nov 25, 2005, 2:14:02 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: stl::list in PhysicsEngine

Location:
trunk/src/lib/physics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/physics/physics_engine.cc

    r5652 r5776  
    3434  this->setClassID(CL_PHYSICS_ENGINE, "PhysicsEngine");
    3535  this->setName("PhysicsEngine");
    36   this->connections = new tList<PhysicsConnection>;
    37   this->fields = new tList<Field>;
    3836  this->interfaces = NULL;
    3937}
     
    5149{
    5250  // delete all PhysicsConnections that are still in existence
    53   tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    54   PhysicsConnection* enumPC = itPC->firstElement();
    55   while (enumPC)
    56   {
    57     delete enumPC;
    58     enumPC = itPC->nextElement();
    59   }
    60   delete itPC;
    61   delete this->connections;
     51  list<PhysicsConnection*>::iterator pc;
     52  for (pc = this->connections.begin(); pc != this->connections.end(); pc++)
     53    delete (*pc);
    6254//
    6355//   // delete all PhysicsInterfaces, still in existence (this could be dangerous)
     
    8274//   }
    8375//   delete itF;
    84    delete this->fields;
    85 
    8676
    8777  PhysicsEngine::singletonRef = NULL;
     
    161151void PhysicsEngine::addField(Field* field)
    162152{
    163   this->fields->add(field);
     153  this->fields.push_back(field);
    164154}
    165155
     
    172162void PhysicsEngine::removeField(Field* field)
    173163{
    174   this->fields->remove(field);
     164  this->fields.remove(field);
    175165}
    176166
     
    181171Field* PhysicsEngine::getFieldByName(const char* FieldName) const
    182172{
    183   tIterator<Field>* tmpIt = fields->getIterator();
    184   Field* tmpField = tmpIt->firstElement();
    185   while(tmpField)
    186   {
    187     if (!strcmp(FieldName, tmpField->getName()))
    188     {
    189       delete tmpIt;
    190       return tmpField;
    191     }
    192     tmpField = tmpIt->nextElement();
    193   }
    194   delete tmpIt;
     173  list<Field*>::const_iterator field;
     174  for (field = this->fields.begin(); field != this->fields.end(); field++)
     175    if (!strcmp(FieldName, (*field)->getName()))
     176      return (*field);
    195177  return NULL;
    196178}
     
    206188void PhysicsEngine::addConnection(PhysicsConnection* connection)
    207189{
    208   this->connections->add(connection);
     190  this->connections.push_back(connection);
    209191}
    210192
     
    217199void PhysicsEngine::removeConnection(PhysicsConnection* connection)
    218200{
    219   this->connections->remove(connection);
     201  this->connections.remove(connection);
    220202}
    221203
     
    226208PhysicsConnection* PhysicsEngine::getPhysicsConnectionByName(const char* physicsConnectionName) const
    227209{
    228   tIterator<PhysicsConnection>* tmpIt = connections->getIterator();
    229   PhysicsConnection* tmpConn = tmpIt->firstElement();
    230   while(tmpConn)
    231   {
    232     if (!strcmp(physicsConnectionName, tmpConn->getName()))
    233     {
    234       delete tmpIt;
    235       return tmpConn;
    236     }
    237     tmpConn = tmpIt->nextElement();
    238   }
    239   delete tmpIt;
     210  list<PhysicsConnection*>::const_iterator pc;
     211  for (pc = this->connections.begin(); pc != this->connections.end(); pc++)
     212    if (!strcmp(physicsConnectionName, (*pc)->getName()))
     213      delete (*pc);
    240214  return NULL;
    241215}
     
    253227  /* go through all the PhysicsInterface(s) and tick them,
    254228  meaning let the fields work */
    255   tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    256   PhysicsConnection* enumPC = itPC->firstElement();
    257   while (enumPC)
    258     {
    259       enumPC->apply();
    260 
    261       enumPC = itPC->nextElement();
    262     }
    263   delete itPC;
     229  list<PhysicsConnection*>::iterator pc;
     230  for (pc = this->connections.begin(); pc != this->connections.end(); pc++)
     231    (*pc)->apply();
    264232
    265233  /* actually tick all the PhysicsInterfaces. Move the objects around */
     
    291259  if (this->interfaces != NULL)
    292260    PRINT(0)(" number of Interfaces: %d\n", this->interfaces->getSize());
    293   PRINT(0)(" number of Fields: %d\n", this->fields->getSize());
    294   PRINT(0)(" number of Connections: %d\n", this->connections->getSize());
     261  PRINT(0)(" number of Fields: %d\n", this->fields.size());
     262  PRINT(0)(" number of Connections: %d\n", this->connections.size());
    295263
    296264  PRINT(0)("==============================PHYS==\n");
  • trunk/src/lib/physics/physics_engine.h

    r5217 r5776  
    1313#include "physics_interface.h"
    1414#include "field.h"
     15#include <list>
     16
    1517
    1618// Forward Declaration
     
    5153  static PhysicsEngine*         singletonRef;         //!< the singleton reference of the PhysicsEngine
    5254
    53   tList<Field>*                 fields;               //!< a list of physicsl fields.
    54   tList<PhysicsConnection>*    connections;          //!< a list of physical connections.
     55  std::list<Field*>             fields;               //!< a list of physicsl fields.
     56  std::list<PhysicsConnection*> connections;          //!< a list of physical connections.
    5557  const tList<BaseObject>*      interfaces;           //!< The list of physical interfaces.
    5658};
Note: See TracChangeset for help on using the changeset viewer.