Add the restitution coefficient

git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@341 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
chappuis.daniel 2010-07-05 10:27:35 +00:00
parent 70e22a2dd8
commit 23438486a6
2 changed files with 21 additions and 7 deletions

View File

@ -28,6 +28,7 @@
: Body(mass), inertiaTensorLocal(inertiaTensorLocal), currentBodyState(position, orientation, inertiaTensorLocal.getInverse(), Kilogram(1.0/mass.getValue())), : Body(mass), inertiaTensorLocal(inertiaTensorLocal), currentBodyState(position, orientation, inertiaTensorLocal.getInverse(), Kilogram(1.0/mass.getValue())),
previousBodyState(position, orientation, inertiaTensorLocal.getInverse(), Kilogram(1.0/mass.getValue())), obb(obb) { previousBodyState(position, orientation, inertiaTensorLocal.getInverse(), Kilogram(1.0/mass.getValue())), obb(obb) {
restitution = 1.0;
isMotionEnabled = true; isMotionEnabled = true;
isCollisionEnabled = true; isCollisionEnabled = true;
interpolationFactor = 0.0; interpolationFactor = 0.0;

View File

@ -49,6 +49,7 @@ class RigidBody : public Body {
bool isMotionEnabled; // True if the body can move bool isMotionEnabled; // True if the body can move
bool isCollisionEnabled; // True if the body can collide with others bodies bool isCollisionEnabled; // True if the body can collide with others bodies
double interpolationFactor; // Interpolation factor used for the state interpolation 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 OBB obb; // Oriented bounding box that contains the rigid body
public : public :
@ -67,6 +68,8 @@ class RigidBody : public Body {
bool getIsMotionEnabled() const; // Return if the rigid body can move 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 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 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
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
@ -141,6 +144,16 @@ inline void RigidBody::setLinearVelocity(const Vector3D& linearVelocity) {
currentBodyState.setLinearMomentum(linearVelocity * (1.0/currentBodyState.getMassInverse().getValue())); currentBodyState.setLinearMomentum(linearVelocity * (1.0/currentBodyState.getMassInverse().getValue()));
} }
// Get the restitution coeffficient of the rigid body
inline double RigidBody::getRestitution() const {
return restitution;
}
// Set the restitution coefficient
inline void RigidBody::setRestitution(double restitution) {
this->restitution = restitution;
}
// Update the previous body state of the body // Update the previous body state of the body
inline void RigidBody::updatePreviousBodyState() { inline void RigidBody::updatePreviousBodyState() {
// The current body state becomes the previous body state // The current body state becomes the previous body state