Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2011, 10:10:09 PM (14 years ago)
Author:
dafrick
Message:

Fixing segfault, that occured when a SpaceShip was created without a camera.

Location:
code/branches/presentation/src/orxonox/worldentities/pawns
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8580 r8582  
    7979        this->registerVariables();
    8080       
    81         Camera* camera = CameraManager::getInstance().getActiveCamera();
    82         this->cameraOriginalPosition_ = camera->getPosition();
    83         this->cameraOriginalOrientation_ = camera->getOrientation();
     81        this->cameraOriginalPosition_ = Vector3::UNIT_SCALE;
     82        this->cameraOriginalOrientation_ = Quaternion::IDENTITY;
     83       
    8484
    8585        this->shakeFrequency_ = 15;
     
    182182                }
    183183
    184                 shakeCamera(dt);
     184                this->shakeCamera(dt);
    185185            }
    186186        }
     
    242242            //COUT(0) << "Boost startet!\n";
    243243            this->bBoost_ = true;
     244            Camera* camera = CameraManager::getInstance().getActiveCamera();
     245            this->cameraOriginalPosition_ = camera->getPosition();
     246            this->cameraOriginalOrientation_ = camera->getOrientation();
    244247        }
    245248        if(!bBoost)
     
    273276   
    274277            //COUT(0) << "Angle: " << angle << std::endl;
    275             Camera* c = this->getCamera();
     278            Camera* camera = this->getCamera();
    276279
    277280            //Shaking Camera effect
    278             if (c != 0)
    279             {
    280                 c->setOrientation(Vector3::UNIT_X, angle);
    281             }
    282         }
    283     }
    284    
     281            if (camera != 0)
     282            {
     283                camera->setOrientation(Vector3::UNIT_X, angle);
     284            }
     285        }
     286    }
     287
    285288    void SpaceShip::resetCamera()
    286289    {
    287    
    288         //COUT(0) << "Resetting camera\n";
    289         Camera *c = this->getCamera();
    290    
    291         if (c == 0)
     290        Camera *camera = this->getCamera();
     291
     292        if (camera == 0)
    292293        {
    293294            COUT(2) << "Failed to reset camera!";
     
    295296        }
    296297   
    297         shakeDt_ = 0;
    298         //
    299         c->setPosition(this->cameraOriginalPosition_);
    300         c->setOrientation(this->cameraOriginalOrientation_);
     298        this->shakeDt_ = 0;
     299        camera->setPosition(this->cameraOriginalPosition_);
     300        camera->setOrientation(this->cameraOriginalOrientation_);
     301    }
     302
     303    void SpaceShip::backupCamera()
     304    {
     305        Camera* camera = CameraManager::getInstance().getActiveCamera();
     306        if(camera != NULL)
     307        {
     308            this->cameraOriginalPosition_ = camera->getPosition();
     309            this->cameraOriginalOrientation_ = camera->getOrientation();
     310        }
    301311    }
    302312
  • code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h

    r8580 r8582  
    108108       
    109109            void resetCamera();
     110            void backupCamera();
    110111            void shakeCamera(float dt);
    111112
Note: See TracChangeset for help on using the changeset viewer.