Fix virtual constructors, use c++11 scoped enums, use c++11 delete methods instead of private constructors
This commit is contained in:
parent
be957ba41a
commit
f5ade0f52d
|
@ -75,14 +75,6 @@ class Body {
|
||||||
/// Pointer that can be used to attach user data to the body
|
/// Pointer that can be used to attach user data to the body
|
||||||
void* mUserData;
|
void* mUserData;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
Body(const Body& body);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Body& operator=(const Body& body);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -90,6 +82,12 @@ class Body {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Body(bodyindex id);
|
Body(bodyindex id);
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
Body(const Body& body) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Body& operator=(const Body& body) = delete;
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~Body();
|
virtual ~Body();
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace reactphysics3d;
|
||||||
* @param id ID of the body
|
* @param id ID of the body
|
||||||
*/
|
*/
|
||||||
CollisionBody::CollisionBody(const Transform& transform, CollisionWorld& world, bodyindex id)
|
CollisionBody::CollisionBody(const Transform& transform, CollisionWorld& world, bodyindex id)
|
||||||
: Body(id), mType(DYNAMIC), mTransform(transform), mProxyCollisionShapes(nullptr),
|
: Body(id), mType(BodyType::DYNAMIC), mTransform(transform), mProxyCollisionShapes(nullptr),
|
||||||
mNbCollisionShapes(0), mContactManifoldsList(nullptr), mWorld(world) {
|
mNbCollisionShapes(0), mContactManifoldsList(nullptr), mWorld(world) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class CollisionWorld;
|
||||||
/// DYNAMIC : A dynamic body has non-zero mass, non-zero velocity determined by forces and its
|
/// DYNAMIC : A dynamic body has non-zero mass, non-zero velocity determined by forces and its
|
||||||
/// position is determined by the physics engine. A dynamic body can collide with other
|
/// position is determined by the physics engine. A dynamic body can collide with other
|
||||||
/// dynamic, static or kinematic bodies.
|
/// dynamic, static or kinematic bodies.
|
||||||
enum BodyType {STATIC, KINEMATIC, DYNAMIC};
|
enum class BodyType {STATIC, KINEMATIC, DYNAMIC};
|
||||||
|
|
||||||
// Class CollisionBody
|
// Class CollisionBody
|
||||||
/**
|
/**
|
||||||
|
@ -87,12 +87,6 @@ class CollisionBody : public Body {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CollisionBody(const CollisionBody& body);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CollisionBody& operator=(const CollisionBody& body);
|
|
||||||
|
|
||||||
/// Reset the contact manifold lists
|
/// Reset the contact manifold lists
|
||||||
void resetContactManifoldsList();
|
void resetContactManifoldsList();
|
||||||
|
|
||||||
|
@ -122,6 +116,12 @@ class CollisionBody : public Body {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CollisionBody();
|
virtual ~CollisionBody();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CollisionBody(const CollisionBody& body) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CollisionBody& operator=(const CollisionBody& body) = delete;
|
||||||
|
|
||||||
/// Return the type of the body
|
/// Return the type of the body
|
||||||
BodyType getType() const;
|
BodyType getType() const;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ inline BodyType CollisionBody::getType() const {
|
||||||
inline void CollisionBody::setType(BodyType type) {
|
inline void CollisionBody::setType(BodyType type) {
|
||||||
mType = type;
|
mType = type;
|
||||||
|
|
||||||
if (mType == STATIC) {
|
if (mType == BodyType::STATIC) {
|
||||||
|
|
||||||
// Update the broad-phase state of the body
|
// Update the broad-phase state of the body
|
||||||
updateBroadPhaseState();
|
updateBroadPhaseState();
|
||||||
|
|
|
@ -76,7 +76,7 @@ void RigidBody::setType(BodyType type) {
|
||||||
recomputeMassInformation();
|
recomputeMassInformation();
|
||||||
|
|
||||||
// If it is a static body
|
// If it is a static body
|
||||||
if (mType == STATIC) {
|
if (mType == BodyType::STATIC) {
|
||||||
|
|
||||||
// Reset the velocity to zero
|
// Reset the velocity to zero
|
||||||
mLinearVelocity.setToZero();
|
mLinearVelocity.setToZero();
|
||||||
|
@ -84,7 +84,7 @@ void RigidBody::setType(BodyType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is a static or a kinematic body
|
// If it is a static or a kinematic body
|
||||||
if (mType == STATIC || mType == KINEMATIC) {
|
if (mType == BodyType::STATIC || mType == BodyType::KINEMATIC) {
|
||||||
|
|
||||||
// Reset the inverse mass and inverse inertia tensor to zero
|
// Reset the inverse mass and inverse inertia tensor to zero
|
||||||
mMassInverse = decimal(0.0);
|
mMassInverse = decimal(0.0);
|
||||||
|
@ -119,7 +119,7 @@ void RigidBody::setType(BodyType type) {
|
||||||
*/
|
*/
|
||||||
void RigidBody::setInertiaTensorLocal(const Matrix3x3& inertiaTensorLocal) {
|
void RigidBody::setInertiaTensorLocal(const Matrix3x3& inertiaTensorLocal) {
|
||||||
|
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
mInertiaTensorLocal = inertiaTensorLocal;
|
mInertiaTensorLocal = inertiaTensorLocal;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void RigidBody::setInertiaTensorLocal(const Matrix3x3& inertiaTensorLocal) {
|
||||||
*/
|
*/
|
||||||
void RigidBody::setCenterOfMassLocal(const Vector3& centerOfMassLocal) {
|
void RigidBody::setCenterOfMassLocal(const Vector3& centerOfMassLocal) {
|
||||||
|
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
const Vector3 oldCenterOfMass = mCenterOfMassWorld;
|
const Vector3 oldCenterOfMass = mCenterOfMassWorld;
|
||||||
mCenterOfMassLocal = centerOfMassLocal;
|
mCenterOfMassLocal = centerOfMassLocal;
|
||||||
|
@ -152,7 +152,7 @@ void RigidBody::setCenterOfMassLocal(const Vector3& centerOfMassLocal) {
|
||||||
*/
|
*/
|
||||||
void RigidBody::setMass(decimal mass) {
|
void RigidBody::setMass(decimal mass) {
|
||||||
|
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
mInitMass = mass;
|
mInitMass = mass;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void RigidBody::removeCollisionShape(const ProxyShape* proxyShape) {
|
||||||
void RigidBody::setLinearVelocity(const Vector3& linearVelocity) {
|
void RigidBody::setLinearVelocity(const Vector3& linearVelocity) {
|
||||||
|
|
||||||
// If it is a static body, we do nothing
|
// If it is a static body, we do nothing
|
||||||
if (mType == STATIC) return;
|
if (mType == BodyType::STATIC) return;
|
||||||
|
|
||||||
// Update the linear velocity of the current body state
|
// Update the linear velocity of the current body state
|
||||||
mLinearVelocity = linearVelocity;
|
mLinearVelocity = linearVelocity;
|
||||||
|
@ -285,7 +285,7 @@ void RigidBody::setLinearVelocity(const Vector3& linearVelocity) {
|
||||||
void RigidBody::setAngularVelocity(const Vector3& angularVelocity) {
|
void RigidBody::setAngularVelocity(const Vector3& angularVelocity) {
|
||||||
|
|
||||||
// If it is a static body, we do nothing
|
// If it is a static body, we do nothing
|
||||||
if (mType == STATIC) return;
|
if (mType == BodyType::STATIC) return;
|
||||||
|
|
||||||
// Set the angular velocity
|
// Set the angular velocity
|
||||||
mAngularVelocity = angularVelocity;
|
mAngularVelocity = angularVelocity;
|
||||||
|
@ -329,12 +329,12 @@ void RigidBody::recomputeMassInformation() {
|
||||||
mCenterOfMassLocal.setToZero();
|
mCenterOfMassLocal.setToZero();
|
||||||
|
|
||||||
// If it is STATIC or KINEMATIC body
|
// If it is STATIC or KINEMATIC body
|
||||||
if (mType == STATIC || mType == KINEMATIC) {
|
if (mType == BodyType::STATIC || mType == BodyType::KINEMATIC) {
|
||||||
mCenterOfMassWorld = mTransform.getPosition();
|
mCenterOfMassWorld = mTransform.getPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(mType == DYNAMIC);
|
assert(mType == BodyType::DYNAMIC);
|
||||||
|
|
||||||
// Compute the total mass of the body
|
// Compute the total mass of the body
|
||||||
for (ProxyShape* shape = mProxyCollisionShapes; shape != nullptr; shape = shape->mNext) {
|
for (ProxyShape* shape = mProxyCollisionShapes; shape != nullptr; shape = shape->mNext) {
|
||||||
|
|
|
@ -103,12 +103,6 @@ class RigidBody : public CollisionBody {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
RigidBody(const RigidBody& body);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
RigidBody& operator=(const RigidBody& body);
|
|
||||||
|
|
||||||
/// Remove a joint from the joints list
|
/// Remove a joint from the joints list
|
||||||
void removeJointFromJointsList(MemoryAllocator& memoryAllocator, const Joint* joint);
|
void removeJointFromJointsList(MemoryAllocator& memoryAllocator, const Joint* joint);
|
||||||
|
|
||||||
|
@ -128,6 +122,12 @@ class RigidBody : public CollisionBody {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~RigidBody();
|
virtual ~RigidBody();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
RigidBody(const RigidBody& body) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
RigidBody& operator=(const RigidBody& body) = delete;
|
||||||
|
|
||||||
/// Set the type of the body (static, kinematic or dynamic)
|
/// Set the type of the body (static, kinematic or dynamic)
|
||||||
void setType(BodyType type);
|
void setType(BodyType type);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ inline void RigidBody::setIsSleeping(bool isSleeping) {
|
||||||
inline void RigidBody::applyForceToCenterOfMass(const Vector3& force) {
|
inline void RigidBody::applyForceToCenterOfMass(const Vector3& force) {
|
||||||
|
|
||||||
// If it is not a dynamic body, we do nothing
|
// If it is not a dynamic body, we do nothing
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
// Awake the body if it was sleeping
|
// Awake the body if it was sleeping
|
||||||
if (mIsSleeping) {
|
if (mIsSleeping) {
|
||||||
|
@ -432,7 +432,7 @@ inline void RigidBody::applyForceToCenterOfMass(const Vector3& force) {
|
||||||
inline void RigidBody::applyForce(const Vector3& force, const Vector3& point) {
|
inline void RigidBody::applyForce(const Vector3& force, const Vector3& point) {
|
||||||
|
|
||||||
// If it is not a dynamic body, we do nothing
|
// If it is not a dynamic body, we do nothing
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
// Awake the body if it was sleeping
|
// Awake the body if it was sleeping
|
||||||
if (mIsSleeping) {
|
if (mIsSleeping) {
|
||||||
|
@ -455,7 +455,7 @@ inline void RigidBody::applyForce(const Vector3& force, const Vector3& point) {
|
||||||
inline void RigidBody::applyTorque(const Vector3& torque) {
|
inline void RigidBody::applyTorque(const Vector3& torque) {
|
||||||
|
|
||||||
// If it is not a dynamic body, we do nothing
|
// If it is not a dynamic body, we do nothing
|
||||||
if (mType != DYNAMIC) return;
|
if (mType != BodyType::DYNAMIC) return;
|
||||||
|
|
||||||
// Awake the body if it was sleeping
|
// Awake the body if it was sleeping
|
||||||
if (mIsSleeping) {
|
if (mIsSleeping) {
|
||||||
|
|
|
@ -209,8 +209,8 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
pair->update();
|
pair->update();
|
||||||
|
|
||||||
// Check that at least one body is awake and not static
|
// Check that at least one body is awake and not static
|
||||||
bool isBody1Active = !body1->isSleeping() && body1->getType() != STATIC;
|
bool isBody1Active = !body1->isSleeping() && body1->getType() != BodyType::STATIC;
|
||||||
bool isBody2Active = !body2->isSleeping() && body2->getType() != STATIC;
|
bool isBody2Active = !body2->isSleeping() && body2->getType() != BodyType::STATIC;
|
||||||
if (!isBody1Active && !isBody2Active) continue;
|
if (!isBody1Active && !isBody2Active) continue;
|
||||||
|
|
||||||
// Check if the bodies are in the set of bodies that cannot collide between each other
|
// Check if the bodies are in the set of bodies that cannot collide between each other
|
||||||
|
@ -220,7 +220,9 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
// Select the narrow phase algorithm to use according to the two collision shapes
|
// Select the narrow phase algorithm to use according to the two collision shapes
|
||||||
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
|
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
|
||||||
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
||||||
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Type][shape2Type];
|
const int shape1Index = static_cast<int>(shape1Type);
|
||||||
|
const int shape2Index = static_cast<int>(shape2Type);
|
||||||
|
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Index][shape2Index];
|
||||||
|
|
||||||
// If there is no collision algorithm between those two kinds of shapes
|
// If there is no collision algorithm between those two kinds of shapes
|
||||||
if (narrowPhaseAlgorithm == nullptr) continue;
|
if (narrowPhaseAlgorithm == nullptr) continue;
|
||||||
|
@ -312,7 +314,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
|
||||||
pair->update();
|
pair->update();
|
||||||
|
|
||||||
// Check if the two bodies are allowed to collide, otherwise, we do not test for collision
|
// Check if the two bodies are allowed to collide, otherwise, we do not test for collision
|
||||||
if (body1->getType() != DYNAMIC && body2->getType() != DYNAMIC) continue;
|
if (body1->getType() != BodyType::DYNAMIC && body2->getType() != BodyType::DYNAMIC) continue;
|
||||||
bodyindexpair bodiesIndex = OverlappingPair::computeBodiesIndexPair(body1, body2);
|
bodyindexpair bodiesIndex = OverlappingPair::computeBodiesIndexPair(body1, body2);
|
||||||
if (mNoCollisionPairs.count(bodiesIndex) > 0) continue;
|
if (mNoCollisionPairs.count(bodiesIndex) > 0) continue;
|
||||||
|
|
||||||
|
@ -322,7 +324,9 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
|
||||||
// Select the narrow phase algorithm to use according to the two collision shapes
|
// Select the narrow phase algorithm to use according to the two collision shapes
|
||||||
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
|
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
|
||||||
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
||||||
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Type][shape2Type];
|
const int shape1Index = static_cast<int>(shape1Type);
|
||||||
|
const int shape2Index = static_cast<int>(shape2Type);
|
||||||
|
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Index][shape2Index];
|
||||||
|
|
||||||
// If there is no collision algorithm between those two kinds of shapes
|
// If there is no collision algorithm between those two kinds of shapes
|
||||||
if (narrowPhaseAlgorithm == nullptr) continue;
|
if (narrowPhaseAlgorithm == nullptr) continue;
|
||||||
|
|
|
@ -116,12 +116,6 @@ class CollisionDetection : public NarrowPhaseCallback {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CollisionDetection(const CollisionDetection& collisionDetection);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CollisionDetection& operator=(const CollisionDetection& collisionDetection);
|
|
||||||
|
|
||||||
/// Compute the broad-phase collision detection
|
/// Compute the broad-phase collision detection
|
||||||
void computeBroadPhase();
|
void computeBroadPhase();
|
||||||
|
|
||||||
|
@ -151,6 +145,12 @@ class CollisionDetection : public NarrowPhaseCallback {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~CollisionDetection();
|
~CollisionDetection();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CollisionDetection(const CollisionDetection& collisionDetection) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CollisionDetection& operator=(const CollisionDetection& collisionDetection) = delete;
|
||||||
|
|
||||||
/// Set the collision dispatch configuration
|
/// Set the collision dispatch configuration
|
||||||
void setCollisionDispatch(CollisionDispatch* collisionDispatch);
|
void setCollisionDispatch(CollisionDispatch* collisionDispatch);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class CollisionDetection : public NarrowPhaseCallback {
|
||||||
// Return the Narrow-phase collision detection algorithm to use between two types of shapes
|
// Return the Narrow-phase collision detection algorithm to use between two types of shapes
|
||||||
inline NarrowPhaseAlgorithm* CollisionDetection::getCollisionAlgorithm(CollisionShapeType shape1Type,
|
inline NarrowPhaseAlgorithm* CollisionDetection::getCollisionAlgorithm(CollisionShapeType shape1Type,
|
||||||
CollisionShapeType shape2Type) const {
|
CollisionShapeType shape2Type) const {
|
||||||
return mCollisionMatrix[shape1Type][shape2Type];
|
return mCollisionMatrix[static_cast<int>(shape1Type)][static_cast<int>(shape2Type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the collision dispatch configuration
|
// Set the collision dispatch configuration
|
||||||
|
|
|
@ -130,12 +130,6 @@ class ContactManifold {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ContactManifold(const ContactManifold& contactManifold);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ContactManifold& operator=(const ContactManifold& contactManifold);
|
|
||||||
|
|
||||||
/// Return the index of maximum area
|
/// Return the index of maximum area
|
||||||
int getMaxArea(decimal area0, decimal area1, decimal area2, decimal area3) const;
|
int getMaxArea(decimal area0, decimal area1, decimal area2, decimal area3) const;
|
||||||
|
|
||||||
|
@ -162,6 +156,12 @@ class ContactManifold {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~ContactManifold();
|
~ContactManifold();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ContactManifold(const ContactManifold& contactManifold) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ContactManifold& operator=(const ContactManifold& contactManifold) = delete;
|
||||||
|
|
||||||
/// Return a pointer to the first proxy shape of the contact
|
/// Return a pointer to the first proxy shape of the contact
|
||||||
ProxyShape* getShape1() const;
|
ProxyShape* getShape1() const;
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,6 @@ class ProxyShape {
|
||||||
/// proxy shape will collide with every collision categories by default.
|
/// proxy shape will collide with every collision categories by default.
|
||||||
unsigned short mCollideWithMaskBits;
|
unsigned short mCollideWithMaskBits;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ProxyShape(const ProxyShape& proxyShape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ProxyShape& operator=(const ProxyShape& proxyShape);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -102,7 +94,13 @@ class ProxyShape {
|
||||||
const Transform& transform, decimal mass);
|
const Transform& transform, decimal mass);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~ProxyShape();
|
virtual ~ProxyShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ProxyShape(const ProxyShape& proxyShape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ProxyShape& operator=(const ProxyShape& proxyShape) = delete;
|
||||||
|
|
||||||
/// Return the collision shape
|
/// Return the collision shape
|
||||||
const CollisionShape* getCollisionShape() const;
|
const CollisionShape* getCollisionShape() const;
|
||||||
|
|
|
@ -46,14 +46,6 @@ struct RaycastInfo {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy constructor
|
|
||||||
RaycastInfo(const RaycastInfo& raycastInfo);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
RaycastInfo& operator=(const RaycastInfo& raycastInfo);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Attributes -------------------- //
|
// -------------------- Attributes -------------------- //
|
||||||
|
@ -91,6 +83,12 @@ struct RaycastInfo {
|
||||||
~RaycastInfo() {
|
~RaycastInfo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deleted copy constructor
|
||||||
|
RaycastInfo(const RaycastInfo& raycastInfo) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
RaycastInfo& operator=(const RaycastInfo& raycastInfo) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class RaycastCallback
|
// Class RaycastCallback
|
||||||
|
|
|
@ -46,10 +46,10 @@ class TriangleVertexArray {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Data type for the vertices in the array
|
/// Data type for the vertices in the array
|
||||||
enum VertexDataType {VERTEX_FLOAT_TYPE, VERTEX_DOUBLE_TYPE};
|
enum class VertexDataType {VERTEX_FLOAT_TYPE, VERTEX_DOUBLE_TYPE};
|
||||||
|
|
||||||
/// Data type for the indices in the array
|
/// Data type for the indices in the array
|
||||||
enum IndexDataType {INDEX_INTEGER_TYPE, INDEX_SHORT_TYPE};
|
enum class IndexDataType {INDEX_INTEGER_TYPE, INDEX_SHORT_TYPE};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,9 @@ class BroadPhaseRaycastCallback : public DynamicAABBTreeRaycastCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~BroadPhaseRaycastCallback() {}
|
||||||
|
|
||||||
// Called for a broad-phase shape that has to be tested for raycast
|
// Called for a broad-phase shape that has to be tested for raycast
|
||||||
virtual decimal raycastBroadPhaseShape(int32 nodeId, const Ray& ray);
|
virtual decimal raycastBroadPhaseShape(int32 nodeId, const Ray& ray);
|
||||||
|
|
||||||
|
@ -160,14 +163,6 @@ class BroadPhaseAlgorithm {
|
||||||
/// Reference to the collision detection object
|
/// Reference to the collision detection object
|
||||||
CollisionDetection& mCollisionDetection;
|
CollisionDetection& mCollisionDetection;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
BroadPhaseAlgorithm(const BroadPhaseAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
BroadPhaseAlgorithm& operator=(const BroadPhaseAlgorithm& algorithm);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -178,6 +173,12 @@ class BroadPhaseAlgorithm {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~BroadPhaseAlgorithm();
|
~BroadPhaseAlgorithm();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
BroadPhaseAlgorithm(const BroadPhaseAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
BroadPhaseAlgorithm& operator=(const BroadPhaseAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
/// Add a proxy collision shape into the broad-phase collision detection
|
/// Add a proxy collision shape into the broad-phase collision detection
|
||||||
void addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb);
|
void addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb);
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,9 @@ class DynamicAABBTreeOverlapCallback {
|
||||||
// Called when a overlapping node has been found during the call to
|
// Called when a overlapping node has been found during the call to
|
||||||
// DynamicAABBTree:reportAllShapesOverlappingWithAABB()
|
// DynamicAABBTree:reportAllShapesOverlappingWithAABB()
|
||||||
virtual void notifyOverlappingNode(int nodeId)=0;
|
virtual void notifyOverlappingNode(int nodeId)=0;
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~DynamicAABBTreeOverlapCallback() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class DynamicAABBTreeRaycastCallback
|
// Class DynamicAABBTreeRaycastCallback
|
||||||
|
@ -115,6 +118,8 @@ class DynamicAABBTreeRaycastCallback {
|
||||||
// Called when the AABB of a leaf node is hit by a ray
|
// Called when the AABB of a leaf node is hit by a ray
|
||||||
virtual decimal raycastBroadPhaseShape(int32 nodeId, const Ray& ray)=0;
|
virtual decimal raycastBroadPhaseShape(int32 nodeId, const Ray& ray)=0;
|
||||||
|
|
||||||
|
virtual ~DynamicAABBTreeRaycastCallback() {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class DynamicAABBTree
|
// Class DynamicAABBTree
|
||||||
|
|
|
@ -263,8 +263,8 @@ void SmoothCollisionNarrowPhaseCallback::notifyContact(OverlappingPair* overlapp
|
||||||
bool isFirstShapeTriangle;
|
bool isFirstShapeTriangle;
|
||||||
|
|
||||||
// If the collision shape 1 is the triangle
|
// If the collision shape 1 is the triangle
|
||||||
if (contactInfo.collisionShape1->getType() == TRIANGLE) {
|
if (contactInfo.collisionShape1->getType() == CollisionShapeType::TRIANGLE) {
|
||||||
assert(contactInfo.collisionShape2->getType() != TRIANGLE);
|
assert(contactInfo.collisionShape2->getType() != CollisionShapeType::TRIANGLE);
|
||||||
|
|
||||||
const TriangleShape* triangleShape = static_cast<const TriangleShape*>(contactInfo.collisionShape1);
|
const TriangleShape* triangleShape = static_cast<const TriangleShape*>(contactInfo.collisionShape1);
|
||||||
triangleVertices[0] = triangleShape->getVertex(0);
|
triangleVertices[0] = triangleShape->getVertex(0);
|
||||||
|
@ -274,7 +274,7 @@ void SmoothCollisionNarrowPhaseCallback::notifyContact(OverlappingPair* overlapp
|
||||||
isFirstShapeTriangle = true;
|
isFirstShapeTriangle = true;
|
||||||
}
|
}
|
||||||
else { // If the collision shape 2 is the triangle
|
else { // If the collision shape 2 is the triangle
|
||||||
assert(contactInfo.collisionShape2->getType() == TRIANGLE);
|
assert(contactInfo.collisionShape2->getType() == CollisionShapeType::TRIANGLE);
|
||||||
|
|
||||||
const TriangleShape* triangleShape = static_cast<const TriangleShape*>(contactInfo.collisionShape2);
|
const TriangleShape* triangleShape = static_cast<const TriangleShape*>(contactInfo.collisionShape2);
|
||||||
triangleVertices[0] = triangleShape->getVertex(0);
|
triangleVertices[0] = triangleShape->getVertex(0);
|
||||||
|
|
|
@ -72,6 +72,9 @@ class ConvexVsTriangleCallback : public TriangleCallback {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~ConvexVsTriangleCallback() {}
|
||||||
|
|
||||||
/// Set the collision detection pointer
|
/// Set the collision detection pointer
|
||||||
void setCollisionDetection(CollisionDetection* collisionDetection) {
|
void setCollisionDetection(CollisionDetection* collisionDetection) {
|
||||||
mCollisionDetection = collisionDetection;
|
mCollisionDetection = collisionDetection;
|
||||||
|
|
|
@ -57,7 +57,7 @@ NarrowPhaseAlgorithm* DefaultCollisionDispatch::selectAlgorithm(int type1, int t
|
||||||
CollisionShapeType shape2Type = static_cast<CollisionShapeType>(type2);
|
CollisionShapeType shape2Type = static_cast<CollisionShapeType>(type2);
|
||||||
|
|
||||||
// Sphere vs Sphere algorithm
|
// Sphere vs Sphere algorithm
|
||||||
if (shape1Type == SPHERE && shape2Type == SPHERE) {
|
if (shape1Type == CollisionShapeType::SPHERE && shape2Type == CollisionShapeType::SPHERE) {
|
||||||
return &mSphereVsSphereAlgorithm;
|
return &mSphereVsSphereAlgorithm;
|
||||||
}
|
}
|
||||||
// Concave vs Convex algorithm
|
// Concave vs Convex algorithm
|
||||||
|
|
|
@ -95,12 +95,6 @@ class EPAAlgorithm {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
EPAAlgorithm(const EPAAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
EPAAlgorithm& operator=(const EPAAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Add a triangle face in the candidate triangle heap
|
/// Add a triangle face in the candidate triangle heap
|
||||||
void addFaceCandidate(TriangleEPA* triangle, TriangleEPA** heap, uint& nbTriangles,
|
void addFaceCandidate(TriangleEPA* triangle, TriangleEPA** heap, uint& nbTriangles,
|
||||||
decimal upperBoundSquarePenDepth);
|
decimal upperBoundSquarePenDepth);
|
||||||
|
@ -119,6 +113,12 @@ class EPAAlgorithm {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~EPAAlgorithm();
|
~EPAAlgorithm();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
EPAAlgorithm(const EPAAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
EPAAlgorithm& operator=(const EPAAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
/// Initalize the algorithm
|
/// Initalize the algorithm
|
||||||
void init(MemoryAllocator* memoryAllocator);
|
void init(MemoryAllocator* memoryAllocator);
|
||||||
|
|
||||||
|
|
|
@ -74,14 +74,6 @@ class TriangleEPA {
|
||||||
/// Square distance of the point closest point v to the origin
|
/// Square distance of the point closest point v to the origin
|
||||||
decimal mDistSquare;
|
decimal mDistSquare;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
TriangleEPA(const TriangleEPA& triangle);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
TriangleEPA& operator=(const TriangleEPA& triangle);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -95,6 +87,12 @@ class TriangleEPA {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~TriangleEPA();
|
~TriangleEPA();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
TriangleEPA(const TriangleEPA& triangle) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
TriangleEPA& operator=(const TriangleEPA& triangle) = delete;
|
||||||
|
|
||||||
/// Return an adjacent edge of the triangle
|
/// Return an adjacent edge of the triangle
|
||||||
EdgeEPA& getAdjacentEdge(int index);
|
EdgeEPA& getAdjacentEdge(int index);
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,6 @@ class TrianglesStore {
|
||||||
/// Number of triangles
|
/// Number of triangles
|
||||||
int mNbTriangles;
|
int mNbTriangles;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
TrianglesStore(const TrianglesStore& triangleStore);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
TrianglesStore& operator=(const TrianglesStore& triangleStore);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -72,6 +64,12 @@ class TrianglesStore {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~TrianglesStore();
|
~TrianglesStore();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
TrianglesStore(const TrianglesStore& triangleStore) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
TrianglesStore& operator=(const TrianglesStore& triangleStore) = delete;
|
||||||
|
|
||||||
/// Clear all the storage
|
/// Clear all the storage
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,6 @@ class GJKAlgorithm : public NarrowPhaseAlgorithm {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
GJKAlgorithm(const GJKAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
GJKAlgorithm& operator=(const GJKAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Compute the penetration depth for enlarged objects.
|
/// Compute the penetration depth for enlarged objects.
|
||||||
void computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info,
|
void computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info,
|
||||||
const Transform& transform1,
|
const Transform& transform1,
|
||||||
|
@ -92,6 +86,12 @@ class GJKAlgorithm : public NarrowPhaseAlgorithm {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~GJKAlgorithm();
|
~GJKAlgorithm();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
GJKAlgorithm(const GJKAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
GJKAlgorithm& operator=(const GJKAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
/// Initalize the algorithm
|
/// Initalize the algorithm
|
||||||
virtual void init(CollisionDetection* collisionDetection,
|
virtual void init(CollisionDetection* collisionDetection,
|
||||||
MemoryAllocator* memoryAllocator);
|
MemoryAllocator* memoryAllocator);
|
||||||
|
|
|
@ -90,12 +90,6 @@ class Simplex {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
Simplex(const Simplex& simplex);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Simplex& operator=(const Simplex& simplex);
|
|
||||||
|
|
||||||
/// Return true if some bits of "a" overlap with bits of "b"
|
/// Return true if some bits of "a" overlap with bits of "b"
|
||||||
bool overlap(Bits a, Bits b) const;
|
bool overlap(Bits a, Bits b) const;
|
||||||
|
|
||||||
|
@ -127,6 +121,12 @@ class Simplex {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Simplex();
|
~Simplex();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
Simplex(const Simplex& simplex) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Simplex& operator=(const Simplex& simplex) = delete;
|
||||||
|
|
||||||
/// Return true if the simplex contains 4 points
|
/// Return true if the simplex contains 4 points
|
||||||
bool isFull() const;
|
bool isFull() const;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ class NarrowPhaseCallback {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual ~NarrowPhaseCallback() {}
|
||||||
|
|
||||||
/// Called by a narrow-phase collision algorithm when a new contact has been found
|
/// Called by a narrow-phase collision algorithm when a new contact has been found
|
||||||
virtual void notifyContact(OverlappingPair* overlappingPair,
|
virtual void notifyContact(OverlappingPair* overlappingPair,
|
||||||
const ContactPointInfo& contactInfo)=0;
|
const ContactPointInfo& contactInfo)=0;
|
||||||
|
@ -74,14 +76,6 @@ class NarrowPhaseAlgorithm {
|
||||||
/// Overlapping pair of the bodies currently tested for collision
|
/// Overlapping pair of the bodies currently tested for collision
|
||||||
OverlappingPair* mCurrentOverlappingPair;
|
OverlappingPair* mCurrentOverlappingPair;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
NarrowPhaseAlgorithm(const NarrowPhaseAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
NarrowPhaseAlgorithm& operator=(const NarrowPhaseAlgorithm& algorithm);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -92,6 +86,12 @@ class NarrowPhaseAlgorithm {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~NarrowPhaseAlgorithm();
|
virtual ~NarrowPhaseAlgorithm();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
NarrowPhaseAlgorithm(const NarrowPhaseAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
NarrowPhaseAlgorithm& operator=(const NarrowPhaseAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
/// Initalize the algorithm
|
/// Initalize the algorithm
|
||||||
virtual void init(CollisionDetection* collisionDetection, MemoryAllocator* memoryAllocator);
|
virtual void init(CollisionDetection* collisionDetection, MemoryAllocator* memoryAllocator);
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,6 @@ class SphereVsSphereAlgorithm : public NarrowPhaseAlgorithm {
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
SphereVsSphereAlgorithm(const SphereVsSphereAlgorithm& algorithm);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
SphereVsSphereAlgorithm& operator=(const SphereVsSphereAlgorithm& algorithm);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -62,6 +54,12 @@ class SphereVsSphereAlgorithm : public NarrowPhaseAlgorithm {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~SphereVsSphereAlgorithm();
|
virtual ~SphereVsSphereAlgorithm();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
SphereVsSphereAlgorithm(const SphereVsSphereAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
SphereVsSphereAlgorithm& operator=(const SphereVsSphereAlgorithm& algorithm) = delete;
|
||||||
|
|
||||||
/// Compute a contact info if the two bounding volume collide
|
/// Compute a contact info if the two bounding volume collide
|
||||||
virtual void testCollision(const CollisionShapeInfo& shape1Info,
|
virtual void testCollision(const CollisionShapeInfo& shape1Info,
|
||||||
const CollisionShapeInfo& shape2Info,
|
const CollisionShapeInfo& shape2Info,
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace reactphysics3d;
|
||||||
* @param margin The collision margin (in meters) around the collision shape
|
* @param margin The collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
BoxShape::BoxShape(const Vector3& extent, decimal margin)
|
BoxShape::BoxShape(const Vector3& extent, decimal margin)
|
||||||
: ConvexShape(BOX, margin), mExtent(extent - Vector3(margin, margin, margin)) {
|
: ConvexShape(CollisionShapeType::BOX, margin), mExtent(extent - Vector3(margin, margin, margin)) {
|
||||||
assert(extent.x > decimal(0.0) && extent.x > margin);
|
assert(extent.x > decimal(0.0) && extent.x > margin);
|
||||||
assert(extent.y > decimal(0.0) && extent.y > margin);
|
assert(extent.y > decimal(0.0) && extent.y > margin);
|
||||||
assert(extent.z > decimal(0.0) && extent.z > margin);
|
assert(extent.z > decimal(0.0) && extent.z > margin);
|
||||||
|
|
|
@ -61,12 +61,6 @@ class BoxShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
BoxShape(const BoxShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
BoxShape& operator=(const BoxShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -90,6 +84,12 @@ class BoxShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BoxShape();
|
virtual ~BoxShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
BoxShape(const BoxShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
BoxShape& operator=(const BoxShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the extents of the box
|
/// Return the extents of the box
|
||||||
Vector3 getExtent() const;
|
Vector3 getExtent() const;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ using namespace reactphysics3d;
|
||||||
* @param height The height of the capsule (in meters)
|
* @param height The height of the capsule (in meters)
|
||||||
*/
|
*/
|
||||||
CapsuleShape::CapsuleShape(decimal radius, decimal height)
|
CapsuleShape::CapsuleShape(decimal radius, decimal height)
|
||||||
: ConvexShape(CAPSULE, radius), mHalfHeight(height * decimal(0.5)) {
|
: ConvexShape(CollisionShapeType::CAPSULE, radius), mHalfHeight(height * decimal(0.5)) {
|
||||||
assert(radius > decimal(0.0));
|
assert(radius > decimal(0.0));
|
||||||
assert(height > decimal(0.0));
|
assert(height > decimal(0.0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,12 +55,6 @@ class CapsuleShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CapsuleShape(const CapsuleShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CapsuleShape& operator=(const CapsuleShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -89,6 +83,12 @@ class CapsuleShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CapsuleShape();
|
virtual ~CapsuleShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CapsuleShape(const CapsuleShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CapsuleShape& operator=(const CapsuleShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the radius of the capsule
|
/// Return the radius of the capsule
|
||||||
decimal getRadius() const;
|
decimal getRadius() const;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
/// Type of the collision shape
|
/// Type of the collision shape
|
||||||
enum CollisionShapeType {TRIANGLE, BOX, SPHERE, CONE, CYLINDER,
|
enum class CollisionShapeType {TRIANGLE, BOX, SPHERE, CONE, CYLINDER,
|
||||||
CAPSULE, CONVEX_MESH, CONCAVE_MESH, HEIGHTFIELD};
|
CAPSULE, CONVEX_MESH, CONCAVE_MESH, HEIGHTFIELD};
|
||||||
const int NB_COLLISION_SHAPE_TYPES = 9;
|
const int NB_COLLISION_SHAPE_TYPES = 9;
|
||||||
|
|
||||||
|
@ -67,12 +67,6 @@ class CollisionShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CollisionShape(const CollisionShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CollisionShape& operator=(const CollisionShape& shape);
|
|
||||||
|
|
||||||
/// Return true if a point is inside the collision shape
|
/// Return true if a point is inside the collision shape
|
||||||
virtual bool testPointInside(const Vector3& worldPoint, ProxyShape* proxyShape) const=0;
|
virtual bool testPointInside(const Vector3& worldPoint, ProxyShape* proxyShape) const=0;
|
||||||
|
|
||||||
|
@ -92,6 +86,12 @@ class CollisionShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CollisionShape();
|
virtual ~CollisionShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CollisionShape(const CollisionShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CollisionShape& operator=(const CollisionShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the type of the collision shapes
|
/// Return the type of the collision shapes
|
||||||
CollisionShapeType getType() const;
|
CollisionShapeType getType() const;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ inline CollisionShapeType CollisionShape::getType() const {
|
||||||
|
|
||||||
// Return true if the collision shape type is a convex shape
|
// Return true if the collision shape type is a convex shape
|
||||||
inline bool CollisionShape::isConvex(CollisionShapeType shapeType) {
|
inline bool CollisionShape::isConvex(CollisionShapeType shapeType) {
|
||||||
return shapeType != CONCAVE_MESH && shapeType != HEIGHTFIELD;
|
return shapeType != CollisionShapeType::CONCAVE_MESH && shapeType != CollisionShapeType::HEIGHTFIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the scaling vector of the collision shape
|
// Return the scaling vector of the collision shape
|
||||||
|
|
|
@ -30,9 +30,9 @@ using namespace reactphysics3d;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh)
|
ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh)
|
||||||
: ConcaveShape(CONCAVE_MESH) {
|
: ConcaveShape(CollisionShapeType::CONCAVE_MESH) {
|
||||||
mTriangleMesh = triangleMesh;
|
mTriangleMesh = triangleMesh;
|
||||||
mRaycastTestType = FRONT;
|
mRaycastTestType = TriangleRaycastSide::FRONT;
|
||||||
|
|
||||||
// Insert all the triangles into the dynamic AABB tree
|
// Insert all the triangles into the dynamic AABB tree
|
||||||
initBVHTree();
|
initBVHTree();
|
||||||
|
@ -72,10 +72,10 @@ void ConcaveMeshShape::initBVHTree() {
|
||||||
|
|
||||||
// Get the index of the current vertex in the triangle
|
// Get the index of the current vertex in the triangle
|
||||||
int vertexIndex = 0;
|
int vertexIndex = 0;
|
||||||
if (indexType == TriangleVertexArray::INDEX_INTEGER_TYPE) {
|
if (indexType == TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE) {
|
||||||
vertexIndex = ((uint*)vertexIndexPointer)[k];
|
vertexIndex = ((uint*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
|
else if (indexType == TriangleVertexArray::IndexDataType::INDEX_SHORT_TYPE) {
|
||||||
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
|
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -83,13 +83,13 @@ void ConcaveMeshShape::initBVHTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the vertices components of the triangle
|
// Get the vertices components of the triangle
|
||||||
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
|
if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE) {
|
||||||
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
|
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
|
||||||
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
|
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
|
||||||
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
|
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
|
||||||
trianglePoints[k][2] = decimal(vertices[2]) * mScaling.z;
|
trianglePoints[k][2] = decimal(vertices[2]) * mScaling.z;
|
||||||
}
|
}
|
||||||
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
|
else if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE) {
|
||||||
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
|
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
|
||||||
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
|
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
|
||||||
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
|
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
|
||||||
|
@ -132,10 +132,10 @@ void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32 subPart, int32
|
||||||
|
|
||||||
// Get the index of the current vertex in the triangle
|
// Get the index of the current vertex in the triangle
|
||||||
int vertexIndex = 0;
|
int vertexIndex = 0;
|
||||||
if (indexType == TriangleVertexArray::INDEX_INTEGER_TYPE) {
|
if (indexType == TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE) {
|
||||||
vertexIndex = ((uint*)vertexIndexPointer)[k];
|
vertexIndex = ((uint*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
|
else if (indexType == TriangleVertexArray::IndexDataType::INDEX_SHORT_TYPE) {
|
||||||
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
|
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -143,13 +143,13 @@ void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32 subPart, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the vertices components of the triangle
|
// Get the vertices components of the triangle
|
||||||
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
|
if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE) {
|
||||||
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
|
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
|
||||||
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
|
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
|
||||||
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
|
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
|
||||||
outTriangleVertices[k][2] = decimal(vertices[2]) * mScaling.z;
|
outTriangleVertices[k][2] = decimal(vertices[2]) * mScaling.z;
|
||||||
}
|
}
|
||||||
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
|
else if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE) {
|
||||||
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
|
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
|
||||||
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
|
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
|
||||||
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
|
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
|
||||||
|
|
|
@ -120,12 +120,6 @@ class ConcaveMeshShape : public ConcaveShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ConcaveMeshShape(const ConcaveMeshShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ConcaveMeshShape& operator=(const ConcaveMeshShape& shape);
|
|
||||||
|
|
||||||
/// Raycast method with feedback information
|
/// Raycast method with feedback information
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
||||||
|
|
||||||
|
@ -146,7 +140,13 @@ class ConcaveMeshShape : public ConcaveShape {
|
||||||
ConcaveMeshShape(TriangleMesh* triangleMesh);
|
ConcaveMeshShape(TriangleMesh* triangleMesh);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~ConcaveMeshShape();
|
virtual ~ConcaveMeshShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ConcaveMeshShape(const ConcaveMeshShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ConcaveMeshShape& operator=(const ConcaveMeshShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the local bounds of the shape in x, y and z directions.
|
/// Return the local bounds of the shape in x, y and z directions.
|
||||||
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
||||||
|
|
|
@ -33,7 +33,7 @@ using namespace reactphysics3d;
|
||||||
// Constructor
|
// Constructor
|
||||||
ConcaveShape::ConcaveShape(CollisionShapeType type)
|
ConcaveShape::ConcaveShape(CollisionShapeType type)
|
||||||
: CollisionShape(type), mIsSmoothMeshCollisionEnabled(false),
|
: CollisionShape(type), mIsSmoothMeshCollisionEnabled(false),
|
||||||
mTriangleMargin(0), mRaycastTestType(FRONT) {
|
mTriangleMargin(0), mRaycastTestType(TriangleRaycastSide::FRONT) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@ class TriangleCallback {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~TriangleCallback() {}
|
||||||
|
|
||||||
/// Report a triangle
|
/// Report a triangle
|
||||||
virtual void testTriangle(const Vector3* trianglePoints)=0;
|
virtual void testTriangle(const Vector3* trianglePoints)=0;
|
||||||
|
|
||||||
|
@ -70,12 +73,6 @@ class ConcaveShape : public CollisionShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ConcaveShape(const ConcaveShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ConcaveShape& operator=(const ConcaveShape& shape);
|
|
||||||
|
|
||||||
/// Return true if a point is inside the collision shape
|
/// Return true if a point is inside the collision shape
|
||||||
virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const;
|
virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const;
|
||||||
|
|
||||||
|
@ -89,6 +86,12 @@ class ConcaveShape : public CollisionShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~ConcaveShape();
|
virtual ~ConcaveShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ConcaveShape(const ConcaveShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ConcaveShape& operator=(const ConcaveShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the triangle margin
|
/// Return the triangle margin
|
||||||
decimal getTriangleMargin() const;
|
decimal getTriangleMargin() const;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace reactphysics3d;
|
||||||
* @param margin Collision margin (in meters) around the collision shape
|
* @param margin Collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
ConeShape::ConeShape(decimal radius, decimal height, decimal margin)
|
ConeShape::ConeShape(decimal radius, decimal height, decimal margin)
|
||||||
: ConvexShape(CONE, margin), mRadius(radius), mHalfHeight(height * decimal(0.5)) {
|
: ConvexShape(CollisionShapeType::CONE, margin), mRadius(radius), mHalfHeight(height * decimal(0.5)) {
|
||||||
assert(mRadius > decimal(0.0));
|
assert(mRadius > decimal(0.0));
|
||||||
assert(mHalfHeight > decimal(0.0));
|
assert(mHalfHeight > decimal(0.0));
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,6 @@ class ConeShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ConeShape(const ConeShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ConeShape& operator=(const ConeShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -95,6 +89,12 @@ class ConeShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~ConeShape();
|
virtual ~ConeShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ConeShape(const ConeShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ConeShape& operator=(const ConeShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the radius
|
/// Return the radius
|
||||||
decimal getRadius() const;
|
decimal getRadius() const;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ using namespace reactphysics3d;
|
||||||
* @param margin Collision margin (in meters) around the collision shape
|
* @param margin Collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
ConvexMeshShape::ConvexMeshShape(const decimal* arrayVertices, uint nbVertices, int stride, decimal margin)
|
ConvexMeshShape::ConvexMeshShape(const decimal* arrayVertices, uint nbVertices, int stride, decimal margin)
|
||||||
: ConvexShape(CONVEX_MESH, margin), mNbVertices(nbVertices), mMinBounds(0, 0, 0),
|
: ConvexShape(CollisionShapeType::CONVEX_MESH, margin), mNbVertices(nbVertices), mMinBounds(0, 0, 0),
|
||||||
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
|
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
|
||||||
assert(nbVertices > 0);
|
assert(nbVertices > 0);
|
||||||
assert(stride > 0);
|
assert(stride > 0);
|
||||||
|
@ -65,7 +65,7 @@ ConvexMeshShape::ConvexMeshShape(const decimal* arrayVertices, uint nbVertices,
|
||||||
* @param margin Collision margin (in meters) around the collision shape
|
* @param margin Collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool isEdgesInformationUsed, decimal margin)
|
ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool isEdgesInformationUsed, decimal margin)
|
||||||
: ConvexShape(CONVEX_MESH, margin), mMinBounds(0, 0, 0),
|
: ConvexShape(CollisionShapeType::CONVEX_MESH, margin), mMinBounds(0, 0, 0),
|
||||||
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(isEdgesInformationUsed) {
|
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(isEdgesInformationUsed) {
|
||||||
|
|
||||||
TriangleVertexArray::VertexDataType vertexType = triangleVertexArray->getVertexDataType();
|
TriangleVertexArray::VertexDataType vertexType = triangleVertexArray->getVertexDataType();
|
||||||
|
@ -79,14 +79,14 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
|
||||||
for (uint v = 0; v < triangleVertexArray->getNbVertices(); v++) {
|
for (uint v = 0; v < triangleVertexArray->getNbVertices(); v++) {
|
||||||
|
|
||||||
// Get the vertices components of the triangle
|
// Get the vertices components of the triangle
|
||||||
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
|
if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE) {
|
||||||
const float* vertices = (float*)(verticesStart + v * vertexStride);
|
const float* vertices = (float*)(verticesStart + v * vertexStride);
|
||||||
|
|
||||||
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
|
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
|
||||||
vertex = vertex * mScaling;
|
vertex = vertex * mScaling;
|
||||||
mVertices.push_back(vertex);
|
mVertices.push_back(vertex);
|
||||||
}
|
}
|
||||||
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
|
else if (vertexType == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE) {
|
||||||
const double* vertices = (double*)(verticesStart + v * vertexStride);
|
const double* vertices = (double*)(verticesStart + v * vertexStride);
|
||||||
|
|
||||||
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
|
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
|
||||||
|
@ -109,10 +109,10 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
|
||||||
for (int k=0; k < 3; k++) {
|
for (int k=0; k < 3; k++) {
|
||||||
|
|
||||||
// Get the index of the current vertex in the triangle
|
// Get the index of the current vertex in the triangle
|
||||||
if (indexType == TriangleVertexArray::INDEX_INTEGER_TYPE) {
|
if (indexType == TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE) {
|
||||||
vertexIndex[k] = ((uint*)vertexIndexPointer)[k];
|
vertexIndex[k] = ((uint*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
|
else if (indexType == TriangleVertexArray::IndexDataType::INDEX_SHORT_TYPE) {
|
||||||
vertexIndex[k] = ((unsigned short*)vertexIndexPointer)[k];
|
vertexIndex[k] = ((unsigned short*)vertexIndexPointer)[k];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -135,7 +135,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
|
||||||
/// If you use this constructor, you will need to set the vertices manually one by one using
|
/// If you use this constructor, you will need to set the vertices manually one by one using
|
||||||
/// the addVertex() method.
|
/// the addVertex() method.
|
||||||
ConvexMeshShape::ConvexMeshShape(decimal margin)
|
ConvexMeshShape::ConvexMeshShape(decimal margin)
|
||||||
: ConvexShape(CONVEX_MESH, margin), mNbVertices(0), mMinBounds(0, 0, 0),
|
: ConvexShape(CollisionShapeType::CONVEX_MESH, margin), mNbVertices(0), mMinBounds(0, 0, 0),
|
||||||
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
|
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,6 @@ class ConvexMeshShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ConvexMeshShape(const ConvexMeshShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ConvexMeshShape& operator=(const ConvexMeshShape& shape);
|
|
||||||
|
|
||||||
/// Recompute the bounds of the mesh
|
/// Recompute the bounds of the mesh
|
||||||
void recalculateBounds();
|
void recalculateBounds();
|
||||||
|
|
||||||
|
@ -128,6 +122,12 @@ class ConvexMeshShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~ConvexMeshShape();
|
virtual ~ConvexMeshShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ConvexMeshShape(const ConvexMeshShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ConvexMeshShape& operator=(const ConvexMeshShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
/// Return the local bounds of the shape in x, y and z directions
|
||||||
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,6 @@ class ConvexShape : public CollisionShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ConvexShape(const ConvexShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ConvexShape& operator=(const ConvexShape& shape);
|
|
||||||
|
|
||||||
// Return a local support point in a given direction with the object margin
|
// Return a local support point in a given direction with the object margin
|
||||||
Vector3 getLocalSupportPointWithMargin(const Vector3& direction,
|
Vector3 getLocalSupportPointWithMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -75,6 +69,12 @@ class ConvexShape : public CollisionShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~ConvexShape();
|
virtual ~ConvexShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ConvexShape(const ConvexShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ConvexShape& operator=(const ConvexShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the current object margin
|
/// Return the current object margin
|
||||||
decimal getMargin() const;
|
decimal getMargin() const;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ using namespace reactphysics3d;
|
||||||
* @param margin Collision margin (in meters) around the collision shape
|
* @param margin Collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
CylinderShape::CylinderShape(decimal radius, decimal height, decimal margin)
|
CylinderShape::CylinderShape(decimal radius, decimal height, decimal margin)
|
||||||
: ConvexShape(CYLINDER, margin), mRadius(radius),
|
: ConvexShape(CollisionShapeType::CYLINDER, margin), mRadius(radius),
|
||||||
mHalfHeight(height/decimal(2.0)) {
|
mHalfHeight(height/decimal(2.0)) {
|
||||||
assert(radius > decimal(0.0));
|
assert(radius > decimal(0.0));
|
||||||
assert(height > decimal(0.0));
|
assert(height > decimal(0.0));
|
||||||
|
|
|
@ -63,12 +63,6 @@ class CylinderShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CylinderShape(const CylinderShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CylinderShape& operator=(const CylinderShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -92,6 +86,12 @@ class CylinderShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CylinderShape();
|
virtual ~CylinderShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CylinderShape(const CylinderShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CylinderShape& operator=(const CylinderShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the radius
|
/// Return the radius
|
||||||
decimal getRadius() const;
|
decimal getRadius() const;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ using namespace reactphysics3d;
|
||||||
HeightFieldShape::HeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight,
|
HeightFieldShape::HeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight,
|
||||||
const void* heightFieldData, HeightDataType dataType, int upAxis,
|
const void* heightFieldData, HeightDataType dataType, int upAxis,
|
||||||
decimal integerHeightScale)
|
decimal integerHeightScale)
|
||||||
: ConcaveShape(HEIGHTFIELD), mNbColumns(nbGridColumns), mNbRows(nbGridRows),
|
: ConcaveShape(CollisionShapeType::HEIGHTFIELD), mNbColumns(nbGridColumns), mNbRows(nbGridRows),
|
||||||
mWidth(nbGridColumns - 1), mLength(nbGridRows - 1), mMinHeight(minHeight),
|
mWidth(nbGridColumns - 1), mLength(nbGridRows - 1), mMinHeight(minHeight),
|
||||||
mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale),
|
mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale),
|
||||||
mHeightDataType(dataType) {
|
mHeightDataType(dataType) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ class HeightFieldShape : public ConcaveShape {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Data type for the height data of the height field
|
/// Data type for the height data of the height field
|
||||||
enum HeightDataType {HEIGHT_FLOAT_TYPE, HEIGHT_DOUBLE_TYPE, HEIGHT_INT_TYPE};
|
enum class HeightDataType {HEIGHT_FLOAT_TYPE, HEIGHT_DOUBLE_TYPE, HEIGHT_INT_TYPE};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -125,12 +125,6 @@ class HeightFieldShape : public ConcaveShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
HeightFieldShape(const HeightFieldShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
HeightFieldShape& operator=(const HeightFieldShape& shape);
|
|
||||||
|
|
||||||
/// Raycast method with feedback information
|
/// Raycast method with feedback information
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
||||||
|
|
||||||
|
@ -165,7 +159,13 @@ class HeightFieldShape : public ConcaveShape {
|
||||||
int upAxis = 1, decimal integerHeightScale = 1.0f);
|
int upAxis = 1, decimal integerHeightScale = 1.0f);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~HeightFieldShape();
|
virtual ~HeightFieldShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
HeightFieldShape(const HeightFieldShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
HeightFieldShape& operator=(const HeightFieldShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the number of rows in the height field
|
/// Return the number of rows in the height field
|
||||||
int getNbRows() const;
|
int getNbRows() const;
|
||||||
|
@ -223,9 +223,9 @@ inline void HeightFieldShape::setLocalScaling(const Vector3& scaling) {
|
||||||
inline decimal HeightFieldShape::getHeightAt(int x, int y) const {
|
inline decimal HeightFieldShape::getHeightAt(int x, int y) const {
|
||||||
|
|
||||||
switch(mHeightDataType) {
|
switch(mHeightDataType) {
|
||||||
case HEIGHT_FLOAT_TYPE : return ((float*)mHeightFieldData)[y * mNbColumns + x];
|
case HeightDataType::HEIGHT_FLOAT_TYPE : return ((float*)mHeightFieldData)[y * mNbColumns + x];
|
||||||
case HEIGHT_DOUBLE_TYPE : return ((double*)mHeightFieldData)[y * mNbColumns + x];
|
case HeightDataType::HEIGHT_DOUBLE_TYPE : return ((double*)mHeightFieldData)[y * mNbColumns + x];
|
||||||
case HEIGHT_INT_TYPE : return ((int*)mHeightFieldData)[y * mNbColumns + x] * mIntegerHeightScale;
|
case HeightDataType::HEIGHT_INT_TYPE : return ((int*)mHeightFieldData)[y * mNbColumns + x] * mIntegerHeightScale;
|
||||||
default: assert(false); return 0;
|
default: assert(false); return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ using namespace reactphysics3d;
|
||||||
/**
|
/**
|
||||||
* @param radius Radius of the sphere (in meters)
|
* @param radius Radius of the sphere (in meters)
|
||||||
*/
|
*/
|
||||||
SphereShape::SphereShape(decimal radius) : ConvexShape(SPHERE, radius) {
|
SphereShape::SphereShape(decimal radius) : ConvexShape(CollisionShapeType::SPHERE, radius) {
|
||||||
assert(radius > decimal(0.0));
|
assert(radius > decimal(0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,6 @@ class SphereShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
SphereShape(const SphereShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
SphereShape& operator=(const SphereShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -80,6 +74,12 @@ class SphereShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~SphereShape();
|
virtual ~SphereShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
SphereShape(const SphereShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
SphereShape& operator=(const SphereShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the radius of the sphere
|
/// Return the radius of the sphere
|
||||||
decimal getRadius() const;
|
decimal getRadius() const;
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,11 @@ using namespace reactphysics3d;
|
||||||
* @param margin The collision margin (in meters) around the collision shape
|
* @param margin The collision margin (in meters) around the collision shape
|
||||||
*/
|
*/
|
||||||
TriangleShape::TriangleShape(const Vector3& point1, const Vector3& point2, const Vector3& point3, decimal margin)
|
TriangleShape::TriangleShape(const Vector3& point1, const Vector3& point2, const Vector3& point3, decimal margin)
|
||||||
: ConvexShape(TRIANGLE, margin) {
|
: ConvexShape(CollisionShapeType::TRIANGLE, margin) {
|
||||||
mPoints[0] = point1;
|
mPoints[0] = point1;
|
||||||
mPoints[1] = point2;
|
mPoints[1] = point2;
|
||||||
mPoints[2] = point3;
|
mPoints[2] = point3;
|
||||||
mRaycastTestType = FRONT;
|
mRaycastTestType = TriangleRaycastSide::FRONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
@ -68,32 +68,32 @@ bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape
|
||||||
// product for this test.
|
// product for this test.
|
||||||
const Vector3 m = pq.cross(pc);
|
const Vector3 m = pq.cross(pc);
|
||||||
decimal u = pb.dot(m);
|
decimal u = pb.dot(m);
|
||||||
if (mRaycastTestType == FRONT) {
|
if (mRaycastTestType == TriangleRaycastSide::FRONT) {
|
||||||
if (u < decimal(0.0)) return false;
|
if (u < decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
else if (mRaycastTestType == BACK) {
|
else if (mRaycastTestType == TriangleRaycastSide::BACK) {
|
||||||
if (u > decimal(0.0)) return false;
|
if (u > decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
decimal v = -pa.dot(m);
|
decimal v = -pa.dot(m);
|
||||||
if (mRaycastTestType == FRONT) {
|
if (mRaycastTestType == TriangleRaycastSide::FRONT) {
|
||||||
if (v < decimal(0.0)) return false;
|
if (v < decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
else if (mRaycastTestType == BACK) {
|
else if (mRaycastTestType == TriangleRaycastSide::BACK) {
|
||||||
if (v > decimal(0.0)) return false;
|
if (v > decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
else if (mRaycastTestType == FRONT_AND_BACK) {
|
else if (mRaycastTestType == TriangleRaycastSide::FRONT_AND_BACK) {
|
||||||
if (!sameSign(u, v)) return false;
|
if (!sameSign(u, v)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
decimal w = pa.dot(pq.cross(pb));
|
decimal w = pa.dot(pq.cross(pb));
|
||||||
if (mRaycastTestType == FRONT) {
|
if (mRaycastTestType == TriangleRaycastSide::FRONT) {
|
||||||
if (w < decimal(0.0)) return false;
|
if (w < decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
else if (mRaycastTestType == BACK) {
|
else if (mRaycastTestType == TriangleRaycastSide::BACK) {
|
||||||
if (w > decimal(0.0)) return false;
|
if (w > decimal(0.0)) return false;
|
||||||
}
|
}
|
||||||
else if (mRaycastTestType == FRONT_AND_BACK) {
|
else if (mRaycastTestType == TriangleRaycastSide::FRONT_AND_BACK) {
|
||||||
if (!sameSign(u, w)) return false;
|
if (!sameSign(u, w)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
/// Raycast test side for the triangle
|
/// Raycast test side for the triangle
|
||||||
enum TriangleRaycastSide {
|
enum class TriangleRaycastSide {
|
||||||
|
|
||||||
/// Raycast against front triangle
|
/// Raycast against front triangle
|
||||||
FRONT,
|
FRONT,
|
||||||
|
@ -65,12 +65,6 @@ class TriangleShape : public ConvexShape {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
TriangleShape(const TriangleShape& shape);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
TriangleShape& operator=(const TriangleShape& shape);
|
|
||||||
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction,
|
||||||
void** cachedCollisionData) const;
|
void** cachedCollisionData) const;
|
||||||
|
@ -95,6 +89,12 @@ class TriangleShape : public ConvexShape {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~TriangleShape();
|
virtual ~TriangleShape();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
TriangleShape(const TriangleShape& shape) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
TriangleShape& operator=(const TriangleShape& shape) = delete;
|
||||||
|
|
||||||
/// Return the local bounds of the shape in x, y and z directions.
|
/// Return the local bounds of the shape in x, y and z directions.
|
||||||
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
virtual void getLocalBounds(Vector3& min, Vector3& max) const;
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ using uint32 = unsigned int;
|
||||||
/// Position correction technique used in the constraint solver (for joints).
|
/// Position correction technique used in the constraint solver (for joints).
|
||||||
/// BAUMGARTE_JOINTS : Faster but can be innacurate in some situations.
|
/// BAUMGARTE_JOINTS : Faster but can be innacurate in some situations.
|
||||||
/// NON_LINEAR_GAUSS_SEIDEL : Slower but more precise. This is the option used by default.
|
/// NON_LINEAR_GAUSS_SEIDEL : Slower but more precise. This is the option used by default.
|
||||||
enum JointsPositionCorrectionTechnique {BAUMGARTE_JOINTS, NON_LINEAR_GAUSS_SEIDEL};
|
enum class JointsPositionCorrectionTechnique {BAUMGARTE_JOINTS, NON_LINEAR_GAUSS_SEIDEL};
|
||||||
|
|
||||||
/// Position correction technique used in the contact solver (for contacts)
|
/// Position correction technique used in the contact solver (for contacts)
|
||||||
/// BAUMGARTE_CONTACTS : Faster but can be innacurate and can lead to unexpected bounciness
|
/// BAUMGARTE_CONTACTS : Faster but can be innacurate and can lead to unexpected bounciness
|
||||||
|
@ -69,7 +69,7 @@ enum JointsPositionCorrectionTechnique {BAUMGARTE_JOINTS, NON_LINEAR_GAUSS_SEIDE
|
||||||
/// the bodies momentum).
|
/// the bodies momentum).
|
||||||
/// SPLIT_IMPULSES : A bit slower but the error correction factor is not added to the
|
/// SPLIT_IMPULSES : A bit slower but the error correction factor is not added to the
|
||||||
/// bodies momentum. This is the option used by default.
|
/// bodies momentum. This is the option used by default.
|
||||||
enum ContactsPositionCorrectionTechnique {BAUMGARTE_CONTACTS, SPLIT_IMPULSES};
|
enum class ContactsPositionCorrectionTechnique {BAUMGARTE_CONTACTS, SPLIT_IMPULSES};
|
||||||
|
|
||||||
// ------------------- Constants ------------------- //
|
// ------------------- Constants ------------------- //
|
||||||
|
|
||||||
|
|
|
@ -81,13 +81,13 @@ void BallAndSocketJoint::initBeforeSolve(const ConstraintSolverData& constraintS
|
||||||
|
|
||||||
// Compute the inverse mass matrix K^-1
|
// Compute the inverse mass matrix K^-1
|
||||||
mInverseMassMatrix.setToZero();
|
mInverseMassMatrix.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrix = massMatrix.getInverse();
|
mInverseMassMatrix = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the constraint
|
// Compute the bias "b" of the constraint
|
||||||
mBiasVector.setToZero();
|
mBiasVector.setToZero();
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
||||||
mBiasVector = biasFactor * (x2 + mR2World - x1 - mR1World);
|
mBiasVector = biasFactor * (x2 + mR2World - x1 - mR1World);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void BallAndSocketJoint::solvePositionConstraint(const ConstraintSolverData& con
|
||||||
|
|
||||||
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
||||||
// do not execute this method
|
// do not execute this method
|
||||||
if (mPositionCorrectionTechnique != NON_LINEAR_GAUSS_SEIDEL) return;
|
if (mPositionCorrectionTechnique != JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL) return;
|
||||||
|
|
||||||
// Get the bodies center of mass and orientations
|
// Get the bodies center of mass and orientations
|
||||||
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
||||||
|
@ -194,7 +194,7 @@ void BallAndSocketJoint::solvePositionConstraint(const ConstraintSolverData& con
|
||||||
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
||||||
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
||||||
mInverseMassMatrix.setToZero();
|
mInverseMassMatrix.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrix = massMatrix.getInverse();
|
mInverseMassMatrix = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct BallAndSocketJointInfo : public JointInfo {
|
||||||
*/
|
*/
|
||||||
BallAndSocketJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
BallAndSocketJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
||||||
const Vector3& initAnchorPointWorldSpace)
|
const Vector3& initAnchorPointWorldSpace)
|
||||||
: JointInfo(rigidBody1, rigidBody2, BALLSOCKETJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::BALLSOCKETJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace) {}
|
anchorPointWorldSpace(initAnchorPointWorldSpace) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,12 +105,6 @@ class BallAndSocketJoint : public Joint {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
BallAndSocketJoint(const BallAndSocketJoint& constraint);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
BallAndSocketJoint& operator=(const BallAndSocketJoint& constraint);
|
|
||||||
|
|
||||||
/// Return the number of bytes used by the joint
|
/// Return the number of bytes used by the joint
|
||||||
virtual size_t getSizeInBytes() const;
|
virtual size_t getSizeInBytes() const;
|
||||||
|
|
||||||
|
@ -135,6 +129,12 @@ class BallAndSocketJoint : public Joint {
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BallAndSocketJoint();
|
virtual ~BallAndSocketJoint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
BallAndSocketJoint(const BallAndSocketJoint& constraint) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
BallAndSocketJoint& operator=(const BallAndSocketJoint& constraint) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the number of bytes used by the joint
|
// Return the number of bytes used by the joint
|
||||||
|
|
|
@ -143,14 +143,6 @@ class ContactPoint {
|
||||||
/// Cached rolling resistance impulse
|
/// Cached rolling resistance impulse
|
||||||
Vector3 mRollingResistanceImpulse;
|
Vector3 mRollingResistanceImpulse;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
ContactPoint(const ContactPoint& contact);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
ContactPoint& operator=(const ContactPoint& contact);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -161,6 +153,12 @@ class ContactPoint {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~ContactPoint();
|
~ContactPoint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
ContactPoint(const ContactPoint& contact) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
ContactPoint& operator=(const ContactPoint& contact) = delete;
|
||||||
|
|
||||||
/// Return the reference to the body 1
|
/// Return the reference to the body 1
|
||||||
CollisionBody* getBody1() const;
|
CollisionBody* getBody1() const;
|
||||||
|
|
||||||
|
|
|
@ -89,27 +89,27 @@ void FixedJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
||||||
|
|
||||||
// Compute the inverse mass matrix K^-1 for the 3 translation constraints
|
// Compute the inverse mass matrix K^-1 for the 3 translation constraints
|
||||||
mInverseMassMatrixTranslation.setToZero();
|
mInverseMassMatrixTranslation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the constraint for the 3 translation constraints
|
// Compute the bias "b" of the constraint for the 3 translation constraints
|
||||||
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
||||||
mBiasTranslation.setToZero();
|
mBiasTranslation.setToZero();
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBiasTranslation = biasFactor * (x2 + mR2World - x1 - mR1World);
|
mBiasTranslation = biasFactor * (x2 + mR2World - x1 - mR1World);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
||||||
// contraints (3x3 matrix)
|
// contraints (3x3 matrix)
|
||||||
mInverseMassMatrixRotation = mI1 + mI2;
|
mInverseMassMatrixRotation = mI1 + mI2;
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotation = mInverseMassMatrixRotation.getInverse();
|
mInverseMassMatrixRotation = mInverseMassMatrixRotation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" for the 3 rotation constraints
|
// Compute the bias "b" for the 3 rotation constraints
|
||||||
mBiasRotation.setToZero();
|
mBiasRotation.setToZero();
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
Quaternion currentOrientationDifference = orientationBody2 * orientationBody1.getInverse();
|
Quaternion currentOrientationDifference = orientationBody2 * orientationBody1.getInverse();
|
||||||
currentOrientationDifference.normalize();
|
currentOrientationDifference.normalize();
|
||||||
const Quaternion qError = currentOrientationDifference * mInitOrientationDifferenceInv;
|
const Quaternion qError = currentOrientationDifference * mInitOrientationDifferenceInv;
|
||||||
|
@ -222,7 +222,7 @@ void FixedJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
|
|
||||||
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
||||||
// do not execute this method
|
// do not execute this method
|
||||||
if (mPositionCorrectionTechnique != NON_LINEAR_GAUSS_SEIDEL) return;
|
if (mPositionCorrectionTechnique != JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL) return;
|
||||||
|
|
||||||
// Get the bodies positions and orientations
|
// Get the bodies positions and orientations
|
||||||
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
||||||
|
@ -256,7 +256,7 @@ void FixedJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
||||||
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
||||||
mInverseMassMatrixTranslation.setToZero();
|
mInverseMassMatrixTranslation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ void FixedJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
||||||
// contraints (3x3 matrix)
|
// contraints (3x3 matrix)
|
||||||
mInverseMassMatrixRotation = mI1 + mI2;
|
mInverseMassMatrixRotation = mI1 + mI2;
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotation = mInverseMassMatrixRotation.getInverse();
|
mInverseMassMatrixRotation = mInverseMassMatrixRotation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct FixedJointInfo : public JointInfo {
|
||||||
*/
|
*/
|
||||||
FixedJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
FixedJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
||||||
const Vector3& initAnchorPointWorldSpace)
|
const Vector3& initAnchorPointWorldSpace)
|
||||||
: JointInfo(rigidBody1, rigidBody2, FIXEDJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::FIXEDJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace){}
|
anchorPointWorldSpace(initAnchorPointWorldSpace){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,12 +116,6 @@ class FixedJoint : public Joint {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
FixedJoint(const FixedJoint& constraint);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
FixedJoint& operator=(const FixedJoint& constraint);
|
|
||||||
|
|
||||||
/// Return the number of bytes used by the joint
|
/// Return the number of bytes used by the joint
|
||||||
virtual size_t getSizeInBytes() const;
|
virtual size_t getSizeInBytes() const;
|
||||||
|
|
||||||
|
@ -146,6 +140,12 @@ class FixedJoint : public Joint {
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FixedJoint();
|
virtual ~FixedJoint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
FixedJoint(const FixedJoint& constraint) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
FixedJoint& operator=(const FixedJoint& constraint) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the number of bytes used by the joint
|
// Return the number of bytes used by the joint
|
||||||
|
|
|
@ -129,14 +129,14 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
||||||
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
||||||
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
||||||
mInverseMassMatrixTranslation.setToZero();
|
mInverseMassMatrixTranslation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the translation constraints
|
// Compute the bias "b" of the translation constraints
|
||||||
mBTranslation.setToZero();
|
mBTranslation.setToZero();
|
||||||
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBTranslation = biasFactor * (x2 + mR2World - x1 - mR1World);
|
mBTranslation = biasFactor * (x2 + mR2World - x1 - mR1World);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,13 +155,13 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
||||||
mC2CrossA1.dot(I2C2CrossA1);
|
mC2CrossA1.dot(I2C2CrossA1);
|
||||||
const Matrix2x2 matrixKRotation(el11, el12, el21, el22);
|
const Matrix2x2 matrixKRotation(el11, el12, el21, el22);
|
||||||
mInverseMassMatrixRotation.setToZero();
|
mInverseMassMatrixRotation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotation = matrixKRotation.getInverse();
|
mInverseMassMatrixRotation = matrixKRotation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the rotation constraints
|
// Compute the bias "b" of the rotation constraints
|
||||||
mBRotation.setToZero();
|
mBRotation.setToZero();
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBRotation = biasFactor * Vector2(mA1.dot(b2), mA1.dot(c2));
|
mBRotation = biasFactor * Vector2(mA1.dot(b2), mA1.dot(c2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,13 +188,13 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
||||||
|
|
||||||
// Compute the bias "b" of the lower limit constraint
|
// Compute the bias "b" of the lower limit constraint
|
||||||
mBLowerLimit = 0.0;
|
mBLowerLimit = 0.0;
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBLowerLimit = biasFactor * lowerLimitError;
|
mBLowerLimit = biasFactor * lowerLimitError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the upper limit constraint
|
// Compute the bias "b" of the upper limit constraint
|
||||||
mBUpperLimit = 0.0;
|
mBUpperLimit = 0.0;
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBUpperLimit = biasFactor * upperLimitError;
|
mBUpperLimit = biasFactor * upperLimitError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ void HingeJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
|
|
||||||
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
||||||
// do not execute this method
|
// do not execute this method
|
||||||
if (mPositionCorrectionTechnique != NON_LINEAR_GAUSS_SEIDEL) return;
|
if (mPositionCorrectionTechnique != JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL) return;
|
||||||
|
|
||||||
// Get the bodies positions and orientations
|
// Get the bodies positions and orientations
|
||||||
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
||||||
|
@ -461,7 +461,7 @@ void HingeJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
skewSymmetricMatrixU1 * mI1 * skewSymmetricMatrixU1.getTranspose() +
|
||||||
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
skewSymmetricMatrixU2 * mI2 * skewSymmetricMatrixU2.getTranspose();
|
||||||
mInverseMassMatrixTranslation.setToZero();
|
mInverseMassMatrixTranslation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
mInverseMassMatrixTranslation = massMatrix.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ void HingeJoint::solvePositionConstraint(const ConstraintSolverData& constraintS
|
||||||
mC2CrossA1.dot(I2C2CrossA1);
|
mC2CrossA1.dot(I2C2CrossA1);
|
||||||
const Matrix2x2 matrixKRotation(el11, el12, el21, el22);
|
const Matrix2x2 matrixKRotation(el11, el12, el21, el22);
|
||||||
mInverseMassMatrixRotation.setToZero();
|
mInverseMassMatrixRotation.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotation = matrixKRotation.getInverse();
|
mInverseMassMatrixRotation = matrixKRotation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct HingeJointInfo : public JointInfo {
|
||||||
HingeJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
HingeJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
||||||
const Vector3& initAnchorPointWorldSpace,
|
const Vector3& initAnchorPointWorldSpace,
|
||||||
const Vector3& initRotationAxisWorld)
|
const Vector3& initRotationAxisWorld)
|
||||||
: JointInfo(rigidBody1, rigidBody2, HINGEJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::HINGEJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(false),
|
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(false),
|
||||||
isMotorEnabled(false), minAngleLimit(-1), maxAngleLimit(1),
|
isMotorEnabled(false), minAngleLimit(-1), maxAngleLimit(1),
|
||||||
|
@ -101,7 +101,7 @@ struct HingeJointInfo : public JointInfo {
|
||||||
const Vector3& initAnchorPointWorldSpace,
|
const Vector3& initAnchorPointWorldSpace,
|
||||||
const Vector3& initRotationAxisWorld,
|
const Vector3& initRotationAxisWorld,
|
||||||
decimal initMinAngleLimit, decimal initMaxAngleLimit)
|
decimal initMinAngleLimit, decimal initMaxAngleLimit)
|
||||||
: JointInfo(rigidBody1, rigidBody2, HINGEJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::HINGEJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(true),
|
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(true),
|
||||||
isMotorEnabled(false), minAngleLimit(initMinAngleLimit),
|
isMotorEnabled(false), minAngleLimit(initMinAngleLimit),
|
||||||
|
@ -124,7 +124,7 @@ struct HingeJointInfo : public JointInfo {
|
||||||
const Vector3& initRotationAxisWorld,
|
const Vector3& initRotationAxisWorld,
|
||||||
decimal initMinAngleLimit, decimal initMaxAngleLimit,
|
decimal initMinAngleLimit, decimal initMaxAngleLimit,
|
||||||
decimal initMotorSpeed, decimal initMaxMotorTorque)
|
decimal initMotorSpeed, decimal initMaxMotorTorque)
|
||||||
: JointInfo(rigidBody1, rigidBody2, HINGEJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::HINGEJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(true),
|
rotationAxisWorld(initRotationAxisWorld), isLimitEnabled(true),
|
||||||
isMotorEnabled(false), minAngleLimit(initMinAngleLimit),
|
isMotorEnabled(false), minAngleLimit(initMinAngleLimit),
|
||||||
|
@ -250,12 +250,6 @@ class HingeJoint : public Joint {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
HingeJoint(const HingeJoint& constraint);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
HingeJoint& operator=(const HingeJoint& constraint);
|
|
||||||
|
|
||||||
/// Reset the limits
|
/// Reset the limits
|
||||||
void resetLimits();
|
void resetLimits();
|
||||||
|
|
||||||
|
@ -298,6 +292,12 @@ class HingeJoint : public Joint {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~HingeJoint();
|
virtual ~HingeJoint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
HingeJoint(const HingeJoint& constraint) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
HingeJoint& operator=(const HingeJoint& constraint) = delete;
|
||||||
|
|
||||||
/// Return true if the limits or the joint are enabled
|
/// Return true if the limits or the joint are enabled
|
||||||
bool isLimitEnabled() const;
|
bool isLimitEnabled() const;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
/// Enumeration for the type of a constraint
|
/// Enumeration for the type of a constraint
|
||||||
enum JointType {BALLSOCKETJOINT, SLIDERJOINT, HINGEJOINT, FIXEDJOINT};
|
enum class JointType {BALLSOCKETJOINT, SLIDERJOINT, HINGEJOINT, FIXEDJOINT};
|
||||||
|
|
||||||
// Class declarations
|
// Class declarations
|
||||||
struct ConstraintSolverData;
|
struct ConstraintSolverData;
|
||||||
|
@ -95,13 +95,13 @@ struct JointInfo {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
JointInfo(JointType constraintType)
|
JointInfo(JointType constraintType)
|
||||||
: body1(nullptr), body2(nullptr), type(constraintType),
|
: body1(nullptr), body2(nullptr), type(constraintType),
|
||||||
positionCorrectionTechnique(NON_LINEAR_GAUSS_SEIDEL),
|
positionCorrectionTechnique(JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL),
|
||||||
isCollisionEnabled(true) {}
|
isCollisionEnabled(true) {}
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
JointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2, JointType constraintType)
|
JointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2, JointType constraintType)
|
||||||
: body1(rigidBody1), body2(rigidBody2), type(constraintType),
|
: body1(rigidBody1), body2(rigidBody2), type(constraintType),
|
||||||
positionCorrectionTechnique(NON_LINEAR_GAUSS_SEIDEL),
|
positionCorrectionTechnique(JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL),
|
||||||
isCollisionEnabled(true) {
|
isCollisionEnabled(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,12 +146,6 @@ class Joint {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
Joint(const Joint& constraint);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Joint& operator=(const Joint& constraint);
|
|
||||||
|
|
||||||
/// Return true if the joint has already been added into an island
|
/// Return true if the joint has already been added into an island
|
||||||
bool isAlreadyInIsland() const;
|
bool isAlreadyInIsland() const;
|
||||||
|
|
||||||
|
@ -180,6 +174,12 @@ class Joint {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~Joint();
|
virtual ~Joint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
Joint(const Joint& constraint) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Joint& operator=(const Joint& constraint) = delete;
|
||||||
|
|
||||||
/// Return the reference to the body 1
|
/// Return the reference to the body 1
|
||||||
RigidBody* getBody1() const;
|
RigidBody* getBody1() const;
|
||||||
|
|
||||||
|
|
|
@ -139,14 +139,14 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
||||||
mR2CrossN2.dot(I2R2CrossN2);
|
mR2CrossN2.dot(I2R2CrossN2);
|
||||||
Matrix2x2 matrixKTranslation(el11, el12, el21, el22);
|
Matrix2x2 matrixKTranslation(el11, el12, el21, el22);
|
||||||
mInverseMassMatrixTranslationConstraint.setToZero();
|
mInverseMassMatrixTranslationConstraint.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslationConstraint = matrixKTranslation.getInverse();
|
mInverseMassMatrixTranslationConstraint = matrixKTranslation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the translation constraint
|
// Compute the bias "b" of the translation constraint
|
||||||
mBTranslation.setToZero();
|
mBTranslation.setToZero();
|
||||||
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
decimal biasFactor = (BETA / constraintSolverData.timeStep);
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBTranslation.x = u.dot(mN1);
|
mBTranslation.x = u.dot(mN1);
|
||||||
mBTranslation.y = u.dot(mN2);
|
mBTranslation.y = u.dot(mN2);
|
||||||
mBTranslation *= biasFactor;
|
mBTranslation *= biasFactor;
|
||||||
|
@ -155,13 +155,13 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
||||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
||||||
// contraints (3x3 matrix)
|
// contraints (3x3 matrix)
|
||||||
mInverseMassMatrixRotationConstraint = mI1 + mI2;
|
mInverseMassMatrixRotationConstraint = mI1 + mI2;
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotationConstraint = mInverseMassMatrixRotationConstraint.getInverse();
|
mInverseMassMatrixRotationConstraint = mInverseMassMatrixRotationConstraint.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the rotation constraint
|
// Compute the bias "b" of the rotation constraint
|
||||||
mBRotation.setToZero();
|
mBRotation.setToZero();
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
Quaternion currentOrientationDifference = orientationBody2 * orientationBody1.getInverse();
|
Quaternion currentOrientationDifference = orientationBody2 * orientationBody1.getInverse();
|
||||||
currentOrientationDifference.normalize();
|
currentOrientationDifference.normalize();
|
||||||
const Quaternion qError = currentOrientationDifference * mInitOrientationDifferenceInv;
|
const Quaternion qError = currentOrientationDifference * mInitOrientationDifferenceInv;
|
||||||
|
@ -180,13 +180,13 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
||||||
|
|
||||||
// Compute the bias "b" of the lower limit constraint
|
// Compute the bias "b" of the lower limit constraint
|
||||||
mBLowerLimit = 0.0;
|
mBLowerLimit = 0.0;
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBLowerLimit = biasFactor * lowerLimitError;
|
mBLowerLimit = biasFactor * lowerLimitError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bias "b" of the upper limit constraint
|
// Compute the bias "b" of the upper limit constraint
|
||||||
mBUpperLimit = 0.0;
|
mBUpperLimit = 0.0;
|
||||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
if (mPositionCorrectionTechnique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mBUpperLimit = biasFactor * upperLimitError;
|
mBUpperLimit = biasFactor * upperLimitError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ void SliderJoint::solvePositionConstraint(const ConstraintSolverData& constraint
|
||||||
|
|
||||||
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
// If the error position correction technique is not the non-linear-gauss-seidel, we do
|
||||||
// do not execute this method
|
// do not execute this method
|
||||||
if (mPositionCorrectionTechnique != NON_LINEAR_GAUSS_SEIDEL) return;
|
if (mPositionCorrectionTechnique != JointsPositionCorrectionTechnique::NON_LINEAR_GAUSS_SEIDEL) return;
|
||||||
|
|
||||||
// Get the bodies positions and orientations
|
// Get the bodies positions and orientations
|
||||||
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
Vector3& x1 = constraintSolverData.positions[mIndexBody1];
|
||||||
|
@ -497,7 +497,7 @@ void SliderJoint::solvePositionConstraint(const ConstraintSolverData& constraint
|
||||||
mR2CrossN2.dot(I2R2CrossN2);
|
mR2CrossN2.dot(I2R2CrossN2);
|
||||||
Matrix2x2 matrixKTranslation(el11, el12, el21, el22);
|
Matrix2x2 matrixKTranslation(el11, el12, el21, el22);
|
||||||
mInverseMassMatrixTranslationConstraint.setToZero();
|
mInverseMassMatrixTranslationConstraint.setToZero();
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixTranslationConstraint = matrixKTranslation.getInverse();
|
mInverseMassMatrixTranslationConstraint = matrixKTranslation.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ void SliderJoint::solvePositionConstraint(const ConstraintSolverData& constraint
|
||||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
// Compute the inverse of the mass matrix K=JM^-1J^t for the 3 rotation
|
||||||
// contraints (3x3 matrix)
|
// contraints (3x3 matrix)
|
||||||
mInverseMassMatrixRotationConstraint = mI1 + mI2;
|
mInverseMassMatrixRotationConstraint = mI1 + mI2;
|
||||||
if (mBody1->getType() == DYNAMIC || mBody2->getType() == DYNAMIC) {
|
if (mBody1->getType() == BodyType::DYNAMIC || mBody2->getType() == BodyType::DYNAMIC) {
|
||||||
mInverseMassMatrixRotationConstraint = mInverseMassMatrixRotationConstraint.getInverse();
|
mInverseMassMatrixRotationConstraint = mInverseMassMatrixRotationConstraint.getInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ struct SliderJointInfo : public JointInfo {
|
||||||
SliderJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
SliderJointInfo(RigidBody* rigidBody1, RigidBody* rigidBody2,
|
||||||
const Vector3& initAnchorPointWorldSpace,
|
const Vector3& initAnchorPointWorldSpace,
|
||||||
const Vector3& initSliderAxisWorldSpace)
|
const Vector3& initSliderAxisWorldSpace)
|
||||||
: JointInfo(rigidBody1, rigidBody2, SLIDERJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::SLIDERJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
||||||
isLimitEnabled(false), isMotorEnabled(false), minTranslationLimit(-1.0),
|
isLimitEnabled(false), isMotorEnabled(false), minTranslationLimit(-1.0),
|
||||||
|
@ -96,7 +96,7 @@ struct SliderJointInfo : public JointInfo {
|
||||||
const Vector3& initAnchorPointWorldSpace,
|
const Vector3& initAnchorPointWorldSpace,
|
||||||
const Vector3& initSliderAxisWorldSpace,
|
const Vector3& initSliderAxisWorldSpace,
|
||||||
decimal initMinTranslationLimit, decimal initMaxTranslationLimit)
|
decimal initMinTranslationLimit, decimal initMaxTranslationLimit)
|
||||||
: JointInfo(rigidBody1, rigidBody2, SLIDERJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::SLIDERJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
||||||
isLimitEnabled(true), isMotorEnabled(false),
|
isLimitEnabled(true), isMotorEnabled(false),
|
||||||
|
@ -120,7 +120,7 @@ struct SliderJointInfo : public JointInfo {
|
||||||
const Vector3& initSliderAxisWorldSpace,
|
const Vector3& initSliderAxisWorldSpace,
|
||||||
decimal initMinTranslationLimit, decimal initMaxTranslationLimit,
|
decimal initMinTranslationLimit, decimal initMaxTranslationLimit,
|
||||||
decimal initMotorSpeed, decimal initMaxMotorForce)
|
decimal initMotorSpeed, decimal initMaxMotorForce)
|
||||||
: JointInfo(rigidBody1, rigidBody2, SLIDERJOINT),
|
: JointInfo(rigidBody1, rigidBody2, JointType::SLIDERJOINT),
|
||||||
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
anchorPointWorldSpace(initAnchorPointWorldSpace),
|
||||||
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
sliderAxisWorldSpace(initSliderAxisWorldSpace),
|
||||||
isLimitEnabled(true), isMotorEnabled(true),
|
isLimitEnabled(true), isMotorEnabled(true),
|
||||||
|
@ -262,12 +262,6 @@ class SliderJoint : public Joint {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
SliderJoint(const SliderJoint& constraint);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
SliderJoint& operator=(const SliderJoint& constraint);
|
|
||||||
|
|
||||||
/// Reset the limits
|
/// Reset the limits
|
||||||
void resetLimits();
|
void resetLimits();
|
||||||
|
|
||||||
|
@ -296,6 +290,12 @@ class SliderJoint : public Joint {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~SliderJoint();
|
virtual ~SliderJoint();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
SliderJoint(const SliderJoint& constraint) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
SliderJoint& operator=(const SliderJoint& constraint) = delete;
|
||||||
|
|
||||||
/// Return true if the limits or the joint are enabled
|
/// Return true if the limits or the joint are enabled
|
||||||
bool isLimitEnabled() const;
|
bool isLimitEnabled() const;
|
||||||
|
|
||||||
|
|
|
@ -80,12 +80,6 @@ class CollisionWorld {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
CollisionWorld(const CollisionWorld& world);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
CollisionWorld& operator=(const CollisionWorld& world);
|
|
||||||
|
|
||||||
/// Return the next available body ID
|
/// Return the next available body ID
|
||||||
bodyindex computeNextAvailableBodyID();
|
bodyindex computeNextAvailableBodyID();
|
||||||
|
|
||||||
|
@ -102,6 +96,12 @@ class CollisionWorld {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CollisionWorld();
|
virtual ~CollisionWorld();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
CollisionWorld(const CollisionWorld& world) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
CollisionWorld& operator=(const CollisionWorld& world) = delete;
|
||||||
|
|
||||||
/// Return an iterator to the beginning of the bodies of the physics world
|
/// Return an iterator to the beginning of the bodies of the physics world
|
||||||
std::set<CollisionBody*>::iterator getBodiesBeginIterator();
|
std::set<CollisionBody*>::iterator getBodiesBeginIterator();
|
||||||
|
|
||||||
|
|
|
@ -105,8 +105,8 @@ void ContactSolver::initializeForIsland(decimal dt, Island* island) {
|
||||||
internalManifold.frictionCoefficient = computeMixedFrictionCoefficient(body1, body2);
|
internalManifold.frictionCoefficient = computeMixedFrictionCoefficient(body1, body2);
|
||||||
internalManifold.rollingResistanceFactor = computeMixedRollingResistance(body1, body2);
|
internalManifold.rollingResistanceFactor = computeMixedRollingResistance(body1, body2);
|
||||||
internalManifold.externalContactManifold = externalManifold;
|
internalManifold.externalContactManifold = externalManifold;
|
||||||
internalManifold.isBody1DynamicType = body1->getType() == DYNAMIC;
|
internalManifold.isBody1DynamicType = body1->getType() == BodyType::DYNAMIC;
|
||||||
internalManifold.isBody2DynamicType = body2->getType() == DYNAMIC;
|
internalManifold.isBody2DynamicType = body2->getType() == BodyType::DYNAMIC;
|
||||||
|
|
||||||
// If we solve the friction constraints at the center of the contact manifold
|
// If we solve the friction constraints at the center of the contact manifold
|
||||||
if (mIsSolveFrictionAtContactManifoldCenterActive) {
|
if (mIsSolveFrictionAtContactManifoldCenterActive) {
|
||||||
|
|
|
@ -503,7 +503,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
||||||
switch(jointInfo.type) {
|
switch(jointInfo.type) {
|
||||||
|
|
||||||
// Ball-and-Socket joint
|
// Ball-and-Socket joint
|
||||||
case BALLSOCKETJOINT:
|
case JointType::BALLSOCKETJOINT:
|
||||||
{
|
{
|
||||||
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(BallAndSocketJoint));
|
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(BallAndSocketJoint));
|
||||||
const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>(
|
const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>(
|
||||||
|
@ -513,7 +513,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slider joint
|
// Slider joint
|
||||||
case SLIDERJOINT:
|
case JointType::SLIDERJOINT:
|
||||||
{
|
{
|
||||||
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(SliderJoint));
|
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(SliderJoint));
|
||||||
const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo);
|
const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo);
|
||||||
|
@ -522,7 +522,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hinge joint
|
// Hinge joint
|
||||||
case HINGEJOINT:
|
case JointType::HINGEJOINT:
|
||||||
{
|
{
|
||||||
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(HingeJoint));
|
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(HingeJoint));
|
||||||
const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo);
|
const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo);
|
||||||
|
@ -531,7 +531,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fixed joint
|
// Fixed joint
|
||||||
case FIXEDJOINT:
|
case JointType::FIXEDJOINT:
|
||||||
{
|
{
|
||||||
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(FixedJoint));
|
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(FixedJoint));
|
||||||
const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo);
|
const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo);
|
||||||
|
@ -673,7 +673,7 @@ void DynamicsWorld::computeIslands() {
|
||||||
if (body->mIsAlreadyInIsland) continue;
|
if (body->mIsAlreadyInIsland) continue;
|
||||||
|
|
||||||
// If the body is static, we go to the next body
|
// If the body is static, we go to the next body
|
||||||
if (body->getType() == STATIC) continue;
|
if (body->getType() == BodyType::STATIC) continue;
|
||||||
|
|
||||||
// If the body is sleeping or inactive, we go to the next body
|
// If the body is sleeping or inactive, we go to the next body
|
||||||
if (body->isSleeping() || !body->isActive()) continue;
|
if (body->isSleeping() || !body->isActive()) continue;
|
||||||
|
@ -706,7 +706,7 @@ void DynamicsWorld::computeIslands() {
|
||||||
|
|
||||||
// If the current body is static, we do not want to perform the DFS
|
// If the current body is static, we do not want to perform the DFS
|
||||||
// search across that body
|
// search across that body
|
||||||
if (bodyToVisit->getType() == STATIC) continue;
|
if (bodyToVisit->getType() == BodyType::STATIC) continue;
|
||||||
|
|
||||||
// For each contact manifold in which the current body is involded
|
// For each contact manifold in which the current body is involded
|
||||||
ContactManifoldListElement* contactElement;
|
ContactManifoldListElement* contactElement;
|
||||||
|
@ -771,7 +771,7 @@ void DynamicsWorld::computeIslands() {
|
||||||
// can also be included in the other islands
|
// can also be included in the other islands
|
||||||
for (uint i=0; i < mIslands[mNbIslands]->mNbBodies; i++) {
|
for (uint i=0; i < mIslands[mNbIslands]->mNbBodies; i++) {
|
||||||
|
|
||||||
if (mIslands[mNbIslands]->mBodies[i]->getType() == STATIC) {
|
if (mIslands[mNbIslands]->mBodies[i]->getType() == BodyType::STATIC) {
|
||||||
mIslands[mNbIslands]->mBodies[i]->mIsAlreadyInIsland = false;
|
mIslands[mNbIslands]->mBodies[i]->mIsAlreadyInIsland = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ void DynamicsWorld::updateSleepingBodies() {
|
||||||
for (uint b=0; b < mIslands[i]->getNbBodies(); b++) {
|
for (uint b=0; b < mIslands[i]->getNbBodies(); b++) {
|
||||||
|
|
||||||
// Skip static bodies
|
// Skip static bodies
|
||||||
if (bodies[b]->getType() == STATIC) continue;
|
if (bodies[b]->getType() == BodyType::STATIC) continue;
|
||||||
|
|
||||||
// If the body is velocity is large enough to stay awake
|
// If the body is velocity is large enough to stay awake
|
||||||
if (bodies[b]->getLinearVelocity().lengthSquare() > sleepLinearVelocitySquare ||
|
if (bodies[b]->getLinearVelocity().lengthSquare() > sleepLinearVelocitySquare ||
|
||||||
|
|
|
@ -127,12 +127,6 @@ class DynamicsWorld : public CollisionWorld {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
DynamicsWorld(const DynamicsWorld& world);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
DynamicsWorld& operator=(const DynamicsWorld& world);
|
|
||||||
|
|
||||||
/// Integrate the positions and orientations of rigid bodies.
|
/// Integrate the positions and orientations of rigid bodies.
|
||||||
void integrateRigidBodiesPositions();
|
void integrateRigidBodiesPositions();
|
||||||
|
|
||||||
|
@ -186,6 +180,12 @@ class DynamicsWorld : public CollisionWorld {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~DynamicsWorld();
|
virtual ~DynamicsWorld();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
DynamicsWorld(const DynamicsWorld& world) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
DynamicsWorld& operator=(const DynamicsWorld& world) = delete;
|
||||||
|
|
||||||
/// Update the physics simulation
|
/// Update the physics simulation
|
||||||
void update(decimal timeStep);
|
void update(decimal timeStep);
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ inline void DynamicsWorld::setNbIterationsPositionSolver(uint nbIterations) {
|
||||||
*/
|
*/
|
||||||
inline void DynamicsWorld::setContactsPositionCorrectionTechnique(
|
inline void DynamicsWorld::setContactsPositionCorrectionTechnique(
|
||||||
ContactsPositionCorrectionTechnique technique) {
|
ContactsPositionCorrectionTechnique technique) {
|
||||||
if (technique == BAUMGARTE_CONTACTS) {
|
if (technique == ContactsPositionCorrectionTechnique::BAUMGARTE_CONTACTS) {
|
||||||
mContactSolver.setIsSplitImpulseActive(false);
|
mContactSolver.setIsSplitImpulseActive(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -362,7 +362,7 @@ inline void DynamicsWorld::setContactsPositionCorrectionTechnique(
|
||||||
*/
|
*/
|
||||||
inline void DynamicsWorld::setJointsPositionCorrectionTechnique(
|
inline void DynamicsWorld::setJointsPositionCorrectionTechnique(
|
||||||
JointsPositionCorrectionTechnique technique) {
|
JointsPositionCorrectionTechnique technique) {
|
||||||
if (technique == BAUMGARTE_JOINTS) {
|
if (technique == JointsPositionCorrectionTechnique::BAUMGARTE_JOINTS) {
|
||||||
mConstraintSolver.setIsNonLinearGaussSeidelPositionCorrectionActive(false);
|
mConstraintSolver.setIsNonLinearGaussSeidelPositionCorrectionActive(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -53,7 +53,7 @@ class EventListener {
|
||||||
/**
|
/**
|
||||||
* @param contact Information about the contact
|
* @param contact Information about the contact
|
||||||
*/
|
*/
|
||||||
virtual void beginContact(const ContactPointInfo& contact) {};
|
virtual void beginContact(const ContactPointInfo& contact) {}
|
||||||
|
|
||||||
/// Called when a new contact point is found between two bodies
|
/// Called when a new contact point is found between two bodies
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,9 +41,6 @@ struct Impulse {
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Impulse& operator=(const Impulse& impulse);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Attributes -------------------- //
|
// -------------------- Attributes -------------------- //
|
||||||
|
@ -78,8 +75,11 @@ struct Impulse {
|
||||||
angularImpulseBody1(impulse.angularImpulseBody1),
|
angularImpulseBody1(impulse.angularImpulseBody1),
|
||||||
linearImpulseBody2(impulse.linearImpulseBody2),
|
linearImpulseBody2(impulse.linearImpulseBody2),
|
||||||
angularImpulseBody2(impulse.angularImpulseBody2) {
|
angularImpulseBody2(impulse.angularImpulseBody2) {
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Impulse& operator=(const Impulse& impulse) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,14 +75,6 @@ class Island {
|
||||||
/// Number of bytes allocated for the joints array
|
/// Number of bytes allocated for the joints array
|
||||||
size_t mNbAllocatedBytesJoints;
|
size_t mNbAllocatedBytesJoints;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Island& operator=(const Island& island);
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
Island(const Island& island);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -94,6 +86,12 @@ class Island {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Island();
|
~Island();
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Island& operator=(const Island& island) = delete;
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
Island(const Island& island) = delete;
|
||||||
|
|
||||||
/// Add a body into the island
|
/// Add a body into the island
|
||||||
void addBody(RigidBody* body);
|
void addBody(RigidBody* body);
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,6 @@ class OverlappingPair {
|
||||||
/// Cached previous separating axis
|
/// Cached previous separating axis
|
||||||
Vector3 mCachedSeparatingAxis;
|
Vector3 mCachedSeparatingAxis;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
OverlappingPair(const OverlappingPair& pair);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
OverlappingPair& operator=(const OverlappingPair& pair);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -76,6 +68,12 @@ class OverlappingPair {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~OverlappingPair();
|
~OverlappingPair();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
OverlappingPair(const OverlappingPair& pair) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
OverlappingPair& operator=(const OverlappingPair& pair) = delete;
|
||||||
|
|
||||||
/// Return the pointer to first proxy collision shape
|
/// Return the pointer to first proxy collision shape
|
||||||
ProxyShape* getShape1() const;
|
ProxyShape* getShape1() const;
|
||||||
|
|
||||||
|
|
|
@ -71,14 +71,6 @@ class Timer {
|
||||||
/// True if the timer is running
|
/// True if the timer is running
|
||||||
bool mIsRunning;
|
bool mIsRunning;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
|
||||||
|
|
||||||
/// Private copy-constructor
|
|
||||||
Timer(const Timer& timer);
|
|
||||||
|
|
||||||
/// Private assignment operator
|
|
||||||
Timer& operator=(const Timer& timer);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -87,7 +79,13 @@ class Timer {
|
||||||
Timer(double timeStep);
|
Timer(double timeStep);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~Timer();
|
~Timer();
|
||||||
|
|
||||||
|
/// Deleted copy-constructor
|
||||||
|
Timer(const Timer& timer) = delete;
|
||||||
|
|
||||||
|
/// Deleted assignment operator
|
||||||
|
Timer& operator=(const Timer& timer) = delete;
|
||||||
|
|
||||||
/// Return the timestep of the physics engine
|
/// Return the timestep of the physics engine
|
||||||
double getTimeStep() const;
|
double getTimeStep() const;
|
||||||
|
|
|
@ -288,13 +288,13 @@ class TestRaycast : public Test {
|
||||||
mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(5);
|
mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(5);
|
||||||
mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(6);
|
mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(6);
|
||||||
mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(5);
|
mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(5);
|
||||||
TriangleVertexArray::VertexDataType vertexType = sizeof(decimal) == 4 ? TriangleVertexArray::VERTEX_FLOAT_TYPE :
|
TriangleVertexArray::VertexDataType vertexType = sizeof(decimal) == 4 ? TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE :
|
||||||
TriangleVertexArray::VERTEX_DOUBLE_TYPE;
|
TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE;
|
||||||
mConcaveMeshVertexArray =
|
mConcaveMeshVertexArray =
|
||||||
new TriangleVertexArray(8, &(mConcaveMeshVertices[0]), sizeof(Vector3),
|
new TriangleVertexArray(8, &(mConcaveMeshVertices[0]), sizeof(Vector3),
|
||||||
12, &(mConcaveMeshIndices[0]), sizeof(uint),
|
12, &(mConcaveMeshIndices[0]), sizeof(uint),
|
||||||
vertexType,
|
vertexType,
|
||||||
TriangleVertexArray::INDEX_INTEGER_TYPE);
|
TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
|
||||||
|
|
||||||
|
|
||||||
// Add the triangle vertex array of the subpart to the triangle mesh
|
// Add the triangle vertex array of the subpart to the triangle mesh
|
||||||
|
@ -305,7 +305,7 @@ class TestRaycast : public Test {
|
||||||
|
|
||||||
// Heightfield shape (plane height field at height=4)
|
// Heightfield shape (plane height field at height=4)
|
||||||
for (int i=0; i<100; i++) mHeightFieldData[i] = 4;
|
for (int i=0; i<100; i++) mHeightFieldData[i] = 4;
|
||||||
mHeightFieldShape = new HeightFieldShape(10, 10, 0, 4, mHeightFieldData, HeightFieldShape::HEIGHT_FLOAT_TYPE);
|
mHeightFieldShape = new HeightFieldShape(10, 10, 0, 4, mHeightFieldData, HeightFieldShape::HeightDataType::HEIGHT_FLOAT_TYPE);
|
||||||
mHeightFieldProxyShape = mHeightFieldBody->addCollisionShape(mHeightFieldShape, mShapeTransform);
|
mHeightFieldProxyShape = mHeightFieldBody->addCollisionShape(mHeightFieldShape, mShapeTransform);
|
||||||
|
|
||||||
// Assign proxy shapes to the different categories
|
// Assign proxy shapes to the different categories
|
||||||
|
@ -1032,7 +1032,7 @@ class TestRaycast : public Test {
|
||||||
|
|
||||||
// CollisionWorld::raycast()
|
// CollisionWorld::raycast()
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
mTriangleShape->setRaycastTestType(FRONT);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT);
|
||||||
mWorld->raycast(ray, &mCallback);
|
mWorld->raycast(ray, &mCallback);
|
||||||
test(mCallback.isHit);
|
test(mCallback.isHit);
|
||||||
test(mCallback.raycastInfo.body == mTriangleBody);
|
test(mCallback.raycastInfo.body == mTriangleBody);
|
||||||
|
@ -1046,7 +1046,7 @@ class TestRaycast : public Test {
|
||||||
test(approxEqual(mCallback.raycastInfo.worldNormal.z, hitNormal.z, epsilon));
|
test(approxEqual(mCallback.raycastInfo.worldNormal.z, hitNormal.z, epsilon));
|
||||||
|
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
mTriangleShape->setRaycastTestType(BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::BACK);
|
||||||
mWorld->raycast(rayBackward, &mCallback);
|
mWorld->raycast(rayBackward, &mCallback);
|
||||||
test(mCallback.isHit);
|
test(mCallback.isHit);
|
||||||
test(mCallback.raycastInfo.body == mTriangleBody);
|
test(mCallback.raycastInfo.body == mTriangleBody);
|
||||||
|
@ -1060,7 +1060,7 @@ class TestRaycast : public Test {
|
||||||
test(approxEqual(mCallback.raycastInfo.worldNormal.z, -hitNormal.z, epsilon));
|
test(approxEqual(mCallback.raycastInfo.worldNormal.z, -hitNormal.z, epsilon));
|
||||||
|
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
mTriangleShape->setRaycastTestType(FRONT_AND_BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT_AND_BACK);
|
||||||
mWorld->raycast(ray, &mCallback);
|
mWorld->raycast(ray, &mCallback);
|
||||||
test(mCallback.isHit);
|
test(mCallback.isHit);
|
||||||
test(mCallback.raycastInfo.body == mTriangleBody);
|
test(mCallback.raycastInfo.body == mTriangleBody);
|
||||||
|
@ -1074,7 +1074,7 @@ class TestRaycast : public Test {
|
||||||
test(approxEqual(mCallback.raycastInfo.worldNormal.z, hitNormal.z, epsilon));
|
test(approxEqual(mCallback.raycastInfo.worldNormal.z, hitNormal.z, epsilon));
|
||||||
|
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
mTriangleShape->setRaycastTestType(FRONT_AND_BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT_AND_BACK);
|
||||||
mWorld->raycast(rayBackward, &mCallback);
|
mWorld->raycast(rayBackward, &mCallback);
|
||||||
test(mCallback.isHit);
|
test(mCallback.isHit);
|
||||||
test(mCallback.raycastInfo.body == mTriangleBody);
|
test(mCallback.raycastInfo.body == mTriangleBody);
|
||||||
|
@ -1087,7 +1087,7 @@ class TestRaycast : public Test {
|
||||||
test(approxEqual(mCallback.raycastInfo.worldNormal.y, -hitNormal.y, epsilon));
|
test(approxEqual(mCallback.raycastInfo.worldNormal.y, -hitNormal.y, epsilon));
|
||||||
test(approxEqual(mCallback.raycastInfo.worldNormal.z, -hitNormal.z, epsilon));
|
test(approxEqual(mCallback.raycastInfo.worldNormal.z, -hitNormal.z, epsilon));
|
||||||
|
|
||||||
mTriangleShape->setRaycastTestType(FRONT);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT);
|
||||||
|
|
||||||
// Correct category filter mask
|
// Correct category filter mask
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
|
@ -1157,7 +1157,7 @@ class TestRaycast : public Test {
|
||||||
test(!mCallback.isHit);
|
test(!mCallback.isHit);
|
||||||
|
|
||||||
// Test backward ray against front triangles (not hit should occur)
|
// Test backward ray against front triangles (not hit should occur)
|
||||||
mTriangleShape->setRaycastTestType(FRONT);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT);
|
||||||
|
|
||||||
test(!mTriangleBody->raycast(ray4Back, raycastInfo3));
|
test(!mTriangleBody->raycast(ray4Back, raycastInfo3));
|
||||||
test(!mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
test(!mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
||||||
|
@ -1178,7 +1178,7 @@ class TestRaycast : public Test {
|
||||||
test(!mCallback.isHit);
|
test(!mCallback.isHit);
|
||||||
|
|
||||||
// Test front ray against back triangles (not hit should occur)
|
// Test front ray against back triangles (not hit should occur)
|
||||||
mTriangleShape->setRaycastTestType(BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::BACK);
|
||||||
|
|
||||||
test(!mTriangleBody->raycast(ray4, raycastInfo3));
|
test(!mTriangleBody->raycast(ray4, raycastInfo3));
|
||||||
test(!mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
test(!mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
||||||
|
@ -1201,7 +1201,7 @@ class TestRaycast : public Test {
|
||||||
// ----- Test raycast hits ----- //
|
// ----- Test raycast hits ----- //
|
||||||
|
|
||||||
// Test front ray against front triangles
|
// Test front ray against front triangles
|
||||||
mTriangleShape->setRaycastTestType(FRONT);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT);
|
||||||
|
|
||||||
test(mTriangleBody->raycast(ray4, raycastInfo3));
|
test(mTriangleBody->raycast(ray4, raycastInfo3));
|
||||||
test(mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
test(mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
||||||
|
@ -1229,7 +1229,7 @@ class TestRaycast : public Test {
|
||||||
mWorld->raycast(Ray(ray6.point1, ray6.point2, decimal(0.8)), &mCallback);
|
mWorld->raycast(Ray(ray6.point1, ray6.point2, decimal(0.8)), &mCallback);
|
||||||
|
|
||||||
// Test back ray against back triangles
|
// Test back ray against back triangles
|
||||||
mTriangleShape->setRaycastTestType(BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::BACK);
|
||||||
|
|
||||||
test(mTriangleBody->raycast(ray4Back, raycastInfo3));
|
test(mTriangleBody->raycast(ray4Back, raycastInfo3));
|
||||||
test(mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
test(mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
||||||
|
@ -1257,7 +1257,7 @@ class TestRaycast : public Test {
|
||||||
mWorld->raycast(Ray(ray6Back.point1, ray6Back.point2, decimal(0.8)), &mCallback);
|
mWorld->raycast(Ray(ray6Back.point1, ray6Back.point2, decimal(0.8)), &mCallback);
|
||||||
|
|
||||||
// Test front ray against front-back triangles
|
// Test front ray against front-back triangles
|
||||||
mTriangleShape->setRaycastTestType(FRONT_AND_BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT_AND_BACK);
|
||||||
|
|
||||||
test(mTriangleBody->raycast(ray4, raycastInfo3));
|
test(mTriangleBody->raycast(ray4, raycastInfo3));
|
||||||
test(mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
test(mTriangleProxyShape->raycast(ray4, raycastInfo3));
|
||||||
|
@ -1285,7 +1285,7 @@ class TestRaycast : public Test {
|
||||||
mWorld->raycast(Ray(ray6.point1, ray6.point2, decimal(0.8)), &mCallback);
|
mWorld->raycast(Ray(ray6.point1, ray6.point2, decimal(0.8)), &mCallback);
|
||||||
|
|
||||||
// Test back ray against front-back triangles
|
// Test back ray against front-back triangles
|
||||||
mTriangleShape->setRaycastTestType(FRONT_AND_BACK);
|
mTriangleShape->setRaycastTestType(TriangleRaycastSide::FRONT_AND_BACK);
|
||||||
|
|
||||||
test(mTriangleBody->raycast(ray4Back, raycastInfo3));
|
test(mTriangleBody->raycast(ray4Back, raycastInfo3));
|
||||||
test(mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
test(mTriangleProxyShape->raycast(ray4Back, raycastInfo3));
|
||||||
|
|
|
@ -53,8 +53,8 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
|
||||||
rp3d::TriangleVertexArray* vertexArray =
|
rp3d::TriangleVertexArray* vertexArray =
|
||||||
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
||||||
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
|
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
|
||||||
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
rp3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
|
||||||
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
rp3d::TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
|
||||||
|
|
||||||
// Add the triangle vertex array of the subpart to the triangle mesh
|
// Add the triangle vertex array of the subpart to the triangle mesh
|
||||||
mPhysicsTriangleMesh.addSubpart(vertexArray);
|
mPhysicsTriangleMesh.addSubpart(vertexArray);
|
||||||
|
@ -110,8 +110,8 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position, float mass,
|
||||||
rp3d::TriangleVertexArray* vertexArray =
|
rp3d::TriangleVertexArray* vertexArray =
|
||||||
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
||||||
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
|
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
|
||||||
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
rp3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
|
||||||
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
rp3d::TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
|
||||||
|
|
||||||
// Add the triangle vertex array of the subpart to the triangle mesh
|
// Add the triangle vertex array of the subpart to the triangle mesh
|
||||||
mPhysicsTriangleMesh.addSubpart(vertexArray);
|
mPhysicsTriangleMesh.addSubpart(vertexArray);
|
||||||
|
|
|
@ -51,8 +51,8 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
|
||||||
mPhysicsTriangleVertexArray =
|
mPhysicsTriangleVertexArray =
|
||||||
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
||||||
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
|
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
|
||||||
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
rp3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
|
||||||
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
rp3d::TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
|
||||||
|
|
||||||
// Create the collision shape for the rigid body (convex mesh shape) and
|
// Create the collision shape for the rigid body (convex mesh shape) and
|
||||||
// do not forget to delete it at the end
|
// do not forget to delete it at the end
|
||||||
|
@ -101,8 +101,8 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
|
||||||
mPhysicsTriangleVertexArray =
|
mPhysicsTriangleVertexArray =
|
||||||
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
|
||||||
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
|
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
|
||||||
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
rp3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
|
||||||
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
rp3d::TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
|
||||||
|
|
||||||
// Create the collision shape for the rigid body (convex mesh shape) and do
|
// Create the collision shape for the rigid body (convex mesh shape) and do
|
||||||
// not forget to delete it at the end
|
// not forget to delete it at the end
|
||||||
|
|
|
@ -49,7 +49,7 @@ HeightField::HeightField(const openglframework::Vector3 &position,
|
||||||
// Create the collision shape for the rigid body (convex mesh shape) and
|
// Create the collision shape for the rigid body (convex mesh shape) and
|
||||||
// do not forget to delete it at the end
|
// do not forget to delete it at the end
|
||||||
mHeightFieldShape = new rp3d::HeightFieldShape(NB_POINTS_WIDTH, NB_POINTS_LENGTH, mMinHeight, mMaxHeight,
|
mHeightFieldShape = new rp3d::HeightFieldShape(NB_POINTS_WIDTH, NB_POINTS_LENGTH, mMinHeight, mMaxHeight,
|
||||||
mHeightData, rp3d::HeightFieldShape::HEIGHT_FLOAT_TYPE);
|
mHeightData, rp3d::HeightFieldShape::HeightDataType::HEIGHT_FLOAT_TYPE);
|
||||||
|
|
||||||
// Initial position and orientation of the rigid body
|
// Initial position and orientation of the rigid body
|
||||||
rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
||||||
|
@ -92,7 +92,7 @@ HeightField::HeightField(const openglframework::Vector3 &position, float mass,
|
||||||
// Create the collision shape for the rigid body (convex mesh shape) and
|
// Create the collision shape for the rigid body (convex mesh shape) and
|
||||||
// do not forget to delete it at the end
|
// do not forget to delete it at the end
|
||||||
mHeightFieldShape = new rp3d::HeightFieldShape(NB_POINTS_WIDTH, NB_POINTS_LENGTH, mMinHeight, mMaxHeight,
|
mHeightFieldShape = new rp3d::HeightFieldShape(NB_POINTS_WIDTH, NB_POINTS_LENGTH, mMinHeight, mMaxHeight,
|
||||||
mHeightData, rp3d::HeightFieldShape::HEIGHT_FLOAT_TYPE);
|
mHeightData, rp3d::HeightFieldShape::HeightDataType::HEIGHT_FLOAT_TYPE);
|
||||||
|
|
||||||
// Initial position and orientation of the rigid body
|
// Initial position and orientation of the rigid body
|
||||||
rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
||||||
|
|
|
@ -245,7 +245,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||||
mFloor->setSleepingColor(mGreyColorDemo);
|
mFloor->setSleepingColor(mGreyColorDemo);
|
||||||
|
|
||||||
// The floor must be a static rigid body
|
// The floor must be a static rigid body
|
||||||
mFloor->getRigidBody()->setType(rp3d::STATIC);
|
mFloor->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Change the material properties of the rigid body
|
// Change the material properties of the rigid body
|
||||||
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
||||||
|
|
|
@ -83,7 +83,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name)
|
||||||
mConcaveMesh = new ConcaveMesh(position, mass, mDynamicsWorld, meshFolderPath + "city.obj");
|
mConcaveMesh = new ConcaveMesh(position, mass, mDynamicsWorld, meshFolderPath + "city.obj");
|
||||||
|
|
||||||
// Set the mesh as beeing static
|
// Set the mesh as beeing static
|
||||||
mConcaveMesh->getRigidBody()->setType(rp3d::STATIC);
|
mConcaveMesh->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Set the box color
|
// Set the box color
|
||||||
mConcaveMesh->setColor(mGreyColorDemo);
|
mConcaveMesh->setColor(mGreyColorDemo);
|
||||||
|
|
|
@ -82,7 +82,7 @@ CubesScene::CubesScene(const std::string& name)
|
||||||
mFloor->setSleepingColor(mGreyColorDemo);
|
mFloor->setSleepingColor(mGreyColorDemo);
|
||||||
|
|
||||||
// The floor must be a static rigid body
|
// The floor must be a static rigid body
|
||||||
mFloor->getRigidBody()->setType(rp3d::STATIC);
|
mFloor->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Change the material properties of the floor rigid body
|
// Change the material properties of the floor rigid body
|
||||||
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
||||||
|
|
|
@ -78,7 +78,7 @@ HeightFieldScene::HeightFieldScene(const std::string& name) : SceneDemo(name, SC
|
||||||
mHeightField = new HeightField(position, mass, mDynamicsWorld);
|
mHeightField = new HeightField(position, mass, mDynamicsWorld);
|
||||||
|
|
||||||
// Set the mesh as beeing static
|
// Set the mesh as beeing static
|
||||||
mHeightField->getRigidBody()->setType(rp3d::STATIC);
|
mHeightField->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Set the color
|
// Set the color
|
||||||
mHeightField->setColor(mGreyColorDemo);
|
mHeightField->setColor(mGreyColorDemo);
|
||||||
|
|
|
@ -274,7 +274,7 @@ void JointsScene::createBallAndSocketJoints() {
|
||||||
|
|
||||||
// The fist box cannot move (static body)
|
// The fist box cannot move (static body)
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
mBallAndSocketJointChainBoxes[i]->getRigidBody()->setType(rp3d::STATIC);
|
mBallAndSocketJointChainBoxes[i]->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add some angular velocity damping
|
// Add some angular velocity damping
|
||||||
|
@ -322,7 +322,7 @@ void JointsScene::createSliderJoint() {
|
||||||
mSliderJointBottomBox->setSleepingColor(mRedColorDemo);
|
mSliderJointBottomBox->setSleepingColor(mRedColorDemo);
|
||||||
|
|
||||||
// The fist box cannot move
|
// The fist box cannot move
|
||||||
mSliderJointBottomBox->getRigidBody()->setType(rp3d::STATIC);
|
mSliderJointBottomBox->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Change the material properties of the rigid body
|
// Change the material properties of the rigid body
|
||||||
rp3d::Material& material1 = mSliderJointBottomBox->getRigidBody()->getMaterial();
|
rp3d::Material& material1 = mSliderJointBottomBox->getRigidBody()->getMaterial();
|
||||||
|
@ -476,7 +476,7 @@ void JointsScene::createFloor() {
|
||||||
mFloor->setSleepingColor(mGreyColorDemo);
|
mFloor->setSleepingColor(mGreyColorDemo);
|
||||||
|
|
||||||
// The floor must be a static rigid body
|
// The floor must be a static rigid body
|
||||||
mFloor->getRigidBody()->setType(rp3d::STATIC);
|
mFloor->getRigidBody()->setType(rp3d::BodyType::STATIC);
|
||||||
|
|
||||||
// Change the material properties of the rigid body
|
// Change the material properties of the rigid body
|
||||||
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user