Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4311 in orxonox.OLD


Ignore:
Timestamp:
May 26, 2005, 11:03:31 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: f*g object manager is hard to get done right, trying it differently

Location:
orxonox/trunk/src
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/garbage_collector.cc

    r4289 r4311  
    140140          //delete entity;
    141141          ObjectManager::getInstance()->addToDeadList(CL_TEST_BULLET, entity);
    142           ObjectManager::getInstance()->debug();
    143142        }
    144143      entity = iterator->nextElement();
     
    148147  PRINTF(3)("=============================\n");
    149148
     149  ObjectManager::getInstance()->debug();
     150
    150151  /* reset time to count again up to this->delay */
    151152  this->time = 0;
  • orxonox/trunk/src/util/object_manager.cc

    r4289 r4311  
    1919#include "list.h"
    2020
     21#include "projectile.h"
    2122
    2223using namespace std;
     
    6263
    6364
    64 void ObjectManager::cache(classList index, int number, const BaseObject &copyObject)
     65void ObjectManager::cache(classList index, int number, Projectile* copyObject)
    6566{
    6667  //this->managedObjectList[index] = new BaseObject[number];
     
    6869  for(int i = 0; i < number; ++i)
    6970    {
    70       this->managedObjectList[index]->add(new BaseObject(copyObject));
     71      this->managedObjectList[index]->add(new Projectile(*copyObject));
    7172    }
    7273}
  • orxonox/trunk/src/util/object_manager.h

    r4288 r4311  
    1818#define OM_
    1919
    20 #include "class_list.h"
     20
     21//! list of all classes to be loadable in via the ObjectManager
     22typedef enum classList
     23{
     24  CL_PROJECTILE,
     25  CL_TEST_BULLET,
     26
     27  CL_NUMBER
     28};
     29 
     30
     31
    2132
    2233
    2334class WorldEntity;
    2435class GarbageCollector;
    25 
     36class Projectile;
    2637
    2738template<class T> class tList;
    2839template<class T> class ManagedObject;
     40
     41#define mCache( Class ) \
     42 cache(classList index, int number, Class * copyObject)
     43
     44
    2945
    3046//! the object manager itself
     
    3551  virtual ~ObjectManager(void);
    3652 
    37   void cache(classList index, int number, const BaseObject &copyObject);
     53
     54  void mCache(Projectile);
     55
    3856  void addToDeadList(classList index, BaseObject* object);
    3957  BaseObject* getFromDeadList(classList index, int number = 1);
     58
     59
    4060
    4161  void debug();
     
    4363 private:
    4464  ObjectManager(void);
     65  //void cache(classList index, int number, Projectile* copyObject);
     66
    4567  static ObjectManager* singletonRef;
    4668
  • orxonox/trunk/src/world_entities/test_gun.cc

    r4289 r4311  
    8989    }
    9090
    91   BaseObject* p = new TestBullet(this);
    92   ObjectManager::getInstance()->cache(CL_TEST_BULLET, 100, *p);
     91  Projectile* p = new TestBullet(this);
     92  ObjectManager::getInstance()->cache(CL_TEST_BULLET, 100, p);
    9393  ObjectManager::getInstance()->debug();
    9494}
     
    143143    }
    144144
    145   Projectile* pj = new TestBullet(this);
     145  Projectile* pj = (TestBullet*)ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET);
     146
     147  //printf( "object ref %p\n", ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET));
     148
     149  //Projectile* pj = new TestBullet(this);
    146150  pj->setAbsCoor(this->getAbsCoor() + this->projectileOffset);
    147151  pj->setAbsDir(this->getAbsDir());
Note: See TracChangeset for help on using the changeset viewer.