Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4934 in orxonox.OLD


Ignore:
Timestamp:
Jul 22, 2005, 6:41:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: resurection of shoots works perfectly… now it is the question of how to recollect them… most probably the GarbageCollector… this will be one step deeper then..

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/object_manager.h

    r4933 r4934  
    6363
    6464  protected:
     65    FastFactory (ClassID classID, const char* fastFactoryName = NULL);
     66
    6567    /** sets the Next factory in the list @param nextFactory the next factory */
    6668    inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; };
     
    6870    FastFactory* getNext() const { return this->next; };
    6971
    70     virtual BaseObject* fabricate(ClassID classID) = NULL;
    71 
    72   private:
    73     FastFactory (ClassID classID, const char* fastFactoryName = NULL);
     72//    virtual BaseObject* fabricate(ClassID classID) = NULL;
     73
     74    static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL);
     75
     76  private:
    7477    static void registerFastFactory(FastFactory* fastFactory);
    75     static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL);
    7678
    7779  protected:
     
    9294{
    9395  public:
    94     static FastFactory* getFastFactory(ClassID classID, const char* fastFactoryName = NULL);
     96    static tFastFactory<T>* getFastFactory(ClassID classID, const char* fastFactoryName = NULL);
    9597
    9698    void prepare(unsigned int count);
     
    126128
    127129template<class T>
    128     FastFactory* tFastFactory<T>::getFastFactory(ClassID classID, const char* fastFactoryName)
     130    tFastFactory<T>* tFastFactory<T>::getFastFactory(ClassID classID, const char* fastFactoryName)
    129131{
    130132  tFastFactory<T>* tmpFac = NULL;
    131133  if (FastFactory::getFirst() != NULL)
    132     tmpFac = FastFactory::getFirst()->searchFastFactory(classID, fastFactoryName);
     134    tmpFac = static_cast<tFastFactory<T>*>(FastFactory::getFirst()->searchFastFactory(classID, fastFactoryName));
    133135
    134136  if (tmpFac != NULL)
    135137    return tmpFac;
    136138  else
    137     return new tFastFactory<T>;
     139    return new tFastFactory<T>(classID, fastFactoryName);
    138140}
    139141
     
    142144    T* tFastFactory<T>::fabricate()
    143145{
    144   FastObjectMember<T>* tmpFirstDead = this->deadList;
     146  FastObjectMember<T>* tmpFirstDead = new FastObjectMember<T>;
    145147  tmpFirstDead->objectPointer = new T();
    146148  tmpFirstDead->next = this->deadList;
     
    148150
    149151  this->deadList = tmpFirstDead;
    150   return this->deadList;
     152  return tmpFirstDead->objectPointer;
    151153}
    152154
     
    154156    void tFastFactory<T>::prepare(unsigned int count)
    155157{
    156   if (this->storedDeadObjects + this->storedLivingObjects >= count)
     158/*  if (this->storedDeadObjects + this->storedLivingObjects >= count)
    157159  {
    158160    PRINTF(3)("not creating new Objects for class %s, because the requested count already exists\n", this->getClassName());
    159   }
    160   for (int i = this->storedDeadObjects + this->storedLivingObjects; i < count; i++)
     161  }*/
     162  for (int i = this->storedDeadObjects; i < count; i++)
    161163  {
    162164    this->fabricate();
     
    167169    T* tFastFactory<T>::resurect()
    168170{
     171  PRINTF(4)("Resurecting Object of type %s\n", this->getName());
    169172  if (unlikely(this->deadList == NULL))
    170173  {
     
    179182
    180183    tmpC->next = this->unusedContainers;
    181     this->unusedContainers->tmpC;
    182 
    183     return tmpC;
     184    this->unusedContainers = tmpC;
     185
     186    return tmpC->objectPointer;
    184187  }
    185188}
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4932 r4934  
    111111
    112112  this->setActionSound(WA_SHOOT, "sound/shot1.wav");
     113
     114  this->bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet");
     115  this->bulletFactory->prepare(100);
    113116}
    114117
     
    155158void TestGun::fire()
    156159{
    157   Projectile* pj =  new TestBullet();//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
     160  Projectile* pj =  this->bulletFactory->resurect();//new TestBullet();//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
    158161//  weaponSource->play();
    159162
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4927 r4934  
    3030class Quaternion;
    3131class Animation3D;
     32class TestBullet;
    3233
    3334
    3435class TestGun : public Weapon
    35 {
     36  {
    3637  public:
    3738    TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight);
     
    5455    int leftRight;   // this will become an enum
    5556
     57    tFastFactory<TestBullet>*       bulletFactory;  //!< The factory for fast interaction with the TestBullet Class.
    5658
    5759
    58 };
    5960
     61  };
    6062#endif /* _TEST_GUN_H */
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4930 r4934  
    398398void Weapon::tickW(float dt)
    399399{
    400   printf("%s ", stateToChar(this->currentState));
     400  //printf("%s ", stateToChar(this->currentState));
    401401
    402402  // setting up the timing properties
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4930 r4934  
    2626class Animation3D;
    2727class TiXmlElement;
     28template<class T> class tFastFactory;
    2829
    2930//! An enumerator defining Actions a Weapon can take
Note: See TracChangeset for help on using the changeset viewer.