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,15 +28,16 @@
: 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) {
isMotionEnabled = true;
isCollisionEnabled = true;
interpolationFactor = 0.0;
restitution = 1.0;
isMotionEnabled = true;
isCollisionEnabled = true;
interpolationFactor = 0.0;
// Update the orientation of the OBB according to the orientation of the rigid body
this->update();
// Update the orientation of the OBB according to the orientation of the rigid body
this->update();
// Set the body pointer to the OBB
this->obb.setBodyPointer(this);
// Set the body pointer to the OBB
this->obb.setBodyPointer(this);
}
// Copy-constructor

View File

@ -49,6 +49,7 @@ class RigidBody : public Body {
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
public :
@ -67,6 +68,8 @@ class RigidBody : public 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
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
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
@ -141,6 +144,16 @@ inline void RigidBody::setLinearVelocity(const Vector3D& linearVelocity) {
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
inline void RigidBody::updatePreviousBodyState() {
// The current body state becomes the previous body state