Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11067


Ignore:
Timestamp:
Jan 17, 2016, 2:58:59 PM (9 years ago)
Author:
landauf
Message:

shortened code

Location:
code/branches/cpp11_v3/src/orxonox/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc

    r11065 r11067  
    174174        this->setFormationMode( this->myDivisionLeader_->getFormationMode() );
    175175        this->spread_ = this->myDivisionLeader_->getSpread();
    176         Vector3* targetRelativePosition;
    177176        switch (this->formationMode_){
    178177            case FormationMode::WALL:
    179             {
    180                 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0);   
    181                 break;
    182             }
     178                return Vector3 (-2.0f*this->spread_, 0, 0);
     179
    183180            case FormationMode::FINGER4:
    184             {
    185                 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);   
    186                 break;
    187             }
     181                return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
    188182           
    189183            case FormationMode::DIAMOND:
    190             {
    191                 targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
    192                 break;
    193             }
    194         }
    195         Vector3 result = *targetRelativePosition;
    196         delete targetRelativePosition;
    197         return result;
     184                return Vector3 (-2.0f*this->spread_, 0, 1.0f*this->spread_);
     185
     186            default:
     187                return Vector3::ZERO;
     188        }
    198189    }
    199190
  • code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc

    r11065 r11067  
    107107    Vector3 WingmanController::getFormationPosition ()
    108108    {
    109 
    110 
    111109        this->setFormationMode( this->myLeader_->getFormationMode() );
    112         Vector3* targetRelativePosition;
    113110        this->spread_ = this->myLeader_->getSpread();
    114111        if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
     
    116113            switch (this->formationMode_){
    117114                case FormationMode::WALL:
    118                 {
    119                     targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
    120                     break;
    121                 }
     115                    return Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
    122116                case FormationMode::FINGER4:
    123                 {
    124                     targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
    125                     break;
    126                 }
     117                    return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
    127118                case FormationMode::DIAMOND:
    128                 {
    129                     targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
    130                     break;
    131                 }
     119                    return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
     120                default:
     121                    return Vector3::ZERO;
    132122            }
    133123        }
     
    136126            switch (this->formationMode_){
    137127                case FormationMode::WALL:
    138                 {
    139                     targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
    140                     break;
    141                 }
     128                    return Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
    142129                case FormationMode::FINGER4:
    143                 {
    144                     targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
    145                     break;
    146                 }
     130                    return Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
    147131                case FormationMode::DIAMOND:
    148                 {
    149                     targetRelativePosition = new Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
    150                     break;
    151                 }
     132                    return Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
     133                default:
     134                    return Vector3::ZERO;
    152135            }
    153136        }
    154         Vector3 result = *targetRelativePosition;
    155         delete targetRelativePosition;
    156         return result;
    157137    }
    158138    void WingmanController::keepFormation()
Note: See TracChangeset for help on using the changeset viewer.