Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2008, 2:34:54 AM (16 years ago)
Author:
landauf
Message:

used isInitialized() in destructors where needed and changed constructors back to normal variable initialization instead of the "myclass() : variable(value), …" pattern. in my opinion this is much more comfortable and I hope everyone agrees ;)

Location:
code/trunk/src/orxonox/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/BillboardProjectile.cc

    r1558 r1559  
    5252    BillboardProjectile::~BillboardProjectile()
    5353    {
    54         if (this->owner_)
     54        if (this->isInitialized() && this->owner_)
    5555            this->detachObject(this->billboard_.getBillboardSet());
    5656    }
  • code/trunk/src/orxonox/objects/Model.cc

    r1558 r1559  
    4545    CreateFactory(Model);
    4646
    47     Model::Model() : meshSrc_("")
     47    Model::Model()
    4848    {
    4949        RegisterObject(Model);
     
    5353    Model::~Model()
    5454    {
    55         if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
     55        if (this->isInitialized() && (this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
    5656            this->detachObject(this->mesh_.getEntity());
    5757    }
  • code/trunk/src/orxonox/objects/ParticleProjectile.cc

    r1558 r1559  
    3737    CreateFactory(ParticleProjectile);
    3838
    39     ParticleProjectile::ParticleProjectile(SpaceShip* owner) : BillboardProjectile(owner), particles_(0)
     39    ParticleProjectile::ParticleProjectile(SpaceShip* owner) : BillboardProjectile(owner)
    4040    {
    4141        RegisterObject(ParticleProjectile);
     
    4747            this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());
    4848            this->particles_->setKeepParticlesInLocalSpace(true);
     49        }
     50        else
     51        {
     52            this->particles_ = 0;
    4953        }
    5054    }
  • code/trunk/src/orxonox/objects/ParticleSpawner.cc

    r1553 r1559  
    3838    CreateFactory(ParticleSpawner);
    3939
    40     ParticleSpawner::ParticleSpawner() : particle_(0)
     40    ParticleSpawner::ParticleSpawner()
    4141    {
    4242        RegisterObject(ParticleSpawner);
    4343    }
    4444
    45     ParticleSpawner::ParticleSpawner(const std::string& templateName, float lifetime, float delay, const Vector3& direction) : particle_(0)
     45    ParticleSpawner::ParticleSpawner(const std::string& templateName, float lifetime, float delay, const Vector3& direction)
    4646    {
    4747        RegisterObject(ParticleSpawner);
     
    6161    ParticleSpawner::~ParticleSpawner()
    6262    {
    63         if (this->particle_)
     63        if (this->isInitialized())
    6464        {
    6565            this->particle_->detachFromSceneNode();
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1558 r1559  
    7979    }
    8080
    81     SpaceShip::SpaceShip() :
    82       //testvector_(0,0,0),
    83       //bInvertYAxis_(false),
    84       setMouseEventCallback_(false),
    85       bLMousePressed_(false),
    86       bRMousePressed_(false),
    87       camNode_(0),
    88       cam_(0),
    89       camName_("CamNode"),
    90       tt1_(0),
    91       tt2_(0),
    92       redNode_(0),
    93       greenNode_(0),
    94       blinkTime_(0.0f),
    95       chNearNode_(0),
    96       chFarNode_(0),
    97       timeToReload_(0.0f),
    98       //reloadTime_(0.0f),
    99       maxSideAndBackSpeed_(0.0f),
    100       maxSpeed_(0.0f),
    101       maxRotation_(0.0f),
    102       translationAcceleration_(0.0f),
    103       rotationAcceleration_(0.0f),
    104       translationDamping_(0.0f),
    105       rotationDamping_(0.0f),
    106       maxRotationRadian_(0),
    107       rotationAccelerationRadian_(0),
    108       rotationDampingRadian_(0),
    109       zeroRadian_(0),
    110       mouseXRotation_(0),
    111       mouseYRotation_(0),
    112       mouseX_(0.0f),
    113       mouseY_(0.0f),
    114       myShip_(false),
    115       teamNr_(0),
    116       health_(100)
     81    SpaceShip::SpaceShip()
    11782    {
    11883        RegisterObject(SpaceShip);
    119         this->registerAllVariables();
    120 
    121         SpaceShip::instance_s = this;
    122 
    123         this->setConfigValues();
    124 
    125         initialDir_ = Vector3(1.0, 0.0, 0.0);
    126         currentDir_ = initialDir_;
    127         initialOrth_ = Vector3(0.0, 0.0, 1.0);
    128         currentOrth_ = initialOrth_;
    129 
    130         this->camName_ = this->getName() + "CamNode";
    13184
    13285        this->setRotationAxis(1, 0, 0);
    13386        this->setStatic(false);
    13487
     88        this->zeroRadian_ = 0;
     89        this->maxSideAndBackSpeed_ = 0;
     90        this->maxSpeed_ = 0;
     91        this->maxRotation_ = 0;
     92        this->translationAcceleration_ = 0;
     93        this->rotationAcceleration_ = 0;
     94        this->translationDamping_ = 0;
     95        this->rotationDamping_ = 0;
     96        this->maxRotationRadian_ = 0;
     97        this->rotationAccelerationRadian_ = 0;
     98        this->rotationDampingRadian_ = 0;
     99
     100        this->cam_ = 0;
     101        this->tt1_ = 0;
     102        this->tt2_ = 0;
     103
     104        this->redNode_ = 0;
     105        this->greenNode_ = 0;
     106        this->blinkTime_ = 0;
     107
     108        this->timeToReload_ = 0;
     109
     110        this->setMouseEventCallback_ = false;
     111        this->bLMousePressed_ = false;
     112        this->bRMousePressed_ = false;
     113        this->mouseXRotation_ = 0;
     114        this->mouseYRotation_ = 0;
     115        this->mouseX_ = 0;
     116        this->mouseY_ = 0;
     117        this->myShip_ = false;
     118
     119        this->registerAllVariables();
     120
     121        SpaceShip::instance_s = this;
     122
     123        this->setConfigValues();
     124
     125        this->initialDir_ = Vector3(1.0, 0.0, 0.0);
     126        this->currentDir_ = initialDir_;
     127        this->initialOrth_ = Vector3(0.0, 0.0, 1.0);
     128        this->currentOrth_ = initialOrth_;
     129
     130        this->camName_ = this->getName() + "CamNode";
     131
     132        this->teamNr_ = 0;
     133        this->health_ = 100;
     134
    135135        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
    136136    }
     
    138138    SpaceShip::~SpaceShip()
    139139    {
    140         if (this->tt1_)
    141             delete this->tt1_;
    142         if (this->tt2_)
    143             delete this->tt2_;
    144         if(setMouseEventCallback_)
    145           InputManager::removeMouseHandler("SpaceShip");
    146         if (this->cam_)
    147           delete this->cam_;
    148         if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL)
    149           //remove the radar object
    150           HUD::getSingleton().removeRadarObject(this->getNode());
     140        if (this->isInitialized())
     141        {
     142            if (this->tt1_)
     143                delete this->tt1_;
     144            if (this->tt2_)
     145                delete this->tt2_;
     146
     147            if (setMouseEventCallback_)
     148                InputManager::removeMouseHandler("SpaceShip");
     149
     150            if (this->cam_)
     151                delete this->cam_;
     152
     153            if (!myShip_ && &HUD::getSingleton()!=NULL)
     154              HUD::getSingleton().removeRadarObject(this->getNode());
     155        }
    151156    }
    152157
     
    307312      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
    308313      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(1,0,0));
    309       camNode_->setOrientation(q2*q1);
     314      this->camNode_->setOrientation(q2*q1);
    310315      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
    311316        this->setBacksync(true);
  • code/trunk/src/orxonox/objects/WorldEntity.cc

    r1558 r1559  
    4545    unsigned int WorldEntity::worldEntityCounter_s = 0;
    4646
    47     WorldEntity::WorldEntity() :
    48       velocity_    (0, 0, 0),
    49       acceleration_(0, 0, 0),
    50       rotationAxis_(0, 1, 0),
    51       rotationRate_(0),
    52       momentum_    (0),
    53       node_        (0),
    54       bStatic_     (true)
     47    WorldEntity::WorldEntity()
    5548    {
    5649        RegisterObject(WorldEntity);
     
    5851        if (GraphicsEngine::getSingleton().getSceneManager())
    5952        {
    60           std::ostringstream name;
    61           name << (WorldEntity::worldEntityCounter_s++);
    62           this->setName("WorldEntity" + name.str());
    63           this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
     53            std::ostringstream name;
     54            name << (WorldEntity::worldEntityCounter_s++);
     55            this->setName("WorldEntity" + name.str());
     56            this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
    6457
    65           registerAllVariables();
     58            registerAllVariables();
    6659        }
     60        else
     61        {
     62            this->node_ = 0;
     63        }
     64
     65        this->bStatic_ = true;
     66        this->velocity_ = Vector3(0, 0, 0);
     67        this->acceleration_ = Vector3(0, 0, 0);
     68        this->rotationAxis_ = Vector3(0, 1, 0);
     69        this->rotationRate_ = 0;
     70        this->momentum_ = 0;
    6771    }
    6872
     
    7074    WorldEntity::~WorldEntity()
    7175    {
    72         // just to make sure we clean out all scene nodes
    73         if(this->getNode())
     76        if (this->isInitialized())
    7477        {
    7578            this->getNode()->removeAndDestroyAllChildren();
Note: See TracChangeset for help on using the changeset viewer.