Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6142 in orxonox.OLD for trunk/src/story_entities/world.cc


Ignore:
Timestamp:
Dec 16, 2005, 7:13:57 PM (18 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ();
Note: See TracChangeset for help on using the changeset viewer.