Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1898 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 20, 2004, 2:33:29 AM (21 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented garbage collection for shoots: now frame-rate wont drop too much with time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/core/shoot_laser.cc

    r1896 r1898  
    4141  /* now draw all the shoots (many) */
    4242  shoot* tmpShoot = lastShoot;
     43  shoot* lastRef = null;
    4344  while( tmpShoot != null )
    4445    {
     
    4950      glutWireCube(1.0);
    5051      glPopMatrix();
    51       tmpShoot = tmpShoot->next;
     52
     53      /* garbage collection: look if shoot is outside world */
     54      /* fix1: weak boundaries check all four sides */
     55      /* fix2: conditions, that a struct tree can be cut off */
     56      if (tmpShoot->yCor > 50)
     57        {
     58          if (lastRef != null)
     59            {
     60              cout << "garbage collection" << endl;
     61              lastRef->next = tmpShoot->next;
     62              delete tmpShoot;
     63              tmpShoot = lastRef;         
     64              lastRef = tmpShoot;
     65              tmpShoot = tmpShoot->next;
     66              cout << "garbage collection left" << endl;
     67            }
     68          else
     69            {
     70              cout << "garbage collecton on last el" << endl;
     71              lastRef = tmpShoot->next;
     72              delete tmpShoot;
     73              tmpShoot = lastRef;
     74              if (tmpShoot != null) {
     75                lastRef = tmpShoot;
     76                tmpShoot = tmpShoot->next;
     77                cout << "noch nich null" << endl;
     78              }
     79              else {
     80                lastRef = null;
     81                tmpShoot = null;
     82                lastShoot = null;
     83                cout << "endl null" << endl;
     84              }
     85              cout << "garbage collection on last el left" << endl;
     86            }
     87        }
     88      else
     89        {
     90          lastRef = tmpShoot;
     91          tmpShoot = tmpShoot->next;
     92        }
    5293    }
    5394  //cout << "ShootLaser::drawShoot - finished" << endl;
     
    61102}
    62103
    63 void ShootLaser::addShoot(float x, float y, float z) 
     104void ShootLaser::addShoot(float x, float y, float z)
    64105{
    65106  //cout << "ShootLaser::addShoot" << endl;
Note: See TracChangeset for help on using the changeset viewer.