Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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.

File:
1 edited

Legend:

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