Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6056 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Dec 11, 2005, 10:47:01 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more small optimisations, and a convenience inline-tick-life-cycle functions for projectiles

Location:
trunk/src/world_entities/weapons
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6054 r6056  
    134134//  GarbageCollector::getInstance()->collect(this);
    135135  State::getWorldEntityList()->remove(this);
     136  this->removeNode();
    136137  GuidedMissile::fastFactory->kill(this);
    137138}
     
    164165  this->shiftCoor(v);
    165166
    166   this->lifeCycle += time/this->lifeSpan;
    167   if( this->lifeCycle >= 1.0)
    168     {
    169       PRINTF(5)("FINALIZE==========================\n");
    170       PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
    171       PRINTF(5)("FINALIZE===========================\n");
    172 
    173       this->deactivate();
    174     }
     167  if(this->tickLifeCycle(time))
     168    this->deactivate();
    175169}
    176170
  • trunk/src/world_entities/weapons/laser.cc

    r5994 r6056  
    100100//  GarbageCollector::getInstance()->collect(this);
    101101  State::getWorldEntityList()->remove(this);
     102  this->removeNode();
    102103  Laser::fastFactory->kill(this);
    103104}
     
    113114/**
    114115 *  signal tick, time dependent things will be handled here
    115  * @param time since last tick
     116 * @param dt time since last tick
    116117*/
    117 void Laser::tick (float time)
     118void Laser::tick (float dt)
    118119{
    119120  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    120   Vector v = this->velocity * (time);
     121  Vector v = this->velocity * dt;
    121122  this->shiftCoor(v);
    122123
    123   this->lifeCycle += time/this->lifeSpan;
    124   if( this->lifeCycle >= 1.0)
    125     {
    126       PRINTF(5)("FINALIZE==========================\n");
    127       PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
    128       PRINTF(5)("FINALIZE===========================\n");
    129 
    130       this->deactivate();
    131     }
     124  if (this->tickLifeCycle(dt))
     125    this->deactivate();
    132126}
    133127
  • trunk/src/world_entities/weapons/laser.h

    r5750 r6056  
    2929    virtual void destroy ();
    3030
    31     virtual void tick (float time);
     31    virtual void tick (float dt);
    3232    virtual void draw () const;
    3333
  • trunk/src/world_entities/weapons/projectile.cc

    r6054 r6056  
    110110/**
    111111 * signal tick, time dependent things will be handled here
    112  * @param time since last tick
     112 * @param dt since last tick
    113113*/
    114 void Projectile::tick (float time)
     114void Projectile::tick (float dt)
    115115{
    116   Vector v = this->velocity * (time);
     116  Vector v = this->velocity * (dt);
    117117  this->shiftCoor(v);
    118118
    119   this->lifeCycle += time/this->lifeSpan;
    120   if( this->lifeCycle >= 1)
    121   {
    122     PRINTF(5)("FINALIZE==========================\n");
    123     PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
    124     PRINTF(5)("FINALIZE===========================\n");
    125     //this->finalize();
    126     GarbageCollector::getInstance()->collect(this);
    127   }
     119  if (this->tickLifeCycle(dt))
     120    this->destroy();
    128121}
    129122
  • trunk/src/world_entities/weapons/projectile.h

    r6054 r6056  
    4040    virtual void destroy ();
    4141
    42     virtual void tick (float time);
     42    virtual void tick (float dt);
     43    /** @brief convenience function
     44     * @param dt the Time passed
     45     * @returns true if the Projectile is past its lifeTime, false if it shall still live */
     46    inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); }
     47
    4348
    4449  protected:
  • trunk/src/world_entities/weapons/rocket.cc

    r5994 r6056  
    143143 * @param time since last tick
    144144*/
    145 void Rocket::tick (float time)
     145void Rocket::tick (float dt)
    146146{
    147147  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    148   Vector v = this->velocity * (time);
     148  Vector v = this->velocity * (dt);
    149149  this->shiftCoor(v);
    150150
    151   this->lifeCycle += time/this->lifeSpan;
    152   if( this->lifeCycle >= 1.0)
    153     {
    154       PRINTF(5)("FINALIZE==========================\n");
    155       PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
    156       PRINTF(5)("FINALIZE===========================\n");
    157 
    158       this->deactivate();
    159     }
     151  if(this->tickLifeCycle(dt))
     152    this->deactivate();
    160153}
    161154
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6055 r6056  
    9090    }
    9191    this->currentSlotConfig[i].position.setName(tmpName);
     92    this->currentSlotConfig[i].position.deactivateNode();
    9293    delete[] tmpName;
    9394  }
Note: See TracChangeset for help on using the changeset viewer.