From 92dabf7f7ffb3f21d29d4b04cf5ba7b8996b814d Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 5 Jul 2010 19:29:14 +0000 Subject: [PATCH] Add the isCollisionEnabled and isMotionEnabled value git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@342 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/body/Body.h | 38 +++++++++++++++++++++---- sources/reactphysics3d/body/RigidBody.h | 16 +---------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/sources/reactphysics3d/body/Body.h b/sources/reactphysics3d/body/Body.h index dabfe678..fb1cd2ff 100644 --- a/sources/reactphysics3d/body/Body.h +++ b/sources/reactphysics3d/body/Body.h @@ -34,16 +34,22 @@ namespace reactphysics3d { ------------------------------------------------------------------- */ class Body { - private : + protected : Kilogram mass; // Mass of the body + bool isMotionEnabled; // True if the body is able to move + bool isCollisionEnabled; // True if the body can collide with others bodies public : - Body(Kilogram mass) throw(std::invalid_argument); // Constructor - Body(const Body& body); // Copy-constructor - virtual ~Body(); // Destructor + Body(Kilogram mass) throw(std::invalid_argument); // Constructor + Body(const Body& body); // Copy-constructor + virtual ~Body(); // Destructor - Kilogram getMass() const; // Return the mass of the body - void setMass(Kilogram mass); // Set the mass of the body + Kilogram getMass() const; // Return the mass of the body + void setMass(Kilogram mass); // Set the mass of the body + bool getIsMotionEnabled() const; // Return if the rigid body can move + void setIsMotionEnabled(bool isMotionEnabled); // Set the value to true if the body can move + bool getIsCollisionEnabled() const; // Return true if the body can collide with others bodies + void setIsCollisionEnabled(bool isCollisionEnabled); // Set the isCollisionEnabled value }; // --- Inlines function --- // @@ -53,11 +59,31 @@ inline Kilogram Body::getMass() const { return mass; }; +// Return if the rigid body can move +inline bool Body::getIsMotionEnabled() const { + return isMotionEnabled; +} + +// Set the value to true if the body can move +inline void Body::setIsMotionEnabled(bool isMotionEnabled) { + this->isMotionEnabled = isMotionEnabled; +} + // Method that set the mass of the body inline void Body::setMass(Kilogram mass) { this->mass = mass; } + // Return true if the body can collide with others bodies +inline bool Body::getIsCollisionEnabled() const { + return isCollisionEnabled; +} + +// Set the isCollisionEnabled value +inline void Body::setIsCollisionEnabled(bool isCollisionEnabled) { + this->isCollisionEnabled = isCollisionEnabled; +} + } #endif diff --git a/sources/reactphysics3d/body/RigidBody.h b/sources/reactphysics3d/body/RigidBody.h index 18fda97b..08189e45 100644 --- a/sources/reactphysics3d/body/RigidBody.h +++ b/sources/reactphysics3d/body/RigidBody.h @@ -42,12 +42,10 @@ namespace reactphysics3d { ------------------------------------------------------------------- */ class RigidBody : public Body { - private : + protected : Matrix3x3 inertiaTensorLocal; // Local inertia tensor of the body (in body coordinates) BodyState currentBodyState; // Current body state BodyState previousBodyState; // Previous body state - bool isMotionEnabled; // True if the body can move - bool isCollisionEnabled; // True if the body can collide with others bodies double interpolationFactor; // Interpolation factor used for the state interpolation double restitution; // Coefficient of restitution (between 0 and 1), 1 for a very boucing body OBB obb; // Oriented bounding box that contains the rigid body @@ -65,8 +63,6 @@ class RigidBody : public Body { BodyState& getPreviousBodyState(); // TODO : DELETE THIS void setInterpolationFactor(double factor); // Set the interpolation factor of the body BodyState getInterpolatedState() const; // Compute and return the interpolated state - bool getIsMotionEnabled() const; // Return if the rigid body can move - void setIsMotionEnabled(bool isMotionEnabled); // Set the value to true if the body can move void setLinearVelocity(const Vector3D& linearVelocity); // Set the linear velocity of the rigid body double getRestitution() const; // Get the restitution coefficient void setRestitution(double restitution); // Set the restitution coefficient @@ -125,16 +121,6 @@ inline void RigidBody::setInterpolationFactor(double factor) { interpolationFactor = factor; } -// Return if the rigid body can move -inline bool RigidBody::getIsMotionEnabled() const { - return isMotionEnabled; -} - -// Set the value to true if the body can move -inline void RigidBody::setIsMotionEnabled(bool isMotionEnabled) { - this->isMotionEnabled = isMotionEnabled; -} - // Set the linear velocity of the rigid body inline void RigidBody::setLinearVelocity(const Vector3D& linearVelocity) { // Update the linear velocity of the current body state