Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2015, 10:37:59 PM (9 years ago)
Author:
gania
Message:

cut smoothness, gained performance

Location:
code/branches/campaignHS15
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/data/levels/AITest.oxw

    r10879 r10880  
    221221      </templates>
    222222      <controller>
    223         <DivisionController team=0 formationMode="Finger4" spread=100>
     223        <DivisionController team=0 formationMode="diamond" spread=100>
    224224          <actionpoints>
    225225            <Actionpoint position="   0,2000,    0" action="FLY" loopStart=true/>
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc

    r10879 r10880  
    360360    void ActionpointController::stayNearProtect()
    361361    {
    362         Vector3* targetRelativePosition;
    363         targetRelativePosition = new Vector3 (0, 300, 300); 
     362        Vector3 targetRelativePosition(0, 300, 300); 
    364363        Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) +
    365             (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
     364            (this->getProtect()->getWorldOrientation()* (targetRelativePosition)));
    366365        this->setTargetPosition(targetAbsolutePosition);
    367366        this->setTargetOrientation(this->getProtect()->getWorldOrientation());
     
    567566        if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
    568567        {
    569             if ( (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_)
    570                 || !this->target_ )
     568            if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
    571569            {
    572570                Pawn* newTarget = this->closestTarget();
  • code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc

    r10877 r10880  
    126126        Vector3 diffUnit = diffVector/diffLength;
    127127
    128         bool bTargetIsLookingAtThis = CommonController::isLooking ( this->target_, getControllableEntity(), math::pi/10.0f );
     128        bool bTargetIsLookingAtThis = CommonController::isLooking ( this->target_, getControllableEntity(), math::pi/20.0f );
    129129       
    130130        //too far? well, come closer then
     
    191191        );
    192192        Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit;
    193         *randVector -= projection;
    194         target += *randVector;
     193        Vector3 randV = *randVector;
     194        delete randVector;
     195        randV -= projection;
     196        target += randV;
    195197        this->setTargetPosition( thisPosition + target );
    196198    }
  • code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc

    r10879 r10880  
    3838    {
    3939        this->rotationProgress_ = 0;
     40        this->tickCounter_ = 0;
    4041        this->spread_ = 200;
    4142        this->tolerance_ = 80;
     
    9495    {
    9596        ControllableEntity* entity = this->getControllableEntity();
    96         Vector2 coord = get2DViewCoordinates
    97             ( entity->getPosition() ,
    98             entity->getOrientation()  * WorldEntity::FRONT,
    99             entity->getOrientation()  * WorldEntity::UP,
    100             target );
     97        this->tickCounter_ += this->tickCounter_ < 100000 ? 1 : -this->tickCounter_ ;
    10198
    10299        float distance = ( target - this->getControllableEntity() ->getPosition() ).length();
    103         float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
    104         float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
     100
    105101
    106102        if ( distance > this->tolerance_ )
    107103        {
     104            Vector2 coord = get2DViewCoordinates
     105                ( entity->getPosition() ,
     106                entity->getOrientation()  * WorldEntity::FRONT,
     107                entity->getOrientation()  * WorldEntity::UP,
     108                target );
     109            float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
     110            float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
    108111            this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
    109112            this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
     
    112115            if (distance > this->tolerance_*1.5f || (rotateX > -0.01 && rotateX < 0.01 && rotateY > -0.01 && rotateY < 0.01))
    113116                this->getControllableEntity() ->moveFrontBack( SPEED * dt );
    114          
    115             // if ( bHasTargetOrientation_ && (rotateX > -0.005 && rotateX < 0.005 && rotateY > -0.005 && rotateY < 0.005) )
    116             // {
     117            if (this->tickCounter_ % 10 == 0 )
    117118                copyTargetOrientation( dt );
    118             // }
    119            
    120119        }
    121120        else
     
    125124        }
    126125    }
     126   
    127127    void FlyingController::moveToTargetPosition(float dt)
    128128    {
     
    136136       
    137137        Quaternion myOrient = this->getControllableEntity()->getOrientation();
    138         this->rotationProgress_ += dt/50.0f;
     138        this->rotationProgress_ += 5*dt;
    139139
    140140        if (this->rotationProgress_ > 1)
     
    144144        else
    145145        {
    146             Quaternion delta = Quaternion::Slerp(this->rotationProgress_, myOrient, orient, true);
     146            Quaternion delta = Quaternion::Slerp(rotationProgress_, myOrient, orient, true);
    147147     
    148148            Matrix3 orientMatrix, myMatrix;
     
    153153            orientMatrix.ToEulerAnglesYXZ(yRad, pRad, rRad);
    154154            myMatrix.ToEulerAnglesYXZ (yMy, pMy, rMy);
    155             orxout (internal_error) << "dt = " << dt << endl;
    156             this->getControllableEntity()->rotateRoll (50.0f*dt*(rRad.valueRadians() - rMy.valueRadians()));
     155            this->getControllableEntity()->rotateRoll (50.0f * dt*(rRad.valueRadians() - rMy.valueRadians()));
    157156            //this->getControllableEntity()->setOrientation(delta);
    158157        }
    159         //this shit works. How?
     158       
    160159       
    161160    }
  • code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h

    r10879 r10880  
    8383         
    8484            float rotationProgress_;
     85            int tickCounter_;
    8586            bool bHasTargetPosition_;
    8687            Vector3 targetPosition_;
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10879 r10880  
    276276            }
    277277        }
    278         return *targetRelativePosition;
     278        Vector3 result = *targetRelativePosition;
     279        delete targetRelativePosition;
     280        return result;
    279281    }
    280282
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10879 r10880  
    149149       
    150150            this->setAction (Action::FLY, targetAbsolutePosition, orient);
     151
    151152            if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
    152153            {
     
    217218            }
    218219        }
    219        
    220         return *targetRelativePosition;
     220        Vector3 result = *targetRelativePosition;
     221        delete targetRelativePosition;
     222        return result;
    221223    }
    222224    //----POST: closest leader that is ready to take a new wingman is returned----
Note: See TracChangeset for help on using the changeset viewer.