Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6142 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Dec 16, 2005, 7:13:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

Location:
trunk/src
Files:
2 deleted
44 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/debug.h

    r5996 r6142  
    110110#endif
    111111#ifndef NO_SHELL
    112 #define PRINT_EXEC       printf //ShellBuffer::addBufferLineStatic
     112#define PRINT_EXEC       ShellBuffer::addBufferLineStatic
    113113#else /* NO_SHELL */
    114114#define PRINT_EXEC       printf
  • trunk/src/lib/collision_detection/cd_engine.cc

    r6022 r6142  
    6565    be able to enhance iteration speed.
    6666 */
    67 void CDEngine::checkCollisions()
    68 {
    69   this->checkCollisionObjects();
     67//void CDEngine::checkCollisions()
     68//{
     69//  this->checkCollisionObjects();
    7070  //this->checkCollisionGround();
    71 }
    72 
    73 #include "class_list.h"
    74 #include "state.h"
     71//}
     72
    7573/**
    7674 *  this checks the collisions with the objects
    7775 */
    78 void CDEngine::checkCollisionObjects()
     76//void CDEngine::checkCollisionObjects()
     77//{
     78//   BVTree* tree;
     79//   tIterator<WorldEntity>* iterator1 = entityList->getIterator();
     80//   tIterator<WorldEntity>* iterator2 = entityList->getIterator();
     81//   WorldEntity* entity1 = iterator1->firstElement();
     82//   WorldEntity* entity2 = iterator2->iteratorElement(iterator1);
     83//   PRINTF(3)("checking for collisions\n");
     84//   while( entity1 != NULL)
     85//   {
     86//     if( likely(entity1 != this->terrain))
     87//     {
     88//       entity2 = iterator2->nextElement();
     89//
     90//       while( entity2 != NULL)
     91//       {
     92//         if( likely(entity2 != this->terrain))
     93//         {
     94//           PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());
     95//           tree = entity1->getOBBTree();
     96//           if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2);
     97//         }
     98//         entity2 = iterator2->nextElement();
     99//       }
     100//     }
     101//     entity1 = iterator1->nextElement();
     102//     entity2 = iterator2->iteratorElement(iterator1);
     103//     entity2 = iterator2->nextElement();
     104//   }
     105//   delete iterator1;
     106//   delete iterator2;
     107//}
     108
     109void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2)
    79110{
    80111  BVTree* tree;
    81   tIterator<WorldEntity>* iterator1 = entityList->getIterator();
    82   tIterator<WorldEntity>* iterator2 = entityList->getIterator();
    83   WorldEntity* entity1 = iterator1->firstElement();
    84   WorldEntity* entity2 = iterator2->iteratorElement(iterator1);
     112  std::list<WorldEntity*>::iterator entity1, entity2, pre1, pre2;
    85113  PRINTF(3)("checking for collisions\n");
    86   while( entity1 != NULL)
     114
     115  pre1 = list1.begin();
     116  while (pre1 != list1.end())
    87117  {
    88     if( likely(entity1 != this->terrain))
     118    entity1 = pre1++;
     119    if( likely((*entity1) != this->terrain))
    89120    {
    90       entity2 = iterator2->nextElement();
    91 
    92       while( entity2 != NULL)
     121      pre2 = list2.begin();
     122      while (pre2 != list2.end())
    93123      {
    94         if( likely(entity2 != this->terrain))
     124        entity2 = pre2++;
     125        if( likely((*entity2) != this->terrain))
    95126        {
    96           PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());
    97           tree = entity1->getOBBTree();
    98           if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2);
     127          PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName());
     128          tree = (*entity1)->getOBBTree();
     129          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) tree->collideWith(*entity1, *entity2);
    99130        }
    100         entity2 = iterator2->nextElement();
    101131      }
    102132    }
    103     entity1 = iterator1->nextElement();
    104     entity2 = iterator2->iteratorElement(iterator1);
    105     entity2 = iterator2->nextElement();
    106133  }
    107   delete iterator1;
    108   delete iterator2;
    109134}
    110135
     
    134159  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
    135160  //this->rootTree->drawBV(depth, drawMode);
    136 
    137   tIterator<WorldEntity>* iterator = entityList->getIterator();
     161  /// FIXME
     162/*  tIterator<WorldEntity>* iterator = entityList->getIterator();
    138163  WorldEntity* entity = iterator->firstElement();
    139164  while( entity != NULL)
     
    142167    entity = iterator->nextElement();
    143168  }
    144   delete iterator;
     169  delete iterator;*/
    145170}
    146171
  • trunk/src/lib/collision_detection/cd_engine.h

    r6022 r6142  
    1212#include "model.h"
    1313
     14#include <list>
    1415
    15 template<class T> class tList;
    1616class WorldEntity;
    1717class OBBTree;
     
    4949  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    5050
    51   inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; }
    5251  inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
    5352  //  inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/
     
    5554  void drawBV(int depth, int drawMode) const;
    5655
    57   void checkCollisions();
     56//  void checkCollisions();
     57  void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2);
    5858
    5959  void debug();
     
    7575 private:
    7676  int                     state;                            //!< the current state of the cd engine
    77   tList<WorldEntity>*     entityList;                       //!< pointer to the world entity list
    7877  OBBTree*                rootTree;                         //!< for testing purposes a root tree
    7978
  • trunk/src/lib/coord/p_node.cc

    r6078 r6142  
    8181    {
    8282      deleteNode = tmp;
    83       ++tmp;
     83      tmp++;
    8484//      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
    8585      if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
     
    470470              this->getClassName(), this->getName(), child->getClassName(), child->getName());
    471471    child->parent = NULL;
     472    child->parentCoorChanged();
    472473  }
    473474}
     
    536537    if (this->parentMode & PNODE_REPARENT_CHILDREN_ON_REMOVE ||
    537538        (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE)
    538     {      printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName());
     539    {
     540      printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName());
    539541      (*reparenter)->reparent();
    540542      printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassName(),(*reparenter)->getParent()->getName());
     
    542544  }
    543545  if (this->parent != NULL)
     546  {
    544547    this->parent->eraseChild(this);
     548    this->parent = NULL;
     549  }
    545550}
    546551
  • trunk/src/lib/coord/p_node.h

    r6078 r6142  
    7979
    8080  // ACTIVATION //
    81   inline void activateNode() { this->bActive = true; };
     81  inline void activateNode() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; };
    8282  inline void deactivateNode() { this->bActive = false; };
    8383  inline bool getNodeActiveState() { return this->bActive; };
  • trunk/src/lib/graphics/graphics_engine.cc

    r6011 r6142  
    1919#include "resource_manager.h"
    2020#include "event_handler.h"
     21
     22#include "world_entity.h"
    2123
    2224#include "render_2d.h"
     
    573575}
    574576
     577void GraphicsEngine::draw(const std::list<WorldEntity*>& drawList ) const
     578{
     579  std::list<WorldEntity*>::const_iterator entity;
     580  for (entity = drawList.begin(); entity != drawList.end(); entity++)
     581    if ((*entity)->isVisible())
     582      (*entity)->draw();
     583}
     584
     585
    575586/**
    576587 * displays the Frames per second
  • trunk/src/lib/graphics/graphics_engine.h

    r5857 r6142  
    1515#include "glincl.h"
    1616
     17#include <list>
     18
    1719// Forward Declaration
    1820class Text;
    1921class IniParser;
    2022class SubString;
     23class WorldEntity;
    2124
    2225//! class to handle graphics
     
    6669    void tick(float dt);
    6770    void draw() const;
     71    void draw(const std::list<WorldEntity*>& drawList) const;
    6872    void displayFPS(bool display);
    6973
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5944 r6142  
    1818#include "element_2d.h"
    1919#include "render_2d.h"
     20
     21#include <algorithm>
    2022
    2123#include "p_node.h"
     
    8284  if (this->parent != NULL)
    8385  {
    84     this->parent->children.remove(this);
     86    this->parent->eraseChild(this);
    8587    this->parent = NULL;
    8688  }
     
    512514  {
    513515    PRINTF(5)("Element2D::addChild() - reparenting node: removing it and adding it again\n");
    514     child->parent->children.remove(child);
     516    child->parent->eraseChild(child);
    515517  }
    516518  child->parent = this;
     
    581583  if (this->parent != NULL)
    582584  {
    583     this->parent->children.remove(this);
     585    this->parent->eraseChild(this);
    584586    this->parent = NULL;
    585587  }
     
    655657  if (parentNode != NULL)
    656658    this->setParentSoft2D(parentNode, bias);
     659}
     660
     661/** @param child the child to be erased from this Nodes List */
     662void Element2D::eraseChild(Element2D* child)
     663{
     664  std::list<Element2D*>::iterator childIT = std::find(this->children.begin(), this->children.end(), child);
     665  this->children.erase(childIT);
    657666}
    658667
     
    733742    else if (unlikely(this->bindNode != NULL))
    734743    {
    735       GLdouble projectPos[3];
     744      GLdouble projectPos[3] = {0, 0, 0};
    736745      gluProject(this->bindNode->getAbsCoor().x,
    737746                 this->bindNode->getAbsCoor().y,
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5775 r6142  
    195195
    196196  private:
     197    void eraseChild(Element2D* child);
    197198    /** tells the child that the parent's Coordinate has changed */
    198199    inline void parentCoorChanged () { this->bRelCoorChanged = true; }
  • trunk/src/lib/sound/sound_engine.cc

    r6076 r6142  
    141141    if (!this->ALSources.empty())
    142142    {
    143 
    144143      source = this->ALSources.top();
    145       printf("test: : %d\n", source);
    146144      this->ALSources.pop();
    147145    }
  • trunk/src/lib/sound/sound_source.cc

    r6139 r6142  
    6969    SoundEngine::getInstance()->popALSource(this->sourceID);
    7070
    71   //printf("%d\n",sourceID);
    7271  alSourceStop(this->sourceID);
    7372  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
  • trunk/src/orxonox.cc

    r6139 r6142  
    4343#include "text_engine.h"
    4444#include "event_handler.h"
    45 #include "garbage_collector.h"
    4645
    4746#include "factory.h"
     
    9695  // game-specific
    9796  delete GameLoader::getInstance();
    98   delete GarbageCollector::getInstance();
    9997
    10098  // class-less services/factories
  • trunk/src/story_entities/network_world.cc

    r6139 r6142  
    3838#include "shell.h"
    3939
    40 #include "garbage_collector.h"
    4140#include "fast_factory.h"
    4241#include "animation_player.h"
     
    123122  PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n");
    124123
    125 
    126   // here everything that is alocated by the NetworkWorld is deleted
    127   delete this->entities;
    128   State::setWorldEntityList(NULL);
    129 
    130124  delete this->localPlayer;
    131125
     
    141135  SoundEngine::getInstance()->flushAllSources();
    142136
    143 
     137  if (State::getObjectManager() == &this->objectManager)
     138    State::setObjectManager(NULL);
    144139  // erease everything that is left.
    145140  delete PNode::getNullParent();
     
    180175  this->music = NULL;
    181176  this->shell = NULL;
    182   this->entities = NULL;
    183177  this->localPlayer = NULL;
    184178  this->localCamera = NULL;
     
    214208ErrorMessage NetworkWorld::preLoad()
    215209{
    216   State::setWorldEntityList(this->entities = new tList<WorldEntity>());
     210  State::setObjectManager(&this->objectManager);
    217211  this->cycle = 0;
    218212
     
    233227
    234228  GraphicsEngine::getInstance()->displayFPS(true);
    235 
    236   CDEngine::getInstance()->setEntityList( this->entities);
    237229}
    238230
     
    630622
    631623/**
    632  *  gets the list of entities from the world
    633  * @returns entity list
    634 */
    635 tList<WorldEntity>* NetworkWorld::getEntities()
    636 {
    637   return this->entities;
    638 }
    639 
    640 
    641 /**
    642624 *  this returns the current game time
    643625 * @returns elapsed game time
     
    648630}
    649631
    650 
    651632/**
    652633 *  function to put your own debug stuff into it. it can display informations about
    653634   the current class/procedure
    654635*/
    655 void NetworkWorld::debug()
    656 {
    657   PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
    658   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    659   WorldEntity* entity = iterator->firstElement();
    660   while( entity != NULL)
    661   {
    662     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
    663     entity = iterator->nextElement();
    664   }
    665   delete iterator;
    666 }
     636// void NetworkWorld::debug()
     637// {
     638//   PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
     639//   tIterator<WorldEntity>* iterator = this->entities->getIterator();
     640//   WorldEntity* entity = iterator->firstElement();
     641//   while( entity != NULL)
     642//   {
     643//     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
     644//     entity = iterator->nextElement();
     645//   }
     646//   delete iterator;
     647// }
    667648
    668649
     
    682663    {
    683664      ++this->cycle;
    684       PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
     665//      PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
    685666      // Network
    686667      this->synchronize ();
     
    727708}
    728709
     710void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt)
     711{
     712  std::list<WorldEntity*>::iterator entity;
     713  for (entity = entityList.begin(); entity != entityList.end(); entity++)
     714    (*entity)->tick(dt);
     715
     716}
    729717
    730718/**
     
    763751      this->gameTime += this->dtS;
    764752
    765       tIterator<WorldEntity>* iterator = this->entities->getIterator();
    766       WorldEntity* entity = iterator->firstElement();
    767       while( entity != NULL)
    768         {
    769           entity->tick (this->dtS);
    770           entity = iterator->nextElement();
    771         }
    772       delete iterator;
     753/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
     754      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
     755      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
     756      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
     757      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
    773758
    774759      /* update tick the rest */
     
    780765
    781766      ParticleEngine::getInstance()->tick(this->dtS);
    782       GarbageCollector::getInstance()->tick(this->dtS);
    783767
    784768
     
    805789void NetworkWorld::update()
    806790{
    807   GarbageCollector::getInstance()->update();
    808791  GraphicsEngine::getInstance()->update(this->dtS);
    809792  PNode::getNullParent()->updateNode (this->dtS);
     
    816799void NetworkWorld::collide()
    817800{
    818   CDEngine::getInstance()->checkCollisions();
     801  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
     802                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
     803  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
     804                                            this->objectManager.getObjectList(OM_COMMON));
    819805}
    820806
     
    846832void NetworkWorld::draw ()
    847833{
    848   /* draw entities */
    849   WorldEntity* entity;
    850   glLoadIdentity();
    851   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    852   entity = iterator->firstElement();
    853   while( entity != NULL )
    854   {
    855     if( entity->isVisible() ) entity->draw();
    856     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
    857     entity = iterator->nextElement();
    858   }
    859   delete iterator;
     834  GraphicsEngine* engine = GraphicsEngine::getInstance();
     835  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
     836  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
     837  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
     838  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
     839  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
     840  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
     841
     842//   {
     843//     if( entity->isVisible() ) entity->draw();
     844  //FIXME
     845//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
     846//     entity = iterator->nextElement();
     847//   }
    860848
    861849  glCallList (objectList);
     
    866854    PNode::getNullParent()->debugDraw(0);
    867855
    868   GraphicsEngine::getInstance()->draw();
     856  engine->draw();
    869857  //TextEngine::getInstance()->draw();
    870858}
     
    876864void NetworkWorld::spawn(WorldEntity* entity)
    877865{
    878   this->entities->add (entity);
     866//   this->entities->add (entity);
    879867  entity->postSpawn ();
    880868}
     
    889877void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    890878{
    891   this->entities->add (entity);
     879//   this->entities->add (entity);
    892880
    893881  entity->setAbsCoor (*absCoor);
     
    915903      entity->setRelDir (*relDir);
    916904
    917       this->entities->add (entity);
     905//       this->entities->add (entity);
    918906
    919907      entity->postSpawn ();
  • trunk/src/story_entities/network_world.h

    r6139 r6142  
    1111#include "story_entity.h"
    1212#include "p_node.h"
     13#include "object_manager.h"
    1314
    1415class NetworkWorld;
     16
    1517class WorldEntity;
    1618class Camera;
     
    1820class GLMenuImageScreen;
    1921class Terrain;
    20 class GarbageCollector;
    21 class Text;
    2222class TiXmlElement;
    2323
    2424class Shell;
    2525class OggPlayer;
    26 template<class T> class tList;
    2726
    2827//! The game world
     
    6160  bool command (Command* cmd);
    6261
    63   tList<WorldEntity>* getEntities();
    64 
    6562  /* interface to world */
    6663  void spawn (WorldEntity* entity);
     
    8481  void synchronize ();
    8582  void handleInput ();
     83  void tick (std::list<WorldEntity*> worldEntity, float dt);
    8684  void tick ();
    8785  void update ();
     
    104102    bool bPause;                        //!< pause mode
    105103
     104    ObjectManager      objectManager;   //!< The ObjectManager of this World.
     105
    106106    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    107107
     
    118118
    119119    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    120     tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
     120
    121121    Player* localPlayer;                //!< The Player, you fly through the level.
    122122};
  • trunk/src/story_entities/world.cc

    r6074 r6142  
    3838#include "shell.h"
    3939
    40 #include "garbage_collector.h"
    4140#include "fast_factory.h"
    4241#include "animation_player.h"
     
    123122  PRINTF(3)("World::~World() - deleting current world\n");
    124123
    125 
    126   // here everything that is alocated by the World is deleted
    127   delete this->entities;
    128   State::setWorldEntityList(NULL);
    129 
    130124  delete this->localPlayer;
    131125
     
    141135  SoundEngine::getInstance()->flushAllSources();
    142136
    143 
     137  if (State::getObjectManager() == &this->objectManager)
     138    State::setObjectManager(NULL);
    144139  // erease everything that is left.
    145140  delete PNode::getNullParent();
     
    180175  this->music = NULL;
    181176  this->shell = NULL;
    182   this->entities = NULL;
    183177  this->localPlayer = NULL;
    184178  this->localCamera = NULL;
     
    214208ErrorMessage World::preLoad()
    215209{
    216   State::setWorldEntityList(this->entities = new tList<WorldEntity>());
     210  State::setObjectManager(&this->objectManager);
    217211  this->cycle = 0;
    218212
     
    233227
    234228  GraphicsEngine::getInstance()->displayFPS(true);
    235 
    236   CDEngine::getInstance()->setEntityList( this->entities);
    237229}
    238230
     
    588580
    589581/**
    590  *  gets the list of entities from the world
    591  * @returns entity list
    592 */
    593 tList<WorldEntity>* World::getEntities()
    594 {
    595   return this->entities;
    596 }
    597 
    598 
    599 /**
    600582 *  this returns the current game time
    601583 * @returns elapsed game time
     
    605587  return this->gameTime;
    606588}
    607 
    608 
    609 /**
    610  *  function to put your own debug stuff into it. it can display informations about
    611    the current class/procedure
    612 */
    613 void World::debug()
    614 {
    615   PRINTF(0)("Printing out the List of alive WorldEntities:\n");
    616   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    617   WorldEntity* entity = iterator->firstElement();
    618   while( entity != NULL)
    619   {
    620     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
    621     entity = iterator->nextElement();
    622   }
    623   delete iterator;
    624 }
    625 
    626589
    627590/**
     
    640603    {
    641604      ++this->cycle;
    642       PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
    643605      // Network
    644606      this->synchronize ();
     
    685647}
    686648
     649void World::tick(std::list<WorldEntity*> entityList, float dt)
     650{
     651  std::list<WorldEntity*>::iterator entity;
     652  for (entity = entityList.begin(); entity != entityList.end(); entity++)
     653    (*entity)->tick(dt);
     654
     655}
    687656
    688657/**
     
    721690      this->gameTime += this->dtS;
    722691
    723       tIterator<WorldEntity>* iterator = this->entities->getIterator();
    724       WorldEntity* entity = iterator->firstElement();
    725       while( entity != NULL)
    726         {
    727           entity->tick (this->dtS);
    728           entity = iterator->nextElement();
    729         }
    730       delete iterator;
     692/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
     693      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
     694      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
     695      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
     696      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
    731697
    732698      /* update tick the rest */
     
    738704
    739705      ParticleEngine::getInstance()->tick(this->dtS);
    740       GarbageCollector::getInstance()->tick(this->dtS);
    741706
    742707
     
    763728void World::update()
    764729{
    765   GarbageCollector::getInstance()->update();
    766730  GraphicsEngine::getInstance()->update(this->dtS);
    767731  PNode::getNullParent()->updateNode (this->dtS);
     
    774738void World::collide()
    775739{
    776   CDEngine::getInstance()->checkCollisions();
     740  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
     741                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
     742  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
     743                                            this->objectManager.getObjectList(OM_COMMON));
    777744}
    778745
     
    804771void World::draw ()
    805772{
    806   /* draw entities */
    807   WorldEntity* entity;
    808   glLoadIdentity();
    809   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    810   entity = iterator->firstElement();
    811   while( entity != NULL )
    812   {
    813     if( entity->isVisible() ) entity->draw();
    814     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
    815     entity = iterator->nextElement();
    816   }
    817   delete iterator;
     773  GraphicsEngine* engine = GraphicsEngine::getInstance();
     774  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
     775  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
     776  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
     777  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
     778  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
     779  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
     780
     781//   {
     782//     if( entity->isVisible() ) entity->draw();
     783  //FIXME
     784//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
     785//     entity = iterator->nextElement();
     786//   }
    818787
    819788  glCallList (objectList);
     
    824793    PNode::getNullParent()->debugDraw(0);
    825794
    826   GraphicsEngine::getInstance()->draw();
     795  engine->draw();
    827796  //TextEngine::getInstance()->draw();
    828797}
     
    834803void World::spawn(WorldEntity* entity)
    835804{
    836   this->entities->add (entity);
     805//   this->entities->add (entity);
    837806  entity->postSpawn ();
    838807}
     
    847816void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    848817{
    849   this->entities->add (entity);
     818//   this->entities->add (entity);
    850819
    851820  entity->setAbsCoor (*absCoor);
     
    873842      entity->setRelDir (*relDir);
    874843
    875       this->entities->add (entity);
     844//       this->entities->add (entity);
    876845
    877846      entity->postSpawn ();
  • trunk/src/story_entities/world.h

    r6048 r6142  
    1111#include "story_entity.h"
    1212#include "p_node.h"
     13#include "object_manager.h"
    1314
    14 class World;
     15
    1516class WorldEntity;
    1617class Camera;
     
    1819class GLMenuImageScreen;
    1920class Terrain;
    20 class GarbageCollector;
    21 class Text;
    2221class TiXmlElement;
    2322
    2423class Shell;
    2524class OggPlayer;
    26 template<class T> class tList;
    2725
    2826//! The game world
     
    6159  bool command (Command* cmd);
    6260
    63   tList<WorldEntity>* getEntities();
    64 
    6561  /* interface to world */
    6662  void spawn (WorldEntity* entity);
     
    8480  void synchronize ();
    8581  void handleInput ();
     82  void tick (std::list<WorldEntity*> worldEntity, float dt);
    8683  void tick ();
    8784  void update ();
     
    104101    bool bPause;                        //!< pause mode
    105102
     103    ObjectManager      objectManager;   //!< The ObjectManager of this World.
     104
    106105    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    107106
     
    118117
    119118    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    120     tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
     119
    121120    Player* localPlayer;                //!< The Player, you fly through the level.
    122121};
  • trunk/src/util/Makefile.am

    r5750 r6142  
    77                        object_manager.cc \
    88                        loading/factory.cc \
    9                         garbage_collector.cc \
    109                        state.cc \
    1110                        user_control.cc \
     
    1918                        track/pilot_node.cc \
    2019                        track/track_manager.cc \
    21                         track/track_node.cc 
     20                        track/track_node.cc
    2221
    2322noinst_HEADERS =        fast_factory.h \
    2423                        object_manager.h \
    25                         garbage_collector.h \
    2624                        state.h \
    2725                        user_control.h \
  • trunk/src/util/object_manager.cc

    r5828 r6142  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    1919#include "class_list.h"
    2020
    21 #include "p_node.h"
    2221#include "world_entity.h"
    23 #include "list.h"
     22
     23#include "shell_command.h"
     24
     25#include <assert.h>
    2426
    2527using namespace std;
    26 
    27 
    28 /**
    29  * standard constructor
     28SHELL_COMMAND(debug, ObjectManager, debug)
     29    ->defaultValues(2, NULL, 0);
     30
     31/**
     32 * @brief standard constructor
    3033 */
    3134ObjectManager::ObjectManager ()
     
    3740}
    3841
    39 /**
    40  *  the singleton reference to this class
    41  */
    42 ObjectManager* ObjectManager::singletonRef = NULL;
    43 
    44 /**
    45    @brief standard deconstructor
     42
     43/**
     44 * @brief standard deconstructor
     45 *
     46 * this also removes ALL entitites in existence.
    4647 */
    4748ObjectManager::~ObjectManager ()
    4849{
    49   ObjectManager::singletonRef = NULL;
    50 }
     50  this->flush();
     51}
     52
     53/**
     54 * @brief flushes all entities
     55 *
     56 * this function deletes all entities that exist within the ObjectManager.
     57 * It does this by poping each list from the front, and delete the given object.
     58 *
     59 * automatically called by a destructor.
     60 */
     61void ObjectManager::flush()
     62{
     63  for (unsigned int i = 0; i < OM_SIZE; ++i)
     64    while(!this->objectLists[i].empty())
     65      delete this->objectLists[i].front();
     66}
     67
     68
     69/**
     70 * @brief moves an Entity from an old list to a new One
     71 * @param entity the entity to move.
     72 * @param omList the new List to move the entity to.
     73 *
     74 * this will erase the entity from the old list
     75 */
     76void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
     77{
     78  assert (omList != OM_SIZE);
     79
     80  if (likely(entity->getOMListNumber() != OM_INIT))
     81    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
     82
     83  if (likely(omList != OM_INIT))
     84  {
     85    this->objectLists[omList].push_back(entity);
     86    entity->getEntityIterator() = --this->objectLists[omList].end();
     87    entity->getOMListNumber() = omList;
     88  }
     89}
     90
     91
     92/**
     93 * @see ObjectManager::toList(WorldEntity* OM_LIST)
     94 * @param entity the entity to move.
     95 * @param omList the new List to move the entity to.
     96 *
     97 * this function also does a transformation from omList as char* to OM_LIST.
     98 */
     99void ObjectManager::toList (WorldEntity* entity, const char* omList)
     100{
     101  this->toList(entity, ObjectManager::StringToOMList(omList));
     102}
     103
     104
    51105
    52106/**
     
    68122  return NULL;
    69123}
     124
     125
     126/**
     127 * @brief print out nice debug information about Elements in the list OM_LIST
     128 * @param omList the List to debug.
     129 * @param level: level 0: only show list info; level 1: also show entities and their names.
     130 */
     131void ObjectManager::debug(OM_LIST omList, unsigned int level) const
     132{
     133  if (omList != OM_INIT || omList == OM_SIZE)
     134  {
     135    PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList), this->objectLists[omList].size());
     136  //  if (level >= 1)
     137    {
     138      std::list<WorldEntity*>::const_iterator entity;
     139      for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
     140      {
     141        PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName());
     142      }
     143    }
     144  }
     145  else
     146    PRINTF(2)("Invalid query. for OM_INIT-LIST or OM_SIZE\n");
     147}
     148
     149
     150/**
     151 * @brief prints out very nice debug information
     152 * @param listName the Name of the list to get Debug information from
     153 * @param level: level 0: only show list info; level 1: also show entities and their names.
     154 */
     155void ObjectManager::debug(const char* listName, unsigned int level)
     156{
     157  PRINT(0)("=================================\n");
     158  PRINT(0)("=ObjectManager-DEBUG=============\n");
     159  PRINT(0)("=================================\n");
     160  if (listName == NULL || listName[0] == '\0')
     161    for (unsigned int i = 0; i < OM_SIZE; ++i)
     162      debug((OM_LIST) i, level);
     163  else
     164    debug(ObjectManager::StringToOMList(listName));
     165  PRINT(0)("=========================== OM ==\n");
     166}
     167
     168
     169
     170/**
     171 * @brief transforms an omList into a String (usefull for debugging).
     172 * @param omList the OM_LIST to be transformed into a String.
     173 * @returns the String transformed from omList.
     174 */
     175const char* ObjectManager::OMListToString(OM_LIST omList)
     176{
     177  if (omList == OM_INIT || omList == OM_SIZE)
     178    return "===invalid===";
     179
     180  printf("%d\n", omList);
     181  return ObjectManager::objectManagerListNames[omList];
     182}
     183
     184
     185
     186/**
     187 * @brief transforms a String into an OM_LIST (usefull for debugging/Loading).
     188 * @param listName the OM_LIST-name to be transformed into an OM_LIST.
     189 * @returns the OM_LIST transformed from listName. or the default, if not found or NULL.
     190 */
     191OM_LIST ObjectManager::StringToOMList(const char* listName)
     192{
     193  if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;
     194
     195  for(unsigned int i = 0; i < OM_SIZE; ++i) {
     196    if(!strcmp(listName, ObjectManager::objectManagerListNames[i])) {
     197      return (OM_LIST)i;
     198    }
     199  }
     200  return OM_DEFAULT_LIST;
     201}
     202
     203
     204
     205const char* ObjectManager::objectManagerListNames[] = {
     206    "null",
     207    "dead",
     208    "dead-tick",
     209    "environ-notick",
     210    "environ",
     211    "common",
     212
     213    "group00",
     214    "group00-proj",
     215    "group01",
     216    "group01-proj",
     217    "group02",
     218    "group02-proj",
     219    "group03",
     220    "group03-proj",
     221    "group04",
     222    "group04-proj",
     223    "group05",
     224    "group05-proj",
     225    "group06",
     226    "group06-proj",
     227    "group07",
     228    "group07-proj",
     229    "group08",
     230    "group08-proj",
     231    "group09",
     232    "group09-proj",
     233    "group10",
     234    "group10-proj",
     235    "group11",
     236    "group11-proj",
     237    "group12",
     238    "group12-proj",
     239    "group13",
     240    "group13-proj",
     241    "group14",
     242    "group14-proj",
     243    "group15",
     244    "group15-proj"
     245};
  • trunk/src/util/object_manager.h

    r5795 r6142  
    11/*!
    22 * @file object_manager.h
    3  * @brief Definition of the ... singleton Class
    4 */
     3 * @brief Definition of the ObjectManager.
     4 */
    55
    66#ifndef _OBJECT_MANAGER_H
     
    99#include "base_object.h"
    1010#include <list>
     11#include <vector>
     12
     13/// Enumerator for Managed Object Lists
     14typedef enum {
     15  OM_NULL             =  0,
     16  OM_DEAD,
     17  OM_DEAD_TICK,
     18  OM_ENVIRON_NOTICK,
     19  OM_ENVIRON,
     20  OM_COMMON,
     21
     22  OM_GROUP_00,
     23  OM_GROUP_00_PROJ,
     24  OM_GROUP_01,
     25  OM_GROUP_01_PROJ,
     26  OM_GROUP_02,
     27  OM_GROUP_02_PROJ,
     28  OM_GROUP_03,
     29  OM_GROUP_03_PROJ,
     30  OM_GROUP_04,
     31  OM_GROUP_04_PROJ,
     32  OM_GROUP_05,
     33  OM_GROUP_05_PROJ,
     34  OM_GROUP_06,
     35  OM_GROUP_06_PROJ,
     36  OM_GROUP_07,
     37  OM_GROUP_07_PROJ,
     38  OM_GROUP_08,
     39  OM_GROUP_08_PROJ,
     40  OM_GROUP_09,
     41  OM_GROUP_09_PROJ,
     42  OM_GROUP_10,
     43  OM_GROUP_10_PROJ,
     44  OM_GROUP_11,
     45  OM_GROUP_11_PROJ,
     46  OM_GROUP_12,
     47  OM_GROUP_12_PROJ,
     48  OM_GROUP_13,
     49  OM_GROUP_13_PROJ,
     50  OM_GROUP_14,
     51  OM_GROUP_14_PROJ,
     52  OM_GROUP_15,
     53  OM_GROUP_15_PROJ,
     54
     55  OM_SIZE,
     56
     57
     58  OM_INIT             = -1, //!< DO NOT USE THIS. (WorldEntity Internal).
     59} OM_LIST;
     60
     61#define OM_DEFAULT_LIST  OM_NULL
     62
    1163
    1264// FORWARD DECLARATION
     
    1466class WorldEntity;
    1567
    16 class ObjectGroupList
    17 {
    18 
    19 
    20 
    21 };
    22 
    23 
    24 //! A default singleton class.
     68//! A powerfull handler for the Object (WorldEntities) in the World.
    2569class ObjectManager : public BaseObject {
    2670
    2771 public:
    28   virtual ~ObjectManager(void);
    29   /** @returns a Pointer to the only object of this Class */
    30   inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; };
     72   ObjectManager();
     73   virtual ~ObjectManager();
    3174
     75  void flush();
     76
     77  void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST);
     78  void toList (WorldEntity* entity, const char* omList);
     79
     80
     81  std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) { return this->objectLists[listNumber]; }
     82  const std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; }
    3283
    3384  static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID);
    3485
    35   ObjectGroupList* getGroupList( );
     86  void debug(OM_LIST omList, unsigned int level = 0) const;
     87  void debug(const char* listName = NULL, unsigned int level = 0);
     88
     89  static OM_LIST StringToOMList(const char* listName);
     90  static const char* OMListToString(OM_LIST omList);
    3691
    3792 private:
    38   ObjectManager(void);
    39   static ObjectManager* singletonRef;
    40 
    41   std::list<ObjectGroupList>           groupList;
    42 
    43   const std::list<BaseObject>*         pNodeList;
     93  const std::list<BaseObject>*            pNodeList;
    4494
    4595
     96  std::list<WorldEntity*>                 objectLists[OM_SIZE];
     97
     98  static const char*                      objectManagerListNames[]; //!< Names of all the lists
    4699};
    47100
  • trunk/src/util/state.cc

    r4836 r6142  
    2929const PNode* State::cameraTarget = NULL;
    3030
    31 tList<WorldEntity>* State::worldEntityList = NULL;
     31ObjectManager* State::objectManager = NULL;
    3232
    3333/**
  • trunk/src/util/state.h

    r5405 r6142  
    1010class PNode;
    1111class WorldEntity;
    12 template<class T> class tList;
    13 //template<class T> class tStack;
     12class ObjectManager;
    1413
    1514//! handles states about orxonox's most importatn objects
     
    2221
    2322 public:
    24   // CAMERA //
     23   //////////////
     24   /// CAMERA ///
     25   //////////////
    2526  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
    2627  static void setCamera(const PNode* camera, const PNode* cameraTarget);
     
    3031  static inline const PNode* getCameraTarget() { return State::cameraTarget; };
    3132
    32   // WORLD_ENTITY_LIST //
    33   /** @param worldEntityList The World's List of WorldEntities */
    34   static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; };
    35   /** @returns the List of WorldEntities */
    36   static inline tList<WorldEntity>* getWorldEntityList() { return State::worldEntityList; };
     33  //////////////////////
     34  /// OBJECT-MANAGER ///
     35  //////////////////////
     36  /** @param objectManager the new Current ObjectManager */
     37  static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; };
     38  /** @returns the current ObjectManager. */
     39  static inline ObjectManager* getObjectManager() { return State::objectManager; };
     40
     41  /////////////////////////
     42  /// WORLD_ENTITY_LIST ///
     43  /////////////////////////
    3744
    3845 private:
     
    4249  static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
    4350  static PNode*                 nullParent;         //!< A reference to the Null-PNode.
     51  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
    4452
    45   static tList<WorldEntity>*    worldEntityList;    //!< The List of the worldEntities
    46 
    47   //tStack<
    4853};
    4954
  • trunk/src/world_entities/environment.cc

    r5994 r6142  
    6262{
    6363  this->setClassID(CL_ENVIRONMENT, "Environment");
     64  this->toList(OM_ENVIRON);
    6465}
    6566
  • trunk/src/world_entities/npcs/npc.cc

    r6054 r6142  
    3333{
    3434  this->setClassID(CL_NPC, "NPC");
    35 
     35  this->toList(OM_GROUP_00);
    3636}
    3737
     
    5050      WorldEntity* powerUp = new TurretPowerUp();
    5151      powerUp->setAbsCoor(this->getAbsCoor());
    52       State::getWorldEntityList()->add(powerUp);
     52//      powerUp->toList(OM_COMMON);
    5353    }
    5454    else if ((float)rand()/RAND_MAX < .3)
     
    5656      WorldEntity* powerUp = new LaserPowerUp();
    5757      powerUp->setAbsCoor(this->getAbsCoor());
    58       State::getWorldEntityList()->add(powerUp);
     58      powerUp->toList(OM_COMMON);
    5959    }
    60     State::getWorldEntityList()->remove(this);
     60    this->toList(OM_DEAD);
    6161    this->removeNode();
    6262
     
    6868  {
    6969    this->setVisibiliy(false);
    70     State::getWorldEntityList()->remove(this);
     70    this->toList(OM_DEAD);
    7171    this->removeNode();
    7272  }
  • trunk/src/world_entities/playable.cc

    r5915 r6142  
    4646  PRINTF(4)("PLAYABLE INIT\n");
    4747
     48  this->toList(OM_GROUP_01);
    4849  this->weaponMan = new WeaponManager(this);
    4950
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r6113 r6142  
    8080 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    8181 if (entity->isA(CL_PLAYABLE))
    82   State::getWorldEntityList()->remove(this);
     82  this->toList(OM_DEAD);
    8383}
    8484
  • trunk/src/world_entities/power_ups/power_up.cc

    r6113 r6142  
    3838{
    3939  delete this->sphereMaterial;
     40  this->toList(OM_COMMON);
    4041}
    4142
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6113 r6142  
    8080 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    8181 if (entity->isA(CL_PLAYABLE))
    82   State::getWorldEntityList()->remove(this);
     82   this->toList(OM_DEAD);
    8383}
    8484
  • trunk/src/world_entities/skybox.cc

    r6022 r6142  
    6565{
    6666  this->setClassID(CL_SKYBOX, "SkyBox");
    67 
     67  this->toList(OM_ENVIRON_NOTICK);
    6868  this->size = 100.0;
    6969
  • trunk/src/world_entities/skysphere.cc

    r5511 r6142  
    4242{
    4343  this->setClassID(CL_SKYSPHERE, "SkySphere");
    44 
     44  this->toList(OM_ENVIRON_NOTICK);
    4545  if (fileName == NULL)
    4646    this->initialize("pictures/sky-replace.jpg");
  • trunk/src/world_entities/terrain.cc

    r6022 r6142  
    9393{
    9494  this->setClassID(CL_TERRAIN, "Terrain");
     95  this->toList(OM_ENVIRON_NOTICK);
    9596
    9697  this->objectList = 0;
  • trunk/src/world_entities/test_entity.cc

    r5994 r6142  
    3333{
    3434  this->setClassID(CL_TEST_ENTITY, "TestEntity");
     35  // TO SOME LIST!!
    3536
    3637  this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");
     
    7071    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    7172  this->setVisibiliy(false);
    72   State::getWorldEntityList()->remove(this);
     73  this->toList(OM_DEAD);
    7374  }
    7475}
  • trunk/src/world_entities/weapons/aim.cc

    r6078 r6142  
    104104void Aim::searchTarget(float range)
    105105{
    106   tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator();
     106  //FIXME//
     107/*  tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator();
    107108  WorldEntity* entity = iterator->firstElement();
    108109  while (likely(entity != NULL))
     
    121122  }
    122123
    123   delete iterator;
     124  delete iterator;*/
    124125}
    125126
  • trunk/src/world_entities/weapons/bomb.cc

    r5994 r6142  
    174174void Bomb::activate()
    175175{
    176   State::getWorldEntityList()->add(this);
    177176
    178177}
     
    180179void Bomb::deactivate()
    181180{
    182   State::getWorldEntityList()->remove(this);
     181  this->toList(OM_DEAD);
    183182  this->lifeCycle = 0.0f;
    184183  Bomb::fastFactory->kill(this);
  • trunk/src/world_entities/weapons/ground_turret.cc

    r5994 r6142  
    8989  {
    9090    this->left->setParent(this);
     91    this->left->toList(this->getOMListNumber());
    9192    this->left->setRelCoor(0,10,-5);
    9293  }
     
    9899  {
    99100    this->right->setParent(this);
     101    this->right->toList(this->getOMListNumber());
    100102    this->right->setRelCoor(0,10,5);
    101103  }
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6078 r6142  
    8585void GuidedMissile::activate()
    8686{
    87   State::getWorldEntityList()->add(this);
    8887  if (unlikely(GuidedMissile::trailParticles == NULL))
    8988  {
     
    129128  this->lifeCycle = 0.0;
    130129
    131 //  GarbageCollector::getInstance()->collect(this);
    132   State::getWorldEntityList()->remove(this);
     130  this->toList(OM_DEAD);
    133131  this->removeNode();
    134132  GuidedMissile::fastFactory->kill(this);
     
    152150  if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    153151   {
    154      printf("========%s::%s\n", target->getParent()->getClassName(), target->getParent()->getName() );
    155152     velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
    156153     float speed = velocity.len();
  • trunk/src/world_entities/weapons/laser.cc

    r6056 r6142  
    7777void Laser::activate()
    7878{
    79   State::getWorldEntityList()->add(this);
    8079  if (unlikely(Laser::explosionParticles == NULL))
    8180  {
     
    9897  this->lifeCycle = 0.0;
    9998
    100 //  GarbageCollector::getInstance()->collect(this);
    101   State::getWorldEntityList()->remove(this);
     99  this->toList(OM_NULL);
    102100  this->removeNode();
    103101  Laser::fastFactory->kill(this);
     
    134132  this->lifeCycle = .95; //!< @todo calculate this usefully.
    135133  ParticleEngine::getInstance()->addConnection(this->emitter, Laser::explosionParticles);
    136 
    137134}
    138135
  • trunk/src/world_entities/weapons/projectile.cc

    r6078 r6142  
    2222#include "weapon.h"
    2323#include "model.h"
    24 
    25 #include "garbage_collector.h"
    2624
    2725using namespace std;
  • trunk/src/world_entities/weapons/rocket.cc

    r6056 r6142  
    8282void Rocket::activate()
    8383{
    84   State::getWorldEntityList()->add(this);
    8584  if (unlikely(Rocket::trailParticles == NULL))
    8685  {
     
    125124  ParticleEngine::getInstance()->breakConnections(this->emitter);
    126125  this->lifeCycle = 0.0;
     126  this->toList(OM_NULL);
    127127
    128128//  GarbageCollector::getInstance()->collect(this);
    129   State::getWorldEntityList()->remove(this);
     129  this->toList(OM_DEAD);
    130130  Rocket::fastFactory->kill(this);
    131131}
  • trunk/src/world_entities/weapons/test_bullet.cc

    r5994 r6142  
    8282void TestBullet::activate()
    8383{
    84   State::getWorldEntityList()->add(this);
    8584  if (unlikely(TestBullet::trailParticles == NULL))
    8685  {
     
    119118  ParticleEngine::getInstance()->breakConnections(this->emitter);
    120119  this->lifeCycle = 0.0;
     120  this->toList(OM_NULL);
    121121
    122 //  GarbageCollector::getInstance()->collect(this);
    123   State::getWorldEntityList()->remove(this);
    124122  TestBullet::fastFactory->kill(this);
    125123}
  • trunk/src/world_entities/weapons/weapon.cc

    r6054 r6142  
    192192{
    193193  if (likely (this->projectileFactory != NULL))
    194     return dynamic_cast<Projectile*>(this->projectileFactory->resurrect());
     194  {
     195    Projectile* pj = dynamic_cast<Projectile*>(this->projectileFactory->resurrect());
     196    pj->toList((OM_LIST)(this->getOMListNumber()+1));
     197    return pj;
     198  }
    195199  else
    196200  {
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6074 r6142  
    3535 * @param number of weapon slots of the model/ship <= 8 (limitied)
    3636 */
    37 WeaponManager::WeaponManager(PNode* parent)
     37WeaponManager::WeaponManager(WorldEntity* parent)
    3838{
    3939  this->init();
     
    155155 * a PNode.
    156156 */
    157 void WeaponManager::setParent(PNode* parent)
    158 {
    159   if (parent == NULL)
    160     parent = PNode::getNullParent();
     157void WeaponManager::setParent(WorldEntity* parent)
     158{
    161159  this->parent = parent;
    162160  if (this->parent != NULL)
     
    247245  this->configs[configID][slotID] = weapon;
    248246  if (this->parent != NULL)
    249     weapon->setParent(parent);
     247  {
     248    this->parent->addChild(weapon);
     249  }
    250250  PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID);
    251251}
     
    373373      else
    374374      {
     375        if (this->currentSlotConfig[i].currentWeapon != NULL)
     376          this->currentSlotConfig[i].currentWeapon->toList(OM_NULL);
    375377        tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon;
    376378        if (tickWeapon != NULL)
     
    378380          tickWeapon->requestAction(WA_ACTIVATE);
    379381          tickWeapon->setParent(&this->currentSlotConfig[i].position);
     382          tickWeapon->toList(this->parent->getOMListNumber());
    380383          this->currentSlotConfig[i].position.activateNode();
    381384        }
  • trunk/src/world_entities/weapons/weapon_manager.h

    r6055 r6142  
    4545
    4646  public:
    47     WeaponManager(PNode* parent);
     47    WeaponManager(WorldEntity* parent);
    4848    WeaponManager(const TiXmlElement* root);
    4949    ~WeaponManager();
     
    6363    long getSlotCapability(int slot) const { return this->currentSlotConfig[slot].capability; };
    6464
    65     void setParent(PNode* parent);
     65    void setParent(WorldEntity* parent);
    6666    /** @returns the Parent (carrier) of this WeaponManager */
    6767    PNode* getParent() const { return this->parent; };
     
    9393
    9494  private:
    95     PNode*                  parent;                                   //!< The parent, this WeaponManager is connected to.
     95    WorldEntity*            parent;                                   //!< The parent, this WeaponManager is connected to.
    9696
    9797    int                     slotCount;                                //!< number of weapon slots the ship has.
  • trunk/src/world_entities/world_entity.cc

    r6005 r6142  
    5353
    5454  this->setVisibiliy(true);
     55
     56  this->objectListNumber = OM_INIT;
     57  this->objectListIterator = NULL;
     58
     59  this->toList(OM_NULL);
    5560}
    5661
     
    6772  for (unsigned int i = 0; i < this->models.size(); i++)
    6873    this->setModel(NULL, i);
     74
     75  State::getObjectManager()->toList(this, OM_INIT);
    6976}
    7077
     
    95102{
    96103  if (fileName != NULL)
    97   { 
     104  {
    98105    // search for the special character # in the LoadParam
    99106    if (strchr(fileName, '#') != NULL)
    100107      {
    101         PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
    102         char* lodFile = new char[strlen(fileName)+1];
    103         strcpy(lodFile, fileName);
    104         char* depth = strchr(lodFile, '#');
    105         for (unsigned int i = 0; i < 5; i++)
    106           {
    107             *depth = 48+(int)i;
    108             printf("-------%s\n", lodFile);
    109             if (ResourceManager::isInDataDir(lodFile))
    110               this->loadModel(lodFile, scaling, i);
    111           }
    112         return;
     108        PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
     109        char* lodFile = new char[strlen(fileName)+1];
     110        strcpy(lodFile, fileName);
     111        char* depth = strchr(lodFile, '#');
     112        for (unsigned int i = 0; i < 5; i++)
     113          {
     114            *depth = 48+(int)i;
     115            printf("-------%s\n", lodFile);
     116            if (ResourceManager::isInDataDir(lodFile))
     117              this->loadModel(lodFile, scaling, i);
     118          }
     119        return;
    113120      }
    114121
     
    174181  }
    175182}
     183
     184/**
     185 * @brief moves this entity to the List OM_List
     186 * @param list the list to set this Entity to.
     187 *
     188 * this is the same as a call to State::getObjectManager()->toList(entity , list);
     189 * directly, but with an easier interface.
     190 *
     191 * @todo inline this (peut etre)
     192 */
     193void WorldEntity::toList(OM_LIST list)
     194{
     195  State::getObjectManager()->toList(this, list);
     196}
     197
    176198
    177199
  • trunk/src/world_entities/world_entity.h

    r6005 r6142  
    1111#include "model.h"
    1212
     13#include "object_manager.h"
    1314#include "glincl.h"
    1415#include <vector>
     
    6566  //  CharacterAttributes* getCharacterAttributes();
    6667
     68  void toList(OM_LIST list);
    6769
     70  /** @returns a Reference to the objectListNumber to set. */
     71  OM_LIST& getOMListNumber() { return this->objectListNumber; }
     72  /** @returns a Reference to the Iterator */
     73  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
    6874 protected:
    6975  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    7076
    7177 private:
    72   std::vector<Model*>     models;            //!< The model that should be loaded for this entity.
    73   BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
     78  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     79  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
    7480
    75   bool                    bCollide;         //!< If it should be considered for the collisiontest.
    76   bool                    bVisible;         //!< If it should be visible.
     81  bool                    bCollide;           //!< If it should be considered for the collisiontest.
     82  bool                    bVisible;           //!< If it should be visible.
     83
     84  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
     85  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
     86
    7787};
    7888
Note: See TracChangeset for help on using the changeset viewer.