From f7ce70d139effc5553c4ed2fa604724413b9d9b2 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 6 Aug 2017 17:03:05 +0100 Subject: Adding clang format with my style based on google --- include/YAGE/Physics/body.hpp | 68 +++++++++++++++--------------- include/YAGE/Physics/collider.hpp | 29 ++++++------- include/YAGE/Physics/collisionbody.hpp | 8 ++-- include/YAGE/Physics/particlebody.hpp | 23 +++++----- include/YAGE/Physics/rectanglecollider.hpp | 14 +++--- include/YAGE/Physics/rigidbody.hpp | 14 +++--- 6 files changed, 71 insertions(+), 85 deletions(-) (limited to 'include/YAGE/Physics') diff --git a/include/YAGE/Physics/body.hpp b/include/YAGE/Physics/body.hpp index b0869779..f32b767d 100644 --- a/include/YAGE/Physics/body.hpp +++ b/include/YAGE/Physics/body.hpp @@ -11,48 +11,46 @@ #include "Math/matrix.hpp" -namespace yage -{ +namespace yage { -class Body -{ +class Body { public: - // gravity constant - static const double GRAVITY; + // gravity constant + static const double GRAVITY; + protected: - // center of mass of the object - Vector2d position_=Vector2d(0, 0); - - // mass of the object - double mass_=1; - - // current velocity of the object - Vector2d velocity_=Vector2d(0, 0); - - // boolean that defines if gravity can act on the object - bool gravity_=true; - - // current acceleration - Vector2d acceleration_=Vector2d(0, 0); - - // force acting on the body - Vector2d force_=Vector2d(0, 0); - + // center of mass of the object + Vector2d position_ = Vector2d(0, 0); + + // mass of the object + double mass_ = 1; + + // current velocity of the object + Vector2d velocity_ = Vector2d(0, 0); + + // boolean that defines if gravity can act on the object + bool gravity_ = true; + + // current acceleration + Vector2d acceleration_ = Vector2d(0, 0); + + // force acting on the body + Vector2d force_ = Vector2d(0, 0); + public: - // apply force to the object and update the velocity - virtual void applyForce(const Vector2d &force)=0; - virtual void update()=0; + // apply force to the object and update the velocity + virtual void applyForce(const Vector2d& force) = 0; + virtual void update() = 0; + + double xPosition() const; + double yPosition() const; - double xPosition() const; - double yPosition() const; protected: - // protected constructor to initialize member variables - Body(const Vector2d &position=Vector2d(0, 0), - double mass=1, - const Vector2d &velocity=Vector2d(0, 0), - bool gravity=false); + // protected constructor to initialize member variables + Body(const Vector2d& position = Vector2d(0, 0), double mass = 1, + const Vector2d& velocity = Vector2d(0, 0), bool gravity = false); }; -} // namespace yage +} // namespace yage #endif diff --git a/include/YAGE/Physics/collider.hpp b/include/YAGE/Physics/collider.hpp index 716b7d4c..92b90de2 100644 --- a/include/YAGE/Physics/collider.hpp +++ b/include/YAGE/Physics/collider.hpp @@ -11,30 +11,29 @@ #include -namespace yage -{ +namespace yage { // The Collider class helps collision detection by providing a general shape // for different shapes to have their own collision algorithms. -class Collider -{ +class Collider { protected: - // position of the object - glm::vec2 position_; + // position of the object + glm::vec2 position_; + + // size of the object + glm::vec2 size_; - // size of the object - glm::vec2 size_; - public: - Collider(const glm::vec2 &position, const glm::vec2 &size) : position_(position), size_(size) {} + Collider(const glm::vec2& position, const glm::vec2& size) + : position_(position), size_(size) {} - // function that checks if two colliders are colliding - virtual bool collides(const Collider &collider) const=0; + // function that checks if two colliders are colliding + virtual bool collides(const Collider& collider) const = 0; - // function that returns if a point is inside the shape - virtual bool inside(const glm::vec2 &point) const=0; + // function that returns if a point is inside the shape + virtual bool inside(const glm::vec2& point) const = 0; }; -} // namespace yage +} // namespace yage #endif diff --git a/include/YAGE/Physics/collisionbody.hpp b/include/YAGE/Physics/collisionbody.hpp index b7403e81..5ddacacd 100644 --- a/include/YAGE/Physics/collisionbody.hpp +++ b/include/YAGE/Physics/collisionbody.hpp @@ -11,18 +11,16 @@ #include "Physics/body.hpp" -namespace yage -{ +namespace yage { // a collision body will be a body that is static and not affected by gravity, // with infinite mass -class CollisionBody : public Body -{ +class CollisionBody : public Body { public: CollisionBody(); virtual ~CollisionBody(); }; -} // yage +} // yage #endif diff --git a/include/YAGE/Physics/particlebody.hpp b/include/YAGE/Physics/particlebody.hpp index e107cb6a..ff8b3b85 100644 --- a/include/YAGE/Physics/particlebody.hpp +++ b/include/YAGE/Physics/particlebody.hpp @@ -13,22 +13,19 @@ #include "body.hpp" -namespace yage -{ +namespace yage { -class ParticleBody : public Body -{ +class ParticleBody : public Body { public: - ParticleBody(const Vector2d &position=Vector2d(0, 0), - double mass=1, - const Vector2d &velocity=Vector2d(0, 0), - bool gravity=true); - - // apply a force to the rigid body - virtual void applyForce(const Vector2d &force); - virtual void update(); + ParticleBody(const Vector2d& position = Vector2d(0, 0), double mass = 1, + const Vector2d& velocity = Vector2d(0, 0), + bool gravity = true); + + // apply a force to the rigid body + virtual void applyForce(const Vector2d& force); + virtual void update(); }; -} // yage +} // yage #endif diff --git a/include/YAGE/Physics/rectanglecollider.hpp b/include/YAGE/Physics/rectanglecollider.hpp index 62f11100..7f9dd7f7 100644 --- a/include/YAGE/Physics/rectanglecollider.hpp +++ b/include/YAGE/Physics/rectanglecollider.hpp @@ -13,18 +13,16 @@ #include -namespace yage -{ +namespace yage { -class RectangleCollider : public Collider -{ +class RectangleCollider : public Collider { public: - RectangleCollider(const glm::vec2 &position, const glm::vec2 &size); + RectangleCollider(const glm::vec2& position, const glm::vec2& size); - virtual bool collides(const Collider &collider) const; - virtual bool inside(const glm::vec2 &point) const; + virtual bool collides(const Collider& collider) const; + virtual bool inside(const glm::vec2& point) const; }; -} // yage +} // yage #endif diff --git a/include/YAGE/Physics/rigidbody.hpp b/include/YAGE/Physics/rigidbody.hpp index c8a2e497..fd19dc7c 100644 --- a/include/YAGE/Physics/rigidbody.hpp +++ b/include/YAGE/Physics/rigidbody.hpp @@ -13,18 +13,14 @@ #include "particlebody.hpp" -namespace yage -{ +namespace yage { -class RigidBody : public ParticleBody -{ +class RigidBody : public ParticleBody { public: - RigidBody(const Vector2d &position=Vector2d(0, 0), - double mass=1, - const Vector2d &velocity=Vector2d(0, 0), - bool gravity=true); + RigidBody(const Vector2d& position = Vector2d(0, 0), double mass = 1, + const Vector2d& velocity = Vector2d(0, 0), bool gravity = true); }; -} // yage +} // yage #endif -- cgit