Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

using strongly typed enum class in WorldEntity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.