[Orxonox-commit 6410] r11067 - code/branches/cpp11_v3/src/orxonox/controllers
landauf at orxonox.net
landauf at orxonox.net
Sun Jan 17 14:58:59 CET 2016
Author: landauf
Date: 2016-01-17 14:58:59 +0100 (Sun, 17 Jan 2016)
New Revision: 11067
Modified:
code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc
code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc
Log:
shortened code
Modified: code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc 2016-01-17 13:03:27 UTC (rev 11066)
+++ code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc 2016-01-17 13:58:59 UTC (rev 11067)
@@ -173,28 +173,19 @@
{
this->setFormationMode( this->myDivisionLeader_->getFormationMode() );
this->spread_ = this->myDivisionLeader_->getSpread();
- Vector3* targetRelativePosition;
switch (this->formationMode_){
case FormationMode::WALL:
- {
- targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0);
- break;
- }
+ return Vector3 (-2.0f*this->spread_, 0, 0);
+
case FormationMode::FINGER4:
- {
- targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
- break;
- }
+ return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
case FormationMode::DIAMOND:
- {
- targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
- break;
- }
+ return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
+
+ default:
+ return Vector3::ZERO;
}
- Vector3 result = *targetRelativePosition;
- delete targetRelativePosition;
- return result;
}
void SectionController::keepFormation()
Modified: code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc 2016-01-17 13:03:27 UTC (rev 11066)
+++ code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc 2016-01-17 13:58:59 UTC (rev 11067)
@@ -106,54 +106,34 @@
Vector3 WingmanController::getFormationPosition ()
{
-
-
this->setFormationMode( this->myLeader_->getFormationMode() );
- Vector3* targetRelativePosition;
this->spread_ = this->myLeader_->getSpread();
if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
{
switch (this->formationMode_){
case FormationMode::WALL:
- {
- targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
case FormationMode::FINGER4:
- {
- targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
case FormationMode::DIAMOND:
- {
- targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
+ default:
+ return Vector3::ZERO;
}
}
else
{
switch (this->formationMode_){
case FormationMode::WALL:
- {
- targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
case FormationMode::FINGER4:
- {
- targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
case FormationMode::DIAMOND:
- {
- targetRelativePosition = new Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
- break;
- }
+ return Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
+ default:
+ return Vector3::ZERO;
}
}
- Vector3 result = *targetRelativePosition;
- delete targetRelativePosition;
- return result;
}
void WingmanController::keepFormation()
{
More information about the Orxonox-commit
mailing list