Changeset 11004
- Timestamp:
- Dec 30, 2015, 10:07:09 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/objects/Turret.cc
r10622 r11004 278 278 //slower the closer it is to the destination 279 279 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); 281 281 this->rotation_ = Quaternion::IDENTITY; 282 282 } -
code/branches/cpp11_v2/src/modules/towerdefense/TowerDefenseEnemy.cc
r10919 r11004 27 27 RegisterObject(TowerDefenseEnemy); 28 28 29 this->setCollisionType(WorldEntity:: Dynamic);29 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 30 30 //needed to keep track of the PlayerStats coded in TowerDefense.h 31 31 this->td = orxonox_cast<TowerDefense*>(this->getGametype()); -
code/branches/cpp11_v2/src/modules/towerdefense/TowerDefenseTower.cc
r10765 r11004 26 26 RegisterObject(TowerDefenseTower); 27 27 game_ =nullptr; 28 this->setCollisionType(WorldEntity:: None);28 this->setCollisionType(WorldEntity::CollisionType::None); 29 29 upgrade = 1; 30 30 -
code/branches/cpp11_v2/src/modules/weapons/projectiles/GravityBomb.cc
r10622 r11004 28 28 this->timeToLife_= LIFETIME; 29 29 this->setCollisionResponse(false); 30 this->setCollisionType(WorldEntity:: Dynamic);30 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 31 31 this->enableCollisionCallback(); 32 32 -
code/branches/cpp11_v2/src/modules/weapons/projectiles/IceGunProjectile.cc
r10629 r11004 89 89 Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition(); 90 90 freezer->setPosition(Vector3(0,0,0)); 91 freezer->translate(offset, WorldEntity:: World);91 freezer->translate(offset, WorldEntity::TransformSpace::World); 92 92 // Start the freezing effect. 93 93 freezer->startFreezing(); -
code/branches/cpp11_v2/src/modules/weapons/projectiles/LightningGunProjectile.cc
r10622 r11004 48 48 this->textureIndex_ = 1; 49 49 this->setMass(2); 50 this->setCollisionType( Dynamic);50 this->setCollisionType(CollisionType::Dynamic); 51 51 this->maxTextureIndex_ = 8; 52 52 this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this))); -
code/branches/cpp11_v2/src/modules/weapons/projectiles/Projectile.cc
r10765 r11004 57 57 this->enableCollisionCallback(); 58 58 this->setCollisionResponse(false); 59 this->setCollisionType( Dynamic);59 this->setCollisionType(CollisionType::Dynamic); 60 60 61 61 // Create a sphere collision shape and attach it to the projectile. -
code/branches/cpp11_v2/src/modules/weapons/projectiles/Rocket.cc
r11000 r11004 70 70 if (GameMode::isMaster()) 71 71 { 72 this->setCollisionType(WorldEntity:: Kinematic);72 this->setCollisionType(WorldEntity::CollisionType::Kinematic); 73 73 this->setVelocity(0,0,-100); 74 74 … … 92 92 this->enableCollisionCallback(); 93 93 this->setCollisionResponse(false); 94 this->setCollisionType( Kinematic);94 this->setCollisionType(CollisionType::Kinematic); 95 95 96 96 // Add collision shape -
code/branches/cpp11_v2/src/modules/weapons/projectiles/RocketOld.cc
r11000 r11004 70 70 if (GameMode::isMaster()) 71 71 { 72 this->setCollisionType(WorldEntity:: Kinematic);72 this->setCollisionType(WorldEntity::CollisionType::Kinematic); 73 73 this->setVelocity(0,0,-100); 74 74 … … 92 92 this->enableCollisionCallback(); 93 93 this->setCollisionResponse(false); 94 this->setCollisionType( Kinematic);94 this->setCollisionType(CollisionType::Kinematic); 95 95 96 96 // Add collision shape -
code/branches/cpp11_v2/src/modules/weapons/projectiles/SimpleRocket.cc
r11000 r11004 70 70 if (GameMode::isMaster()) 71 71 { 72 this->setCollisionType(WorldEntity:: Kinematic);72 this->setCollisionType(WorldEntity::CollisionType::Kinematic); 73 73 this->fuel_ = true; 74 74 … … 87 87 this->enableCollisionCallback(); 88 88 this->setCollisionResponse(false); 89 this->setCollisionType( Kinematic);89 this->setCollisionType(CollisionType::Kinematic); 90 90 91 91 // Add collision shape. -
code/branches/cpp11_v2/src/orxonox/worldentities/Drone.cc
r10818 r11004 49 49 this->localAngularAcceleration_.setValue(0, 0, 0); 50 50 this->setRadarVisibility(false); 51 this->setCollisionType(WorldEntity:: Dynamic);51 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 52 52 53 53 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 189 189 bool MobileEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const 190 190 { 191 if (type == WorldEntity:: Static)191 if (type == WorldEntity::CollisionType::Static) 192 192 { 193 193 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 95 95 bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const 96 96 { 97 if (type == WorldEntity:: Kinematic || type == WorldEntity::Dynamic)97 if (type == WorldEntity::CollisionType::Kinematic || type == WorldEntity::CollisionType::Dynamic) 98 98 { 99 99 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 56 56 57 57 // 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"); 61 61 62 62 RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>(); … … 95 95 this->collisionShape_ = new WorldEntityCollisionShape(this->getContext()); 96 96 this->collisionShape_->setWorldEntityOwner(this); 97 this->collisionType_ = None;98 this->collisionTypeSynchronised_ = None;97 this->collisionType_ = CollisionType::None; 98 this->collisionTypeSynchronised_ = CollisionType::None; 99 99 this->mass_ = 1.0f; 100 100 this->childrenMass_ = 0; … … 207 207 registerVariable(this->bCollisionResponseActive_, 208 208 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged)); 209 registerVariable( (int&)this->collisionTypeSynchronised_,209 registerVariable(this->collisionTypeSynchronised_, 210 210 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); 211 211 registerVariable(this->bPhysicsActiveSynchronised_, … … 322 322 void WorldEntity::collisionTypeChanged() 323 323 { 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) 328 328 { 329 329 orxout(internal_error) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << endl; … … 681 681 switch (relativeTo) 682 682 { 683 case WorldEntity::Local:683 case TransformSpace::Local: 684 684 // position is relative to parent so transform downwards 685 685 this->setPosition(this->getPosition() + this->getOrientation() * distance); 686 686 break; 687 case WorldEntity::Parent:687 case TransformSpace::Parent: 688 688 this->setPosition(this->getPosition() + distance); 689 689 break; 690 case WorldEntity::World:690 case TransformSpace::World: 691 691 // position is relative to parent so transform upwards 692 692 if (this->node_->getParent()) … … 711 711 switch(relativeTo) 712 712 { 713 case WorldEntity::Local:713 case TransformSpace::Local: 714 714 this->setOrientation(this->getOrientation() * rotation); 715 715 break; 716 case WorldEntity::Parent:716 case TransformSpace::Parent: 717 717 // Rotations are normally relative to local axes, transform up 718 718 this->setOrientation(rotation * this->getOrientation()); 719 719 break; 720 case WorldEntity::World:720 case TransformSpace::World: 721 721 // Rotations are normally relative to local axes, transform up 722 722 this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse() … … 741 741 switch (relativeTo) 742 742 { 743 case WorldEntity::Local:743 case TransformSpace::Local: 744 744 origin = Vector3::ZERO; 745 745 break; 746 case WorldEntity::Parent:746 case TransformSpace::Parent: 747 747 origin = this->getPosition(); 748 748 break; 749 case WorldEntity::World:749 case TransformSpace::World: 750 750 origin = this->getWorldPosition(); 751 751 break; … … 831 831 832 832 // Check whether we have to create or destroy. 833 if (type != None && this->collisionType_ ==None)833 if (type != CollisionType::None && this->collisionType_ == CollisionType::None) 834 834 { 835 835 /* … … 849 849 this->physicalBody_->setActivationState(DISABLE_DEACTIVATION); 850 850 } 851 else if (type == None && this->collisionType_ !=None)851 else if (type == CollisionType::None && this->collisionType_ != CollisionType::None) 852 852 { 853 853 // Destroy rigid body … … 856 856 delete this->physicalBody_; 857 857 this->physicalBody_ = nullptr; 858 this->collisionType_ = None;859 this->collisionTypeSynchronised_ = None;858 this->collisionType_ = CollisionType::None; 859 this->collisionTypeSynchronised_ = CollisionType::None; 860 860 return; 861 861 } … … 864 864 switch (type) 865 865 { 866 case Dynamic:866 case CollisionType::Dynamic: 867 867 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT & !btCollisionObject::CF_KINEMATIC_OBJECT); 868 868 break; 869 case Kinematic:869 case CollisionType::Kinematic: 870 870 this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT) | btCollisionObject::CF_KINEMATIC_OBJECT); 871 871 break; 872 case Static:872 case CollisionType::Static: 873 873 this->physicalBody_->setCollisionFlags((this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT) | btCollisionObject::CF_STATIC_OBJECT); 874 874 break; 875 case None:875 case CollisionType::None: 876 876 assert(false); // Doesn't happen 877 877 return; … … 895 895 CollisionType type; 896 896 if (typeStrLower == "dynamic") 897 type = Dynamic;897 type = CollisionType::Dynamic; 898 898 else if (typeStrLower == "static") 899 type = Static;899 type = CollisionType::Static; 900 900 else if (typeStrLower == "kinematic") 901 type = Kinematic;901 type = CollisionType::Kinematic; 902 902 else if (typeStrLower == "none") 903 type = None;903 type = CollisionType::None; 904 904 else 905 905 ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'."); … … 912 912 switch (this->getCollisionType()) 913 913 { 914 case Dynamic:914 case CollisionType::Dynamic: 915 915 return "dynamic"; 916 case Kinematic:916 case CollisionType::Kinematic: 917 917 return "kinematic"; 918 case Static:918 case CollisionType::Static: 919 919 return "static"; 920 case None:920 case CollisionType::None: 921 921 return "none"; 922 922 default: -
code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.h
r10817 r11004 82 82 Enumeration denoting the spaces which a transform can be relative to. 83 83 */ 84 enum TransformSpace84 enum class TransformSpace 85 85 { 86 86 //! Transform is relative to the local space … … 117 117 const Vector3& getWorldPosition() const; 118 118 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) 121 121 { this->translate(Vector3(x, y, z), relativeTo); } 122 122 … … 134 134 const Quaternion& getWorldOrientation() const; 135 135 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) 138 138 { this->rotate(Quaternion(angle, axis), relativeTo); } 139 139 140 inline void yaw(const Degree& angle, TransformSpace relativeTo = WorldEntity::Local)140 inline void yaw(const Degree& angle, TransformSpace relativeTo = TransformSpace::Local) 141 141 { 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) 143 143 { 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) 145 145 { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); } 146 146 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) 150 150 { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); } 151 151 … … 257 257 None: The object has no physics at all. 258 258 */ 259 enum CollisionType259 enum class CollisionType 260 260 { 261 261 Dynamic, … … 266 266 267 267 //! 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 ; } 269 269 //! @see CollisionType 270 bool isStatic() const { return getCollisionType() == Static ; }270 bool isStatic() const { return getCollisionType() == CollisionType::Static ; } 271 271 //! @see CollisionType 272 bool isKinematic() const { return getCollisionType() == Kinematic; }272 bool isKinematic() const { return getCollisionType() == CollisionType::Kinematic; } 273 273 //! @see CollisionType 274 bool isDynamic() const { return getCollisionType() == Dynamic ; }274 bool isDynamic() const { return getCollisionType() == CollisionType::Dynamic ; } 275 275 //! Tells whether physics has been activated (you can temporarily deactivate it) 276 276 bool isPhysicsActive() const { return this->bPhysicsActive_; } -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/FpsPlayer.cc
r10818 r11004 79 79 // FpsPlayer is always a physical object per default 80 80 // 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); 82 82 // Get notification about collisions 83 83 this->enableCollisionCallback(); … … 130 130 bool FpsPlayer::isCollisionTypeLegal(WorldEntity::CollisionType type) const 131 131 { 132 if (type != WorldEntity:: Dynamic)132 if (type != WorldEntity::CollisionType::Dynamic) 133 133 { 134 134 orxout(internal_warning) << "Cannot tell a FpsPlayer not to be dynamic! Ignoring." << endl; … … 168 168 if (!this->isInMouseLook()) 169 169 { 170 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity:: Parent);170 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::TransformSpace::Parent); 171 171 172 172 Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch(); -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
r10916 r11004 80 80 // SpaceShip is always a physical object per default 81 81 // 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); 83 83 // Get notification about collisions 84 84 this->enableCollisionCallback(); … … 143 143 bool SpaceShip::isCollisionTypeLegal(WorldEntity::CollisionType type) const 144 144 { 145 if (type != WorldEntity:: Dynamic)145 if (type != WorldEntity::CollisionType::Dynamic) 146 146 { 147 147 orxout(internal_warning) << "Cannot tell a SpaceShip not to be dynamic! Ignoring." << endl;
Note: See TracChangeset
for help on using the changeset viewer.