Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10946


Ignore:
Timestamp:
Dec 7, 2015, 4:06:37 PM (8 years ago)
Author:
gania
Message:

fix for sigsegv?

Location:
code/branches/campaignHS15/src/orxonox/controllers
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc

    r10935 r10946  
    113113            this->moveToTargetPosition(dt);
    114114        }
     115        if (!this || !this->getControllableEntity())
     116            return;
    115117        else if (this->bLookAtTarget_)
    116118        {
     
    146148            this->bDodge_ = true;
    147149        }
     150        if (!this || !this->getControllableEntity())
     151            return;
    148152        if (ActionpointController::sTicks_ % 100 == step * this->actionpointControllerId_ + 1)
    149153        {
     
    175179                this->doFire();
    176180            }
     181            if (!this || !this->getControllableEntity())
     182                return;
    177183            this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
    178184            this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
     
    202208            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_)
    203209            {
     210                if (!this || !this->getControllableEntity())
     211                    return;
    204212                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
    205213                this->parsedActionpoints_.push_back (p);
    206214            }
     215            if (!this || !this->getControllableEntity())
     216                return;
    207217            this->executeActionpoint();
     218            if (!this || !this->getControllableEntity())
     219                return;
    208220            this->bTakenOver_ = false;
    209221        }
     
    220232                if (newTarget)
    221233                {
     234                    if (!this || !this->getControllableEntity())
     235                        return;
    222236                    this->setAction (Action::FIGHTALL, newTarget);
    223237                }
    224238                else
    225239                {
     240                    if (!this || !this->getControllableEntity())
     241                        return;
    226242                    this->nextActionpoint();
     243                    if (!this || !this->getControllableEntity())
     244                        return;
    227245                    this->executeActionpoint();
    228246   
     
    233251        else if (this->action_ == Action::FIGHT)
    234252        {
    235 
    236253            if (!this->hasTarget() )
    237254            {
    238255                //----find a target----
    239                 ControllableEntity* newTarget = this->closestTarget();   
     256                ControllableEntity* newTarget = this->closestTarget(); 
     257                if (!this || !this->getControllableEntity())
     258                    return; 
    240259                if (newTarget &&
    241260                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
    242261                {
     262                    if (!this || !this->getControllableEntity())
     263                        return;
    243264                    this->setAction (Action::FIGHT, newTarget);
    244265                }
    245266                else
    246267                {
     268                    if (!this || !this->getControllableEntity())
     269                        return;
    247270                    this->nextActionpoint();
     271                    if (!this || !this->getControllableEntity())
     272                        return;
    248273                    this->executeActionpoint();
    249274                }
     
    257282                {
    258283                    ControllableEntity* newTarget = this->closestTarget();
    259                    
     284                    if (!this || !this->getControllableEntity())
     285                        return;
    260286                    if (newTarget &&
    261287                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
    262288                    {
     289                        if (!this || !this->getControllableEntity())
     290                            return;
    263291                        this->setAction (Action::FIGHT, newTarget);
    264292                    }
    265293                    else
    266294                    {
     295                        if (!this || !this->getControllableEntity())
     296                            return;
    267297                        this->nextActionpoint();
     298                        if (!this || !this->getControllableEntity())
     299                            return;
    268300                        this->executeActionpoint();
    269301                    }
     
    275307            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    276308            {
     309                if (!this || !this->getControllableEntity())
     310                    return;
    277311                this->nextActionpoint();   
     312                if (!this || !this->getControllableEntity())
     313                    return;
    278314                this->executeActionpoint();
    279315            }
     
    283319            if (!this->getProtect())
    284320            {
     321                if (!this || !this->getControllableEntity())
     322                    return;
    285323                this->nextActionpoint();
     324                if (!this || !this->getControllableEntity())
     325                    return;
    286326                this->executeActionpoint();
    287327            }
     328            if (!this || !this->getControllableEntity())
     329                return;
    288330            this->stayNearProtect();
    289331        }
    290332        else if (this->action_ == Action::ATTACK)
    291333        {   
    292 
     334            if (!this || !this->getControllableEntity())
     335                return;
    293336            if (!this->hasTarget())
    294337            {
     338                if (!this || !this->getControllableEntity())
     339                    return;
    295340                this->nextActionpoint();
     341                if (!this || !this->getControllableEntity())
     342                    return;
    296343                this->executeActionpoint();
    297344            }
     
    302349    void ActionpointController::setProtect (ControllableEntity* protect)
    303350    {
     351
    304352        this->protect_ = protect;
    305353    }
    306354    ControllableEntity* ActionpointController::getProtect ()
    307355    {
     356
    308357        return this->protect_;
    309358    }
     
    401450    void ActionpointController::setAction (Action::Value action, ControllableEntity* target)
    402451    {
     452        if (!this || !this->getControllableEntity())
     453            return;
    403454        this->action_ = action;
    404455        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
     
    415466    void ActionpointController::setAction (Action::Value action, const Vector3& target)
    416467    {
     468        if (!this || !this->getControllableEntity())
     469            return;
    417470        this->action_ = action;
    418471        if (action == Action::FLY)
     
    423476    void ActionpointController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
    424477    {
     478        if (!this || !this->getControllableEntity())
     479            return;
    425480        this->action_ = action;
    426481        if (action == Action::FLY)
     
    466521            return;
    467522        }
     523        if (!this || !this->getControllableEntity())
     524            return;
    468525        if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
    469526        {
    470527            //MOVES all points that are in loop to a loop vector
    471528            this->fillLoop();
     529            if (!this || !this->getControllableEntity())
     530                return;
    472531            this->bLoop_ = true;
    473532            executeActionpoint();
    474533            return;
    475534        }
     535        if (!this || !this->getControllableEntity())
     536            return;
    476537        this->setAction (p.action);
    477538        if (!this || !this->getControllableEntity())
     
    487548                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    488549                {
     550                    if (!this || !this->getControllableEntity())
     551                        return;
    489552                    if (CommonController::getName(*itP) == targetName)
    490553                    {
     
    497560            {
    498561                this->setTargetPosition( p.position );
     562                if (!this || !this->getControllableEntity())
     563                    return;
    499564                if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    500565                {
     566                    if (!this || !this->getControllableEntity())
     567                        return;
    501568                    this->nextActionpoint();
     569                    if (!this || !this->getControllableEntity())
     570                        return;
    502571                    this->executeActionpoint();
    503572                }
     
    553622                    if (CommonController::getName(*itP) == targetName)
    554623                    {
     624                        if (!this || !this->getControllableEntity())
     625                            return;
    555626                        this->setTarget (static_cast<ControllableEntity*>(*itP));
    556627                    }
     
    559630                {
    560631                    this->nextActionpoint();
     632                    if (!this || !this->getControllableEntity())
     633                        return;
    561634                    this->executeActionpoint();
    562635                }
     
    648721    void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
    649722    {
    650       this->parsedActionpoints_ = vector;
    651       this->loopActionpoints_ = loop;
    652       this->bLoop_ = b;
    653       this->bTakenOver_ = true;
     723        if (!this || !this->getControllableEntity())
     724            return;
     725        this->parsedActionpoints_ = vector;
     726        if (!this || !this->getControllableEntity())
     727            return;
     728        this->loopActionpoints_ = loop;
     729        this->bLoop_ = b;
     730        this->bTakenOver_ = true;
    654731    }
    655732    void ActionpointController::setClosestTarget()
     
    667744        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    668745        {
     746            if (!this || !this->getControllableEntity())
     747                return 0;
    669748            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
    670749                continue;
     
    692771            if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
    693772            {
     773                if (!this || !this->getControllableEntity())
     774                    return;
    694775                Pawn* newTarget = this->closestTarget();
    695776                if ( newTarget &&
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h

    r10935 r10946  
    246246                bool bDefaultPatrol_;
    247247                bool stop_;
    248                 static unsigned int sTicks_;     //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep
    249                                         //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action()
     248                static unsigned int sTicks_;    //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep
     249                                                //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action()
    250250                static unsigned int nextActionpointControllerId_;    //<! if level has 16 ActionpointControllers, than this variable equals to 17 after first tick
    251251                unsigned int actionpointControllerId_;   //<! integer from 0 to nextActionpointControllerId_, different for every ActionpointController in level
    252                 unsigned int ticks_;     //<! local tick counter
    253 
    254 
    255         private:
    256            
     252                unsigned int ticks_;     //<! local tick counter           
    257253    };
    258254}
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc

    r10885 r10946  
    99 *   modify it under the terms of the GNU General Public License
    1010 *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or ( at your option )any later version.
     11 *   of the License, or (at your option)any later version.
    1212 *
    1313 *   This program is distributed in the hope that it will be useful,
     
    2828#include "controllers/CommonController.h"
    2929
    30 //stuff for sameTeam function
     30//here starts stuff for sameTeam function copied from FormationController
    3131#include "gametypes/TeamDeathmatch.h"
    3232#include "gametypes/Gametype.h"
     
    3939{
    4040
    41     RegisterClass( CommonController );
    42 
    43     CommonController::CommonController( Context* context ): Controller( context )
    44     {
    45         RegisterObject( CommonController );
     41    RegisterClass(CommonController);
     42
     43    CommonController::CommonController(Context* context): Controller(context)
     44    {
     45        RegisterObject(CommonController);
    4646    }
    4747    CommonController::~CommonController()
    4848    {
    49        
    50     }
    51 
    52     float CommonController::randomInRange( float a, float b )
     49        //no member variables - nothing to destroy
     50    }
     51    /**
     52    @brief
     53      PRE: a < b.
     54      returns random float between a and b.
     55    */
     56    float CommonController::randomInRange(float a, float b)
    5357    {
    5458        return a + rnd(1.0f) * (b - a);
    5559    }
    56     float CommonController::distance (ControllableEntity* entity1, ControllableEntity* entity2)
     60    /**
     61    @brief
     62      returns distance between two entities, if either is zero pointer, returns infinity
     63    */   
     64    float CommonController::distance (const ControllableEntity* entity1, const ControllableEntity* entity2)
    5765    {
    5866        if (!entity1 || !entity2)
    5967            return std::numeric_limits<float>::infinity();
    60         return ( entity1->getPosition() - entity2->getPosition() ).length();
    61     }
     68        return (entity1->getPosition() - entity2->getPosition()).length();
     69    }
     70    /**
     71    @brief
     72      bad function from FormationController that returns true if both entities have same team
     73    */   
    6274    bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    6375    {
     76        //uncomment following code if functions stops working due to being a hack
    6477        /*if (!entity1 || !entity2)
    6578            return false;
    6679        return entity1->getTeam() == entity2->getTeam();*/
     80        if (!entity1 || !entity2)
     81            return false;
    6782        if (entity1 == entity2)
    6883            return true;
     
    161176                team2 = dynamic->getParty(entity2->getPlayer());
    162177
    163             if (team1 ==-1 ||team2 ==-1 ) {return false;}
     178            if (team1 ==-1 ||team2 ==-1) {return false;}
    164179            else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;}
    165180            else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;}
     
    170185        return (team1 == team2 && team1 != -1);
    171186    }
    172     bool CommonController::isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle )
    173     {
    174         if ( !entityThatLooks || !entityBeingLookedAt )
     187    /**
     188    @brief
     189      returns true if entityThatLooks does look at entityBeingLookeAt with a tolerance of angle.
     190    */   
     191    bool CommonController::isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle)
     192    {
     193        if (!entityThatLooks || !entityBeingLookedAt)
    175194            return false;
    176         return ( getAngle( entityThatLooks ->getPosition() ,
     195        return (getAngle(entityThatLooks ->getPosition() ,
    177196            entityThatLooks->getOrientation()  * WorldEntity::FRONT,
    178             entityBeingLookedAt->getWorldPosition() ) < angle );
    179     }
    180     std::string CommonController::getName(Pawn* entity)
     197            entityBeingLookedAt->getWorldPosition()) < angle);
     198    }
     199    /**
     200    @brief
     201      returns a name of a Pawn entity, if no name set, returns string representing address of the Pawn.
     202    */   
     203    std::string CommonController::getName(const Pawn* entity)
    181204    {
    182205        std::string name = entity->getName();
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.h

    r10885 r10946  
    3131
    3232
    33 #include "controllers/Controller.h"
    34 #include <limits>
     33#include "controllers/Controller.h"                 //that's what I inherit from
    3534
    36 #include "worldentities/ControllableEntity.h"
    37 #include "worldentities/pawns/Pawn.h"
     35#include <limits>                                   //I use limits pretty much in every class, so might as well include it in the parent class
     36
     37#include "worldentities/ControllableEntity.h"       //same for ControllableEntity
     38#include "worldentities/pawns/Pawn.h"               //and Pawn
    3839
    3940
     
    4445
    4546        public:
    46             static const float ACTION_INTERVAL = 1.0f;
    47 
    48             static const float hardcoded_projectile_speed = 750;
     47            static const float hardcoded_projectile_speed = 750;        //<! FightingController uses it to predict enemy position
    4948
    5049            CommonController(Context* context);
     
    5251
    5352            static float randomInRange(float a, float b);
    54             static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
     53            static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2);
    5554            static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
    56             static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
    57             static std::string getName( Pawn* entity ) ;           
     55            static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle ) ;
     56            static std::string getName(const Pawn* entity ) ;           
    5857    };
    5958}
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10935 r10946  
    7070    void DivisionController::action()
    7171    {   
    72         if (!this || !this->getControllableEntity())
     72        if (!this || !this->getControllableEntity() || !this->isActive())
    7373            return;
    7474       
  • code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc

    r10923 r10946  
    99 *   modify it under the terms of the GNU General Public License
    1010 *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or ( at your option )any later version.
     11 *   of the License, or (at your option)any later version.
    1212 *
    1313 *   This program is distributed in the hope that it will be useful,
     
    2727 *
    2828 */
     29#include <OgreMatrix3.h>                        //for Quaternion manipulations
     30
     31#include "util/Math.h"                         
     32#include "core/XMLPort.h"
    2933#include "controllers/FlyingController.h"
    30 #include "core/XMLPort.h"
    31 #include "worldentities/pawns/SpaceShip.h"
    32 #include "util/Math.h"
    33 #include <OgreMatrix3.h>
     34
     35#include "worldentities/pawns/SpaceShip.h"      //for boosting
    3436
    3537namespace orxonox
     
    6062        FormationMode::Value value;
    6163       
    62         if ( valUpper == "WALL" )
     64        if (valUpper == "WALL")
    6365            value = FormationMode::WALL;
    64         else if ( valUpper == "FINGER4" )
     66        else if (valUpper == "FINGER4")
    6567            value = FormationMode::FINGER4;
    66         else if ( valUpper == "DIAMOND" )
     68        else if (valUpper == "DIAMOND")
    6769            value = FormationMode::DIAMOND;
    6870        else
    69             ThrowException(ParseError, std::string( "Attempting to set an unknown FormationMode: '" )+ val + "'.");
     71            ThrowException(ParseError, std::string("Attempting to set an unknown FormationMode: '")+ val + "'.");
    7072        this->setFormationMode(value);
    7173    }
    7274    std::string FlyingController::getFormationModeXML() const
    7375    {
    74         switch ( this->formationMode_ )
     76        switch (this->formationMode_)
    7577        {
    7678            case FormationMode::WALL:
     
    8890        this->bHasTargetPosition_ = false;
    8991    }
     92    /**
     93    @brief
     94      if distance to targetPosition is smaller than this->tolerance_, no moving should be made, otherwise
     95      find amount of yaw and pitch that have to be applied, so that ship looks at targetPosition, then
     96      ship is moved forward towards targetPosition. Also target orientation is being applied.
     97    */
    9098    void FlyingController::moveToPosition(const Vector3& targetPosition, float dt)
    9199    {
     
    94102        ControllableEntity* entity = this->getControllableEntity();
    95103
    96         float distance = ( targetPosition - entity->getPosition() ).length();
    97 
    98         if ( distance >= this->tolerance_ )
    99         {
     104        float distance = (targetPosition - entity->getPosition()).length();
     105
     106        if (distance >= this->tolerance_)
     107        {
     108            //function that calculates how much yaw and pitch are to be applied
    100109            Vector2 coord = get2DViewCoordinates
    101                 ( entity->getPosition() ,
     110                (entity->getPosition() ,
    102111                entity->getOrientation()  * WorldEntity::FRONT,
    103112                entity->getOrientation()  * WorldEntity::UP,
    104                 targetPosition );
    105             float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
    106             float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
    107             entity->rotateYaw( ROTATEFACTOR * rotateX * dt );
    108             entity->rotatePitch( ROTATEFACTOR * rotateY * dt );
    109          
     113                targetPosition);
     114            //limit yaw and pitch by [-1,1]
     115            float rotateX = -clamp(coord.x * 10, -1.0f, 1.0f);
     116            float rotateY = clamp(coord.y * 10, -1.0f, 1.0f);
     117
     118            if (!entity)
     119                return;
     120
     121            //apply yaw and pitch
     122            entity->rotateYaw(ROTATEFACTOR * rotateX * dt);
     123            entity->rotatePitch(ROTATEFACTOR * rotateY * dt);
     124           
     125            if (!entity)
     126                return;
     127           
     128            //only move either if ship looks at target with a certain tolerance, or if ship is far enough for it to be ok to move in a curve.
    110129            if (distance > this->tolerance_*1.5f || (rotateX > -0.03 && rotateX < 0.03 && rotateY > -0.03 && rotateY < 0.03))
    111                 entity->moveFrontBack( SPEED * dt );
    112                 copyTargetOrientation(dt);
     130                entity->moveFrontBack(SPEED * dt);
     131            //roll
     132            copyTargetOrientation(dt);
    113133        }
    114134        else
     
    117137        }
    118138    }
    119    
     139    /**
     140    @brief
     141      fly towards a preset targetPosition_
     142    */
    120143    void FlyingController::moveToTargetPosition(float dt)
    121144    {
    122145        this->moveToPosition (this->targetPosition_, dt);
    123146    }
     147    /**
     148    @brief
     149      roll ship so that it has same roll as orient
     150    */
    124151    void FlyingController::copyOrientation(const Quaternion& orient, float dt)
    125152    {
     
    155182        }
    156183    }
    157 
     184    /**
     185    @brief
     186      roll ship so that it has same roll as a preset targetOrientation_
     187    */
    158188    void FlyingController::copyTargetOrientation(float dt)
    159189    {
     
    163193        }
    164194    }
    165    
     195    /**
     196    @brief
     197      set Vector to fly to
     198    */
    166199    void FlyingController::setTargetPosition(const Vector3& target)
    167200    {
     
    169202        this->bHasTargetPosition_ = true;
    170203    }
    171 
     204    /**
     205    @brief
     206      set orientation to apply
     207    */
    172208    void FlyingController::setTargetOrientation(const Quaternion& orient)
    173209    {
     
    175211        this->bHasTargetOrientation_=true;
    176212    }
    177 
     213    /**
     214    @brief
     215      set orientation to apply
     216    */
    178217    void FlyingController::setTargetOrientation(ControllableEntity* target)
    179218    {
     
    181220            this->setTargetOrientation(target->getOrientation());
    182221    }
     222    /**
     223    @brief
     224      boost if you can
     225    */
    183226    void FlyingController::boostControl()
    184227    {
     
    187230        SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
    188231        if(ship == NULL) return;
    189         if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost
     232        if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower()) //upper limit ->boost
    190233        {
    191234            this->getControllableEntity()->boost(true);
     
    196239        }
    197240    }
     241    /**
     242    @brief
     243      keep this ship in a formation with its division
     244    */
    198245    void FlyingController::keepFormation(const ControllableEntity* leaderEntity, Vector3& targetRelativePosition)
    199246    {
     247        if (!this->getControllableEntity())
     248            return;
    200249        ControllableEntity* myEntity = this->getControllableEntity();
    201250        Vector3 myPosition = myEntity->getWorldPosition();
     
    212261            return;
    213262        }
     263        //calculate where in world coordinates this ship should fly
    214264        Vector3 targetAbsolutePosition =
    215265            (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
    216266             + (orient* (targetRelativePosition)));
    217         //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
     267        //let ship finish rotating. also don't call copyOrientation too often as it is a slow function. Don't know how to do it different
    218268        if (static_cast<int>(rnd(1.0f) * 100) % 3 == 0)
    219269            this->setTargetOrientation (orient);
     270        //set a position to fly to
    220271        this->setTargetPosition (targetAbsolutePosition);
     272
     273        //boost if too far
    221274        if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
    222275        {
     
    225278        else
    226279        {
    227            this->getControllableEntity()->boost(false);
     280            if (!this->getControllableEntity())
     281                return;
     282            this->getControllableEntity()->boost(false);
    228283        }
    229284    }
  • code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h

    r10923 r10946  
    3939        FlyingController stores all the flying methods and member variables of AI.
    4040    */
     41
     42    //Formation mode for the divisions
    4143    namespace FormationMode
    4244    {
     
    5153
    5254        public:
    53             static const float SPEED = 0.9f/0.02f;
    54             static const float ROTATEFACTOR = 0.6f/0.02f;
     55            static const float SPEED = 0.9f/0.02f;              //<! ship's speed
     56            static const float ROTATEFACTOR = 0.6f/0.02f;       //<! ship's rotation factor
    5557 
    5658            FlyingController(Context* context);
     
    5860            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5961
    60             void setSpread (int spread)
     62            void setSpread (int spread)                         //<! spread is a multiplier for formation flight, should be bigger than 100
    6163                { this->spread_ = spread; }
    62             int getSpread () const
     64            int getSpread () const                             
    6365                { return this->spread_; }
    6466
     
    7274
    7375        protected:
    74             void stopMoving();
     76            void stopMoving();                                  //<! don't call moveToTargetPosition() in tick, call lookAtTarget() from FightingController instead
    7577
    76             void moveToPosition(const Vector3& target, float dt);
    77             void moveToTargetPosition(float dt);
     78            void moveToPosition(const Vector3& target, float dt);   //<! move towards a vector
     79            void moveToTargetPosition(float dt);                    //<! move to the preset position. Don't mix with positionOfTarget!
    7880
    79             void copyOrientation(const Quaternion& orient, float dt);
    80             void copyTargetOrientation(float dt);
     81            void copyOrientation(const Quaternion& orient, float dt);   //<! roll to have same roll as orient
     82            void copyTargetOrientation(float dt);                       //<! roll to have a preset orient
    8183
    82             void setTargetPosition(const Vector3& target);
    83             void setTargetOrientation(const Quaternion& orient);
    84             void setTargetOrientation(ControllableEntity* target);
    85             virtual void boostControl(); 
    86             void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition);     
     84            void setTargetPosition(const Vector3& target);              //<! preset a Vector to fly to
     85            void setTargetOrientation(const Quaternion& orient);        //<! preset a desired orientation
     86            void setTargetOrientation(ControllableEntity* target);      //<! preset a desired orientation
     87            virtual void boostControl();                                //<! boost if you can
     88            void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition);   //<! preset targetPosition, so that
     89                                                                                                            //<! this stays in a certain position relative to leader     
    8790           
    8891            FormationMode::Value formationMode_;
    8992         
    90             float rotationProgress_;    //<! for slerp
     93            float rotationProgress_;    //<! for slerping
    9194            bool bHasTargetPosition_;
    92             Vector3 targetPosition_;
     95            Vector3 targetPosition_;    //<! vector to fly to
    9396            bool bHasTargetOrientation_;
    94             Quaternion targetOrientation_;
    95             int spread_;
    96             int tolerance_;
     97            Quaternion targetOrientation_;  //<! orientation to take
     98            int spread_;                //<! spread is a multiplier for formation flight, should be bigger than 100
     99            int tolerance_;             //<! if this ship is tolerance_ away from targetPosition_, ship decides that it finished moving
    97100    };
    98101}
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10935 r10946  
    7373    void SectionController::action()
    7474    {
    75         if (!this || !this->getControllableEntity())
     75        if (!this || !this->getControllableEntity() || !this->isActive())
    7676            return;
    7777
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10935 r10946  
    7373    void WingmanController::action()
    7474    {
    75         if (!this || !this->getControllableEntity())
     75        if (!this || !this->getControllableEntity() || !this->isActive())
    7676            return;
    7777        //----If no leader, find one----
Note: See TracChangeset for help on using the changeset viewer.