diff --git a/sources/reactphysics3d/engine/PhysicsWorld.cpp b/sources/reactphysics3d/engine/PhysicsWorld.cpp index dc764d85..47c5b37d 100644 --- a/sources/reactphysics3d/engine/PhysicsWorld.cpp +++ b/sources/reactphysics3d/engine/PhysicsWorld.cpp @@ -24,7 +24,7 @@ using namespace reactphysics3d; // Constructor -PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity) { +PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity), isGravityOn(true) { } @@ -32,6 +32,7 @@ PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity) { PhysicsWorld::PhysicsWorld(const PhysicsWorld& world) { bodyList = world.bodyList; gravity = world.gravity; + isGravityOn = world.isGravityOn; } // Destructor diff --git a/sources/reactphysics3d/engine/PhysicsWorld.h b/sources/reactphysics3d/engine/PhysicsWorld.h index 90b38f9d..92ddcf5f 100644 --- a/sources/reactphysics3d/engine/PhysicsWorld.h +++ b/sources/reactphysics3d/engine/PhysicsWorld.h @@ -40,6 +40,7 @@ class PhysicsWorld { protected : std::vector bodyList; // list that contains all bodies of the physics world Vector3D gravity; // Gravity vector of the world + bool isGravityOn; // True if the gravity force is on public : PhysicsWorld(const Vector3D& gravity); // Constructor @@ -49,6 +50,8 @@ class PhysicsWorld { void addBody(Body* body) throw(std::invalid_argument); // Add a body to the physics world void removeBody(Body const* const body) throw(std::invalid_argument); // Remove a body from the physics world Vector3D getGravity() const; // Return the gravity vector of the world + bool getIsGravityOn() const; // Return if the gravity is on + void setIsGratityOn(bool isGravityOn); // Set the isGravityOn attribute std::vector::const_iterator getBodyListStartIterator() const; // Return a start iterator on the body list std::vector::const_iterator getBodyListEndIterator() const; // Return a end iterator on the body list }; @@ -72,6 +75,16 @@ inline std::vector::const_iterator PhysicsWorld::getBodyListEndIterator() return bodyList.end(); } +// Return if the gravity is on +inline bool PhysicsWorld::getIsGravityOn() const { + return isGravityOn; +} + +// Set the isGravityOn attribute +inline void PhysicsWorld::setIsGratityOn(bool isGravityOn) { + this->isGravityOn = isGravityOn; +} + } // End of the ReactPhysics3D namespace #endif