Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3646 in orxonox.OLD


Ignore:
Timestamp:
Mar 23, 2005, 5:43:07 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented garbage collector, is not yet collecting, i have to update the list.h first.

Location:
orxonox/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r3618 r3646  
    3535                 track_node.cc \
    3636                 simple_animation.cc \
     37                 garbage_collector.cc \
    3738                 story_entities/story_entity.cc \
    3839                 story_entities/campaign.cc \
     
    8182                 track_node.h \
    8283                 simple_animation.h \
     84                 garbage_collector.h \
    8385                 story_entities/story_entity.h \
    8486                 story_entities/story_def.h \
  • orxonox/trunk/src/Makefile.in

    r3618 r3646  
    5656        command_node.$(OBJEXT) keynames.$(OBJEXT) camera.$(OBJEXT) \
    5757        track_manager.$(OBJEXT) track_node.$(OBJEXT) \
    58         simple_animation.$(OBJEXT) story_entity.$(OBJEXT) \
    59         campaign.$(OBJEXT) world.$(OBJEXT) world_entity.$(OBJEXT) \
    60         player.$(OBJEXT) environment.$(OBJEXT) skysphere.$(OBJEXT) \
    61         terrain.$(OBJEXT) primitive.$(OBJEXT) weapon.$(OBJEXT) \
    62         projectile.$(OBJEXT) character_attributes.$(OBJEXT) \
    63         test_gun.$(OBJEXT) ai.$(OBJEXT) p_node.$(OBJEXT) \
    64         null_parent.$(OBJEXT) helper_parent.$(OBJEXT) \
     58        simple_animation.$(OBJEXT) garbage_collector.$(OBJEXT) \
     59        story_entity.$(OBJEXT) campaign.$(OBJEXT) world.$(OBJEXT) \
     60        world_entity.$(OBJEXT) player.$(OBJEXT) environment.$(OBJEXT) \
     61        skysphere.$(OBJEXT) terrain.$(OBJEXT) primitive.$(OBJEXT) \
     62        weapon.$(OBJEXT) projectile.$(OBJEXT) \
     63        character_attributes.$(OBJEXT) test_gun.$(OBJEXT) ai.$(OBJEXT) \
     64        p_node.$(OBJEXT) null_parent.$(OBJEXT) helper_parent.$(OBJEXT) \
    6565        data_tank.$(OBJEXT) graphics_engine.$(OBJEXT) light.$(OBJEXT) \
    6666        fontset.$(OBJEXT) array.$(OBJEXT) objModel.$(OBJEXT) \
     
    8383@AMDEP_TRUE@    ./$(DEPDIR)/environment.Po ./$(DEPDIR)/fontset.Po \
    8484@AMDEP_TRUE@    ./$(DEPDIR)/game_loader.Po \
     85@AMDEP_TRUE@    ./$(DEPDIR)/garbage_collector.Po \
    8586@AMDEP_TRUE@    ./$(DEPDIR)/glmenu_imagescreen.Po \
    8687@AMDEP_TRUE@    ./$(DEPDIR)/graphics_engine.Po \
     
    238239                 track_node.cc \
    239240                 simple_animation.cc \
     241                 garbage_collector.cc \
    240242                 story_entities/story_entity.cc \
    241243                 story_entities/campaign.cc \
     
    284286                 track_node.h \
    285287                 simple_animation.h \
     288                 garbage_collector.h \
    286289                 story_entities/story_entity.h \
    287290                 story_entities/story_def.h \
     
    410413@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontset.Po@am__quote@
    411414@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game_loader.Po@am__quote@
     415@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/garbage_collector.Po@am__quote@
    412416@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glmenu_imagescreen.Po@am__quote@
    413417@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graphics_engine.Po@am__quote@
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3644 r3646  
    354354{
    355355  pNode->remove();
    356   this->children->remove (pNode);
     356  //this->children->remove (pNode);
    357357  pNode->parent = NULL;
    358358}
  • orxonox/trunk/src/lib/lang/base_object.cc

    r3607 r3646  
    3030{
    3131  this->className = NULL;
     32  this->finalized = false;
    3233}
    3334
     
    5859  return true;
    5960}
     61
     62
     63bool BaseObject::isFinalized()
     64{
     65  return this->finalized;
     66}
     67
     68
     69void BaseObject::finalize()
     70{
     71  this->finalized = true;
     72}
  • orxonox/trunk/src/lib/lang/base_object.h

    r3609 r3646  
    2121  bool isA (char* className);
    2222
     23  bool isFinalized();
     24  void finalize();
     25
    2326 private:
    2427  char* className;
    25 
     28  bool finalized;
    2629};
    2730
  • orxonox/trunk/src/story_entities/world.cc

    r3644 r3646  
    2626#include "track_node.h"
    2727#include "world_entity.h"
    28 #include "track_manager.h"
    2928#include "player.h"
    3029#include "camera.h"
     
    3534#include "light.h"
    3635
     36#include "track_manager.h"
     37#include "garbage_collector.h"
     38
    3739#include "command_node.h"
    3840#include "glmenu_imagescreen.h"
     
    182184  WorldInterface* wi = WorldInterface::getInstance();
    183185  wi->init(this);
     186  this->garbageCollector = GarbageCollector::getInstance();
    184187}
    185188
     
    506509{
    507510  return this->entities;
     511}
     512
     513
     514/**
     515   \brief this returns the current game time
     516   \returns elapsed game time
     517*/
     518double World::getGameTime()
     519{
     520  return this->gameTime;
    508521}
    509522
     
    721734      this->dt = currentFrame - this->lastFrame;
    722735     
    723       if(dt > 0)
     736      if( this->dt > 0)
    724737        {
    725738          float fps = 1000/dt;
     
    733746          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
    734747          SDL_Delay(10);
    735           dt = 10;
     748          this->dt = 10;
    736749        }
    737750      //this->timeSlice (dt);
     
    739752      /* function to let all entities tick (iterate through list) */
    740753      WorldEntity* entity;
    741       float seconds = dt / 1000.0;     
     754      float seconds = this->dt / 1000.0;     
     755      this->gameTime += seconds;
    742756      entity = entities->enumerate();
    743757      while( entity != NULL)
     
    749763     
    750764      /* update tick the rest */
    751       this->trackManager->tick(dt);
    752       this->localCamera->tick(dt);
     765      this->trackManager->tick(this->dt);
     766      this->localCamera->tick(this->dt);
     767      this->garbageCollector->tick(seconds);
    753768    }
    754769  this->lastFrame = currentFrame;
     
    764779void World::update()
    765780{
     781  this->garbageCollector->update();
    766782  this->nullParent->update (dt);
    767783}
  • orxonox/trunk/src/story_entities/world.h

    r3644 r3646  
    2323class FontSet;
    2424class Terrain;
     25class GarbageCollector;
    2526
    2627//! The game world Interface
     
    5758  virtual ~World ();
    5859
     60  double getGameTime();
    5961
    6062  /* classes from story-entity */
     
    8890  Uint32 lastFrame;             //!< last time of frame
    8991  Uint32 dt;                    //!< time needed to calculate this frame
     92  double gameTime;              //!< this is where the game time is saved
    9093  bool bQuitOrxonox;            //!< quit this application
    9194  bool bQuitCurrentGame;        //!< quit only the current game and return to menu
     
    108111  tList<WorldEntity>* entities;//!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
    109112  WorldEntity* localPlayer;     //!< The Player, you fly through the level.
     113
     114  GarbageCollector* garbageCollector; //!< reference to the garbage  collector
    110115 
    111116  /* function for main-loop */
  • orxonox/trunk/src/world_entities/projectile.cc

    r3633 r3646  
    2020
    2121#include "world_entity.h"
     22#include "null_parent.h"
    2223#include "objModel.h"
    2324#include "primitive.h"
     
    3536  this->projectileModel = new Primitive(P_SPHERE);
    3637  this->flightDirection = NULL;
     38  this->currentLifeTime = 0.0f;
     39  this->ttl = 1.0f;
    3740  this->speed = 1.1f;
    3841}
     
    6972
    7073/**
     74   \brief this sets the time to life of the projectile
     75   \param ttl in second
     76
     77   after this life time, the projectile will garbage collect itself
     78*/
     79void Projectile::setTTL(float ttl)
     80{
     81  this->ttl = ttl;
     82}
     83
     84
     85/**
    7186   \brief signal tick, time dependent things will be handled here
    7287   \param time since last tick
     
    7489void Projectile::tick (float time)
    7590{
    76   *this->flightDirection = *this->flightDirection * speed;
    77   this->shiftCoor(this->flightDirection);
     91  this->currentLifeTime += time;
     92  if( this->ttl < this->currentLifeTime)
     93    {
     94      *this->flightDirection = *this->flightDirection * speed;
     95      this->shiftCoor(this->flightDirection);
     96      return;
     97    }
     98  this->finalize();
     99  //NullParent* np = NullParent::getInstance();
     100  /* garbage colelction */
     101  // \fix: there is no gc in this class, its all been done by GarbageCollector
    78102}
    79103
  • orxonox/trunk/src/world_entities/projectile.h

    r3632 r3646  
    2121
    2222  void setFlightDirection(Quaternion* flightDirection);
     23  void setSpeed(float speed);
     24  void setTTL(float ttl);
    2325
    2426  virtual void hit (WorldEntity* weapon, Vector* loc);
     
    3234  Primitive* projectileModel;          //!< this serves temporary as a plasma bullet
    3335  float speed;                         //!< this is the speed of the projectile
     36  float currentLifeTime;               //!< this is the time, the projectile exists in this world (incremented by tick)
     37  float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
    3438  Vector* flightDirection;             //!< direction in which the shoot flights
     39 
    3540};
    3641
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3632 r3646  
    9393  pj->setFlightDirection(q);
    9494
     95  printf("TestGun::current speed is: %f", this->getSpeed());
     96
    9597  this->worldEntities->add(pj);
    9698}
  • orxonox/trunk/src/world_entities/weapon.cc

    r3631 r3646  
    183183*/
    184184void Weapon::fire()
    185 {
    186  
    187 }
     185{}
    188186
    189187
  • orxonox/trunk/src/world_entities/weapon.h

    r3631 r3646  
    6161  bool hasWeaponIdleTimeElapsed(void);
    6262
    63   virtual void fire(void);
     63  virtual void fire(void) = 0;
    6464  virtual void hit (WorldEntity* weapon, Vector* loc);
    6565  virtual void destroy(void);
Note: See TracChangeset for help on using the changeset viewer.