Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2015, 1:41:26 PM (9 years ago)
Author:
gania
Message:

fixed library dependencies

File:
1 edited

Legend:

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

    r10873 r10875  
    7878        if (!this->isActive())
    7979            return;
    80      
    81        
     80
     81    //this doesn't fight in formation flight, thus we can afford executing following code in tick: when nobody fights, tick is anyway stable.
     82        if (this->myDivisionLeader_ && this->myDivisionLeader_->getAction() != Action::FIGHT && this->myDivisionLeader_->getAction() !=
     83            Action::FIGHTALL && this->myDivisionLeader_->getAction() != Action::ATTACK)
     84        {
     85            ControllableEntity* myEntity = this->getControllableEntity();
     86            Vector3 myPosition = myEntity->getWorldPosition();
     87            if (!this->myDivisionLeader_)
     88            {
     89                return;
     90            }
     91            ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
     92            Quaternion orient = leaderEntity->getWorldOrientation();
     93            Vector3 leaderPosition = leaderEntity->getWorldPosition();
     94
     95            Vector3 targetRelativePosition = getFormationPosition();
     96            if (!this->myDivisionLeader_)
     97            {
     98                return;
     99            }
     100            Vector3 targetAbsolutePosition =
     101                (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
     102                 + (orient* (targetRelativePosition)));
     103       
     104            this->setAction (Action::FLY, targetAbsolutePosition, orient);
     105            if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
     106            {
     107                this->boostControl();
     108            }
     109            else
     110            {
     111               this->getControllableEntity()->boost(false);
     112            }
     113        }   
    82114        SUPER(SectionController, tick, dt);
    83115    }
     
    143175                default:
    144176                {
    145                     ControllableEntity* myEntity = this->getControllableEntity();
    146                     Vector3 myPosition = myEntity->getWorldPosition();
    147                     if (!this->myDivisionLeader_)
    148                     {
    149                         return;
    150                     }
    151                     ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
    152                     Quaternion orient = leaderEntity->getWorldOrientation();
    153                     Vector3 leaderPosition = leaderEntity->getWorldPosition();
    154 
    155                     Vector3 targetRelativePosition = getFormationPosition();
    156                     if (!this->myDivisionLeader_)
    157                     {
    158                         return;
    159                     }
    160                     Vector3 targetAbsolutePosition =
    161                         (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
    162                          + (orient* (targetRelativePosition)));
    163                
    164                     this->setAction (Action::FLY, targetAbsolutePosition, orient);
    165                     if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
    166                     {
    167                         this->boostControl();
    168                     }
    169                     else
    170                     {
    171                        this->getControllableEntity()->boost(false);
    172                     }
     177                    //formation flight is executed in tick
    173178                }
    174179            }
Note: See TracChangeset for help on using the changeset viewer.