Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 646 for code


Ignore:
Timestamp:
Dec 19, 2007, 5:04:07 AM (17 years ago)
Author:
landauf
Message:
  • added very bad collision detection (presentation hack :D)
  • added explosions
  • fixed bug in ParticleInterface (it tried to delete SceneManager)

AND:

  • fixed one of the most amazing bugs ever! (the game crashed when I deleted an object through a timer-function. because the timer-functions is called by an iterator, the iterator indirectly delted its object. by overloading the (it++) operator, i was able to solve this problem)
Location:
code/branches/FICN/src/orxonox
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/CMakeLists.txt

    r643 r646  
    4343    objects/weapon_system/bullet_manager.cc
    4444    objects/weapon_system/weapon_station.cc
     45    objects/Explosion.cc
    4546  )
    4647ELSE(WIN32)
  • code/branches/FICN/src/orxonox/core/Iterator.h

    r496 r646  
    5656
    5757            /**
     58                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
     59                @return The Iterator itself
     60            */
     61            Iterator<T> operator++(int i)
     62            {
     63                Iterator<T> copy = *this;
     64                this->element_ = this->element_->next_;
     65                return copy;
     66            }
     67
     68            /**
    5869                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
    5970                @return The Iterator itself
     
    6374                this->element_ = this->element_->prev_;
    6475                return *this;
     76            }
     77
     78            /**
     79                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
     80                @return The Iterator itself
     81            */
     82            Iterator<T> operator--(int i)
     83            {
     84                Iterator<T> copy = *this;
     85                this->element_ = this->element_->prev_;
     86                return copy;
    6587            }
    6688
  • code/branches/FICN/src/orxonox/objects/CMakeLists.txt

    r643 r646  
    2727  weapon_system/bullet_manager.cc
    2828  weapon_system/weapon_station.cc
     29  Explosion.cc
    2930)
    3031
  • code/branches/FICN/src/orxonox/objects/Model.cc

    r631 r646  
    3131        create();
    3232    }
    33    
     33
    3434    bool Model::create(){
    3535      if(meshSrc_.compare("")!=0){
     
    4141      return true;
    4242    }
    43    
     43
    4444    void Model::registerAllVariables(){
    4545      registerVar(&meshSrc_, meshSrc_.length()+1, network::STRING);
  • code/branches/FICN/src/orxonox/objects/Model.h

    r630 r646  
    1212        public:
    1313            Model();
    14             ~Model();
     14            virtual ~Model();
    1515            virtual void loadParams(TiXmlElement* xmlElem);
    1616            bool create();
  • code/branches/FICN/src/orxonox/objects/Projectile.cc

    r644 r646  
    11#include "Projectile.h"
    22#include "../core/CoreIncludes.h"
     3#include "Explosion.h"
     4#include "Model.h"
    35
    46namespace orxonox
     
    3537    }
    3638
     39    void Projectile::tick(float dt)
     40    {
     41        WorldEntity::tick(dt);
     42
     43        float radius;
     44        for (Iterator<Model> it = ObjectList<Model>::start(); it; ++it)
     45        {
     46            if ((*it) != this->owner_)
     47            {
     48                radius = it->getScale().x * 3.0;
     49
     50                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
     51                {
     52                    Explosion* eplosion = new Explosion(this);
     53                    delete this;
     54                    return;
     55                }
     56            }
     57        }
     58    }
     59
    3760    void Projectile::destroyObject()
    3861    {
  • code/branches/FICN/src/orxonox/objects/Projectile.h

    r643 r646  
    1313        public:
    1414            Projectile(SpaceShip* owner = 0);
    15             ~Projectile();
     15            virtual ~Projectile();
    1616            void destroyObject();
     17            virtual void tick(float dt);
    1718
    1819        private:
  • code/branches/FICN/src/orxonox/objects/SpaceShip.cc

    r644 r646  
    4646
    4747        SetConfigValue(bInvertMouse_, true);
    48         SetConfigValue(reloadTime_, 0.1);
     48        SetConfigValue(reloadTime_, 0.125);
    4949
    5050        this->setMouseEventCallback_ = false;
  • code/branches/FICN/src/orxonox/objects/Tickable.h

    r640 r646  
    4646            {
    4747                // Iterate through all Tickables and call their tick(dt) function
    48                 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    49                     it->tick(evt.timeSinceLastFrame);
     48                for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
     49                    (it++)->tick(evt.timeSinceLastFrame);
    5050
    5151                return FrameListener::frameStarted(evt);
  • code/branches/FICN/src/orxonox/objects/Timer.h

    r640 r646  
    136136            {
    137137                // Iterate through all Timers
    138                 for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; ++it)
     138                for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; )
    139139                {
    140140                    if (it->isActive())
     
    151151                                it->stopTimer(); // Stop the timer if we don't want to loop
    152152
    153                             it->run();
     153                            (it++)->run();
    154154                        }
     155                        else
     156                            ++it;
    155157                    }
     158                    else
     159                        ++it;
    156160                }
    157161
  • code/branches/FICN/src/orxonox/objects/WorldEntity.h

    r643 r646  
    1818    public:
    1919      WorldEntity();
    20       ~WorldEntity();
     20      virtual ~WorldEntity();
    2121
    2222      virtual void tick(float dt);
  • code/branches/FICN/src/orxonox/particle/ParticleInterface.cc

    r618 r646  
    4040  ParticleInterface::~ParticleInterface(void)
    4141  {
     42std::cout << "blubiblub_1\n";
    4243    sceneManager_->destroyParticleSystem(particleSystem_);
     44std::cout << "blubiblub_2\n";
    4345
    44     delete sceneNode_;
    45     delete particleSystem_;
    46     delete sceneManager_;
     46//    delete sceneNode_;
     47//    delete particleSystem_;
     48//    delete sceneManager_;
    4749  }
    4850
     
    8082  }
    8183
    82   void ParticleInterface::dettachFromSceneNode ( void )
     84  void ParticleInterface::detachFromSceneNode ( void )
    8385  {
    8486    sceneNode_->detachObject(particleSystem_);
  • code/branches/FICN/src/orxonox/particle/ParticleInterface.h

    r621 r646  
    2222        ~ParticleInterface( void );
    2323        void addToSceneNode( Ogre::SceneNode* sceneNode );
    24         void dettachFromSceneNode( void );
     24        void detachFromSceneNode( void );
    2525        Ogre::ParticleEmitter* getEmitter ( int emitterNr );
    2626        void newEmitter ( void );
Note: See TracChangeset for help on using the changeset viewer.