Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11004


Ignore:
Timestamp:
Dec 30, 2015, 10:07:09 PM (9 years ago)
Author:
landauf
Message:

using strongly typed enum class in WorldEntity

Location:
code/branches/cpp11_v2/src
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/objects/Turret.cc

    r10622 r11004  
    278278            //slower the closer it is to the destination
    279279            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
    280             this->rotate(drot, WorldEntity::World);
     280            this->rotate(drot, WorldEntity::TransformSpace::World);
    281281            this->rotation_ = Quaternion::IDENTITY;
    282282        }
  • code/branches/cpp11_v2/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10919 r11004  
    2727        RegisterObject(TowerDefenseEnemy);
    2828
    29         this->setCollisionType(WorldEntity::Dynamic);
     29        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    3030        //needed to keep track of the PlayerStats coded in TowerDefense.h
    3131        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
  • code/branches/cpp11_v2/src/modules/towerdefense/TowerDefenseTower.cc

    r10765 r11004  
    2626        RegisterObject(TowerDefenseTower);
    2727        game_ =nullptr;
    28         this->setCollisionType(WorldEntity::None);
     28        this->setCollisionType(WorldEntity::CollisionType::None);
    2929        upgrade = 1;
    3030
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/GravityBomb.cc

    r10622 r11004  
    2828                this->timeToLife_= LIFETIME;
    2929                this->setCollisionResponse(false);
    30                 this->setCollisionType(WorldEntity::Dynamic);
     30                this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    3131                this->enableCollisionCallback();
    3232
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/IceGunProjectile.cc

    r10629 r11004  
    8989            Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition();
    9090            freezer->setPosition(Vector3(0,0,0));
    91             freezer->translate(offset, WorldEntity::World);
     91            freezer->translate(offset, WorldEntity::TransformSpace::World);
    9292            // Start the freezing effect.
    9393            freezer->startFreezing();
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r10622 r11004  
    4848        this->textureIndex_ = 1;
    4949        this->setMass(2);
    50         this->setCollisionType(Dynamic);
     50        this->setCollisionType(CollisionType::Dynamic);
    5151        this->maxTextureIndex_ = 8;
    5252        this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/Projectile.cc

    r10765 r11004  
    5757            this->enableCollisionCallback();
    5858            this->setCollisionResponse(false);
    59             this->setCollisionType(Dynamic);
     59            this->setCollisionType(CollisionType::Dynamic);
    6060
    6161            // Create a sphere collision shape and attach it to the projectile.
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/Rocket.cc

    r11000 r11004  
    7070        if (GameMode::isMaster())
    7171        {
    72             this->setCollisionType(WorldEntity::Kinematic);
     72            this->setCollisionType(WorldEntity::CollisionType::Kinematic);
    7373            this->setVelocity(0,0,-100);
    7474
     
    9292            this->enableCollisionCallback();
    9393            this->setCollisionResponse(false);
    94             this->setCollisionType(Kinematic);
     94            this->setCollisionType(CollisionType::Kinematic);
    9595
    9696            // Add collision shape
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/RocketOld.cc

    r11000 r11004  
    7070        if (GameMode::isMaster())
    7171        {
    72             this->setCollisionType(WorldEntity::Kinematic);
     72            this->setCollisionType(WorldEntity::CollisionType::Kinematic);
    7373            this->setVelocity(0,0,-100);
    7474
     
    9292            this->enableCollisionCallback();
    9393            this->setCollisionResponse(false);
    94             this->setCollisionType(Kinematic);
     94            this->setCollisionType(CollisionType::Kinematic);
    9595
    9696            // Add collision shape
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/SimpleRocket.cc

    r11000 r11004  
    7070        if (GameMode::isMaster())
    7171        {
    72             this->setCollisionType(WorldEntity::Kinematic);
     72            this->setCollisionType(WorldEntity::CollisionType::Kinematic);
    7373            this->fuel_ = true;
    7474
     
    8787            this->enableCollisionCallback();
    8888            this->setCollisionResponse(false);
    89             this->setCollisionType(Kinematic);
     89            this->setCollisionType(CollisionType::Kinematic);
    9090
    9191            // Add collision shape.
  • code/branches/cpp11_v2/src/orxonox/worldentities/Drone.cc

    r10818 r11004  
    4949        this->localAngularAcceleration_.setValue(0, 0, 0);
    5050        this->setRadarVisibility(false);
    51         this->setCollisionType(WorldEntity::Dynamic);
     51        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    5252
    5353        myController_ = new DroneController(this->getContext()); //!< Creates a new controller and passes our this pointer to it as creator.
  • code/branches/cpp11_v2/src/orxonox/worldentities/MobileEntity.cc

    r9667 r11004  
    189189    bool MobileEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    190190    {
    191         if (type == WorldEntity::Static)
     191        if (type == WorldEntity::CollisionType::Static)
    192192        {
    193193            orxout(internal_warning) << "Cannot tell a MobileEntity to have static collision type! Ignoring." << endl;
  • code/branches/cpp11_v2/src/orxonox/worldentities/StaticEntity.cc

    r9667 r11004  
    9595    bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    9696    {
    97         if (type == WorldEntity::Kinematic || type == WorldEntity::Dynamic)
     97        if (type == WorldEntity::CollisionType::Kinematic || type == WorldEntity::CollisionType::Dynamic)
    9898        {
    9999            orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl;
  • code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc

    r10916 r11004  
    5656
    5757    // Be sure we don't do bad conversions
    58     static_assert((int)Ogre::Node::TS_LOCAL  == (int)WorldEntity::Local,  "check enum");
    59     static_assert((int)Ogre::Node::TS_PARENT == (int)WorldEntity::Parent, "check enum");
    60     static_assert((int)Ogre::Node::TS_WORLD  == (int)WorldEntity::World,  "check enum");
     58    static_assert((int)Ogre::Node::TS_LOCAL  == (int)WorldEntity::TransformSpace::Local,  "check enum");
     59    static_assert((int)Ogre::Node::TS_PARENT == (int)WorldEntity::TransformSpace::Parent, "check enum");
     60    static_assert((int)Ogre::Node::TS_WORLD  == (int)WorldEntity::TransformSpace::World,  "check enum");
    6161
    6262    RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>();
     
    9595        this->collisionShape_ = new WorldEntityCollisionShape(this->getContext());
    9696        this->collisionShape_->setWorldEntityOwner(this);
    97         this->collisionType_             = None;
    98         this->collisionTypeSynchronised_ = None;
     97        this->collisionType_             = CollisionType::None;
     98        this->collisionTypeSynchronised_ = CollisionType::None;
    9999        this->mass_                 = 1.0f;
    100100        this->childrenMass_         = 0;
     
    207207        registerVariable(this->bCollisionResponseActive_,
    208208                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
    209         registerVariable((int&)this->collisionTypeSynchronised_,
     209        registerVariable(this->collisionTypeSynchronised_,
    210210                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
    211211        registerVariable(this->bPhysicsActiveSynchronised_,
     
    322322    void WorldEntity::collisionTypeChanged()
    323323    {
    324         if (this->collisionTypeSynchronised_ != Dynamic &&
    325             this->collisionTypeSynchronised_ != Kinematic &&
    326             this->collisionTypeSynchronised_ != Static &&
    327             this->collisionTypeSynchronised_ != None)
     324        if (this->collisionTypeSynchronised_ != CollisionType::Dynamic &&
     325            this->collisionTypeSynchronised_ != CollisionType::Kinematic &&
     326            this->collisionTypeSynchronised_ != CollisionType::Static &&
     327            this->collisionTypeSynchronised_ != CollisionType::None)
    328328        {
    329329            orxout(internal_error) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << endl;
     
    681681        switch (relativeTo)
    682682        {
    683         case WorldEntity::Local:
     683        case TransformSpace::Local:
    684684            // position is relative to parent so transform downwards
    685685            this->setPosition(this->getPosition() + this->getOrientation() * distance);
    686686            break;
    687         case WorldEntity::Parent:
     687        case TransformSpace::Parent:
    688688            this->setPosition(this->getPosition() + distance);
    689689            break;
    690         case WorldEntity::World:
     690        case TransformSpace::World:
    691691            // position is relative to parent so transform upwards
    692692            if (this->node_->getParent())
     
    711711        switch(relativeTo)
    712712        {
    713         case WorldEntity::Local:
     713        case TransformSpace::Local:
    714714            this->setOrientation(this->getOrientation() * rotation);
    715715            break;
    716         case WorldEntity::Parent:
     716        case TransformSpace::Parent:
    717717            // Rotations are normally relative to local axes, transform up
    718718            this->setOrientation(rotation * this->getOrientation());
    719719            break;
    720         case WorldEntity::World:
     720        case TransformSpace::World:
    721721            // Rotations are normally relative to local axes, transform up
    722722            this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse()
     
    741741        switch (relativeTo)
    742742        {
    743         case WorldEntity::Local:
     743        case TransformSpace::Local:
    744744            origin = Vector3::ZERO;
    745745            break;
    746         case WorldEntity::Parent:
     746        case TransformSpace::Parent:
    747747            origin = this->getPosition();
    748748            break;
    749         case WorldEntity::World:
     749        case TransformSpace::World:
    750750            origin = this->getWorldPosition();
    751751            break;
     
    831831
    832832        // Check whether we have to create or destroy.
    833         if (type != None && this->collisionType_ == None)
     833        if (type != CollisionType::None && this->collisionType_ == CollisionType::None)
    834834        {
    835835/*
     
    849849            this->physicalBody_->setActivationState(DISABLE_DEACTIVATION);
    850850        }
    851         else if (type == None && this->collisionType_ != None)
     851        else if (type == CollisionType::None && this->collisionType_ != CollisionType::None)
    852852        {
    853853            // Destroy rigid body
     
    856856            delete this->physicalBody_;
    857857            this->physicalBody_ = nullptr;
    858             this->collisionType_ = None;
    859             this->collisionTypeSynchronised_ = None;
     858            this->collisionType_ = CollisionType::None;
     859            this->collisionTypeSynchronised_ = CollisionType::None;
    860860            return;
    861861        }
     
    864864        switch (type)
    865865        {
    866         case Dynamic:
     866        case CollisionType::Dynamic:
    867867            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT & !btCollisionObject::CF_KINEMATIC_OBJECT);
    868868            break;
    869         case Kinematic:
     869        case CollisionType::Kinematic:
    870870            this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT) | btCollisionObject::CF_KINEMATIC_OBJECT);
    871871            break;
    872         case Static:
     872        case CollisionType::Static:
    873873            this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT) | btCollisionObject::CF_STATIC_OBJECT);
    874874            break;
    875         case None:
     875        case CollisionType::None:
    876876            assert(false); // Doesn't happen
    877877            return;
     
    895895        CollisionType type;
    896896        if (typeStrLower == "dynamic")
    897             type = Dynamic;
     897            type = CollisionType::Dynamic;
    898898        else if (typeStrLower == "static")
    899             type = Static;
     899            type = CollisionType::Static;
    900900        else if (typeStrLower == "kinematic")
    901             type = Kinematic;
     901            type = CollisionType::Kinematic;
    902902        else if (typeStrLower == "none")
    903             type = None;
     903            type = CollisionType::None;
    904904        else
    905905            ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'.");
     
    912912        switch (this->getCollisionType())
    913913        {
    914             case Dynamic:
     914            case CollisionType::Dynamic:
    915915                return "dynamic";
    916             case Kinematic:
     916            case CollisionType::Kinematic:
    917917                return "kinematic";
    918             case Static:
     918            case CollisionType::Static:
    919919                return "static";
    920             case None:
     920            case CollisionType::None:
    921921                return "none";
    922922            default:
  • code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.h

    r10817 r11004  
    8282                Enumeration denoting the spaces which a transform can be relative to.
    8383            */
    84             enum TransformSpace
     84            enum class TransformSpace
    8585            {
    8686                //! Transform is relative to the local space
     
    117117            const Vector3& getWorldPosition() const;
    118118
    119             void translate(const Vector3& distance, TransformSpace relativeTo = WorldEntity::Parent);
    120             inline void translate(float x, float y, float z, TransformSpace relativeTo = WorldEntity::Parent)
     119            void translate(const Vector3& distance, TransformSpace relativeTo = TransformSpace::Parent);
     120            inline void translate(float x, float y, float z, TransformSpace relativeTo = TransformSpace::Parent)
    121121                { this->translate(Vector3(x, y, z), relativeTo); }
    122122
     
    134134            const Quaternion& getWorldOrientation() const;
    135135
    136             void rotate(const Quaternion& rotation, TransformSpace relativeTo = WorldEntity::Local);
    137             inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)
     136            void rotate(const Quaternion& rotation, TransformSpace relativeTo = TransformSpace::Local);
     137            inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace relativeTo = TransformSpace::Local)
    138138                { this->rotate(Quaternion(angle, axis), relativeTo); }
    139139
    140             inline void yaw(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)
     140            inline void yaw(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local)
    141141                { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); }
    142             inline void pitch(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)
     142            inline void pitch(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local)
    143143                { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); }
    144             inline void roll(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)
     144            inline void roll(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local)
    145145                { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); }
    146146
    147             void lookAt(const Vector3& target, TransformSpace relativeTo = WorldEntity::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    148             void setDirection(const Vector3& direction, TransformSpace relativeTo = WorldEntity::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    149             inline void setDirection(float x, float y, float z, TransformSpace relativeTo = WorldEntity::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
     147            void lookAt(const Vector3& target, TransformSpace relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     148            void setDirection(const Vector3& direction, TransformSpace relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     149            inline void setDirection(float x, float y, float z, TransformSpace relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
    150150                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    151151
     
    257257                None:      The object has no physics at all.
    258258            */
    259             enum CollisionType
     259            enum class CollisionType
    260260            {
    261261                Dynamic,
     
    266266
    267267            //! Tells whether the object has any connection to the Bullet physics engine. If hasPhysics() is false, the object may still have a velocity.
    268             bool hasPhysics()       const { return getCollisionType() != None     ; }
     268            bool hasPhysics()       const { return getCollisionType() != CollisionType::None     ; }
    269269            //! @see CollisionType
    270             bool isStatic()         const { return getCollisionType() == Static   ; }
     270            bool isStatic()         const { return getCollisionType() == CollisionType::Static   ; }
    271271            //! @see CollisionType
    272             bool isKinematic()      const { return getCollisionType() == Kinematic; }
     272            bool isKinematic()      const { return getCollisionType() == CollisionType::Kinematic; }
    273273            //! @see CollisionType
    274             bool isDynamic()        const { return getCollisionType() == Dynamic  ; }
     274            bool isDynamic()        const { return getCollisionType() == CollisionType::Dynamic  ; }
    275275            //! Tells whether physics has been activated (you can temporarily deactivate it)
    276276            bool isPhysicsActive()  const { return this->bPhysicsActive_; }
  • code/branches/cpp11_v2/src/orxonox/worldentities/pawns/FpsPlayer.cc

    r10818 r11004  
    7979        // FpsPlayer is always a physical object per default
    8080        // Be aware of this call: The collision type legality check will not reach derived classes!
    81         this->setCollisionType(WorldEntity::Dynamic);
     81        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    8282        // Get notification about collisions
    8383        this->enableCollisionCallback();
     
    130130    bool FpsPlayer::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    131131    {
    132         if (type != WorldEntity::Dynamic)
     132        if (type != WorldEntity::CollisionType::Dynamic)
    133133        {
    134134            orxout(internal_warning) << "Cannot tell a FpsPlayer not to be dynamic! Ignoring." << endl;
     
    168168            if (!this->isInMouseLook())
    169169            {
    170                 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent);
     170                this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::TransformSpace::Parent);
    171171
    172172                Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch();
  • code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc

    r10916 r11004  
    8080        // SpaceShip is always a physical object per default
    8181        // Be aware of this call: The collision type legality check will not reach derived classes!
    82         this->setCollisionType(WorldEntity::Dynamic);
     82        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    8383        // Get notification about collisions
    8484        this->enableCollisionCallback();
     
    143143    bool SpaceShip::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    144144    {
    145         if (type != WorldEntity::Dynamic)
     145        if (type != WorldEntity::CollisionType::Dynamic)
    146146        {
    147147            orxout(internal_warning) << "Cannot tell a SpaceShip not to be dynamic! Ignoring." << endl;
Note: See TracChangeset for help on using the changeset viewer.