Throw an exception if the argument to setRestitution() is not between 0 and 1
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@350 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
874d96ad00
commit
f57cd95dba
|
@ -65,7 +65,7 @@ class RigidBody : public Body {
|
||||||
BodyState getInterpolatedState() const; // Compute and return the interpolated state
|
BodyState getInterpolatedState() const; // Compute and return the interpolated state
|
||||||
void setLinearVelocity(const Vector3D& linearVelocity); // Set the linear velocity of the rigid body
|
void setLinearVelocity(const Vector3D& linearVelocity); // Set the linear velocity of the rigid body
|
||||||
double getRestitution() const; // Get the restitution coefficient
|
double getRestitution() const; // Get the restitution coefficient
|
||||||
void setRestitution(double restitution); // Set the restitution coefficient
|
void setRestitution(double restitution) throw(std::invalid_argument); // Set the restitution coefficient
|
||||||
void updatePreviousBodyState(); // Update the previous body state of the body
|
void updatePreviousBodyState(); // Update the previous body state of the body
|
||||||
const OBB* const getOBB() const; // Return the oriented bounding box of the rigid body
|
const OBB* const getOBB() const; // Return the oriented bounding box of the rigid body
|
||||||
void update(); // Update the rigid body in order to reflect a change in the body state
|
void update(); // Update the rigid body in order to reflect a change in the body state
|
||||||
|
@ -139,8 +139,14 @@ inline double RigidBody::getRestitution() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the restitution coefficient
|
// Set the restitution coefficient
|
||||||
inline void RigidBody::setRestitution(double restitution) {
|
inline void RigidBody::setRestitution(double restitution) throw(std::invalid_argument) {
|
||||||
|
// Check if the restitution coefficient is between 0 and 1
|
||||||
|
if (restitution >= 0.0 && restitution <= 1.0) {
|
||||||
this->restitution = restitution;
|
this->restitution = restitution;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw std::invalid_argument("Error : the restitution coefficent must be between 0 and 1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the previous body state of the body
|
// Update the previous body state of the body
|
||||||
|
|
Loading…
Reference in New Issue
Block a user