[Orxonox-commit 3908] r8582 - code/branches/presentation/src/orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Wed May 25 22:10:09 CEST 2011
Author: dafrick
Date: 2011-05-25 22:10:09 +0200 (Wed, 25 May 2011)
New Revision: 8582
Modified:
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Fixing segfault, that occured when a SpaceShip was created without a camera.
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-25 19:42:29 UTC (rev 8581)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-25 20:10:09 UTC (rev 8582)
@@ -78,9 +78,9 @@
this->setConfigValues();
this->registerVariables();
- Camera* camera = CameraManager::getInstance().getActiveCamera();
- this->cameraOriginalPosition_ = camera->getPosition();
- this->cameraOriginalOrientation_ = camera->getOrientation();
+ this->cameraOriginalPosition_ = Vector3::UNIT_SCALE;
+ this->cameraOriginalOrientation_ = Quaternion::IDENTITY;
+
this->shakeFrequency_ = 15;
this->shakeAmplitude_ = 5;
@@ -181,7 +181,7 @@
}
- shakeCamera(dt);
+ this->shakeCamera(dt);
}
}
}
@@ -241,6 +241,9 @@
{
//COUT(0) << "Boost startet!\n";
this->bBoost_ = true;
+ Camera* camera = CameraManager::getInstance().getActiveCamera();
+ this->cameraOriginalPosition_ = camera->getPosition();
+ this->cameraOriginalOrientation_ = camera->getOrientation();
}
if(!bBoost)
{
@@ -272,34 +275,41 @@
Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_);
//COUT(0) << "Angle: " << angle << std::endl;
- Camera* c = this->getCamera();
+ Camera* camera = this->getCamera();
//Shaking Camera effect
- if (c != 0)
+ if (camera != 0)
{
- c->setOrientation(Vector3::UNIT_X, angle);
+ camera->setOrientation(Vector3::UNIT_X, angle);
}
}
}
-
+
void SpaceShip::resetCamera()
{
-
- //COUT(0) << "Resetting camera\n";
- Camera *c = this->getCamera();
-
- if (c == 0)
+ Camera *camera = this->getCamera();
+
+ if (camera == 0)
{
COUT(2) << "Failed to reset camera!";
return;
}
- shakeDt_ = 0;
- //
- c->setPosition(this->cameraOriginalPosition_);
- c->setOrientation(this->cameraOriginalOrientation_);
+ this->shakeDt_ = 0;
+ camera->setPosition(this->cameraOriginalPosition_);
+ camera->setOrientation(this->cameraOriginalOrientation_);
}
+ void SpaceShip::backupCamera()
+ {
+ Camera* camera = CameraManager::getInstance().getActiveCamera();
+ if(camera != NULL)
+ {
+ this->cameraOriginalPosition_ = camera->getPosition();
+ this->cameraOriginalOrientation_ = camera->getOrientation();
+ }
+ }
+
void SpaceShip::loadEngineTemplate()
{
if (!this->enginetemplate_.empty())
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-25 19:42:29 UTC (rev 8581)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-25 20:10:09 UTC (rev 8582)
@@ -107,6 +107,7 @@
void boostCooledDown(void);
void resetCamera();
+ void backupCamera();
void shakeCamera(float dt);
std::string enginetemplate_;
More information about the Orxonox-commit
mailing list