Some optimizations in contact solver
This commit is contained in:
parent
81426293e0
commit
14bfb0aca4
|
@ -102,7 +102,7 @@ class ContactManifold {
|
||||||
short int mNormalDirectionId;
|
short int mNormalDirectionId;
|
||||||
|
|
||||||
/// Number of contacts in the cache
|
/// Number of contacts in the cache
|
||||||
uint mNbContactPoints;
|
int8 mNbContactPoints;
|
||||||
|
|
||||||
/// First friction vector of the contact manifold
|
/// First friction vector of the contact manifold
|
||||||
Vector3 mFrictionVector1;
|
Vector3 mFrictionVector1;
|
||||||
|
@ -187,7 +187,7 @@ class ContactManifold {
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/// Return the number of contact points in the manifold
|
/// Return the number of contact points in the manifold
|
||||||
uint getNbContactPoints() const;
|
int8 getNbContactPoints() const;
|
||||||
|
|
||||||
/// Return the first friction vector at the center of the contact manifold
|
/// Return the first friction vector at the center of the contact manifold
|
||||||
const Vector3& getFrictionVector1() const;
|
const Vector3& getFrictionVector1() const;
|
||||||
|
@ -264,7 +264,7 @@ inline short int ContactManifold::getNormalDirectionId() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number of contact points in the manifold
|
// Return the number of contact points in the manifold
|
||||||
inline uint ContactManifold::getNbContactPoints() const {
|
inline int8 ContactManifold::getNbContactPoints() const {
|
||||||
return mNbContactPoints;
|
return mNbContactPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,11 +119,8 @@ class ContactSolver {
|
||||||
*/
|
*/
|
||||||
struct ContactPointSolver {
|
struct ContactPointSolver {
|
||||||
|
|
||||||
/// Accumulated normal impulse
|
/// Pointer to the external contact
|
||||||
decimal penetrationImpulse;
|
ContactPoint* externalContact;
|
||||||
|
|
||||||
/// Accumulated split impulse for penetration correction
|
|
||||||
decimal penetrationSplitImpulse;
|
|
||||||
|
|
||||||
/// Normal vector of the contact
|
/// Normal vector of the contact
|
||||||
Vector3 normal;
|
Vector3 normal;
|
||||||
|
@ -134,41 +131,26 @@ class ContactSolver {
|
||||||
/// Vector from the body 2 center to the contact point
|
/// Vector from the body 2 center to the contact point
|
||||||
Vector3 r2;
|
Vector3 r2;
|
||||||
|
|
||||||
/// Cross product of r1 with 1st friction vector
|
|
||||||
Vector3 r1CrossT1;
|
|
||||||
|
|
||||||
/// Cross product of r1 with 2nd friction vector
|
|
||||||
Vector3 r1CrossT2;
|
|
||||||
|
|
||||||
/// Cross product of r2 with 1st friction vector
|
|
||||||
Vector3 r2CrossT1;
|
|
||||||
|
|
||||||
/// Cross product of r2 with 2nd friction vector
|
|
||||||
Vector3 r2CrossT2;
|
|
||||||
|
|
||||||
/// Cross product of r1 with the contact normal
|
|
||||||
Vector3 r1CrossN;
|
|
||||||
|
|
||||||
/// Cross product of r2 with the contact normal
|
|
||||||
Vector3 r2CrossN;
|
|
||||||
|
|
||||||
/// Penetration depth
|
/// Penetration depth
|
||||||
decimal penetrationDepth;
|
decimal penetrationDepth;
|
||||||
|
|
||||||
/// Velocity restitution bias
|
/// Velocity restitution bias
|
||||||
decimal restitutionBias;
|
decimal restitutionBias;
|
||||||
|
|
||||||
|
/// Accumulated normal impulse
|
||||||
|
decimal penetrationImpulse;
|
||||||
|
|
||||||
|
/// Accumulated split impulse for penetration correction
|
||||||
|
decimal penetrationSplitImpulse;
|
||||||
|
|
||||||
/// Inverse of the matrix K for the penenetration
|
/// Inverse of the matrix K for the penenetration
|
||||||
decimal inversePenetrationMass;
|
decimal inversePenetrationMass;
|
||||||
|
|
||||||
/// Inverse of the matrix K for the 1st friction
|
/// Cross product of r1 with the contact normal
|
||||||
decimal inverseFriction1Mass;
|
Vector3 r1CrossN;
|
||||||
|
|
||||||
/// Inverse of the matrix K for the 2nd friction
|
/// Cross product of r2 with the contact normal
|
||||||
decimal inverseFriction2Mass;
|
Vector3 r2CrossN;
|
||||||
|
|
||||||
/// Pointer to the external contact
|
|
||||||
ContactPoint* externalContact;
|
|
||||||
|
|
||||||
/// True if the contact was existing last time step
|
/// True if the contact was existing last time step
|
||||||
bool isRestingContact;
|
bool isRestingContact;
|
||||||
|
@ -181,11 +163,14 @@ class ContactSolver {
|
||||||
*/
|
*/
|
||||||
struct ContactManifoldSolver {
|
struct ContactManifoldSolver {
|
||||||
|
|
||||||
|
/// Pointer to the external contact manifold
|
||||||
|
ContactManifold* externalContactManifold;
|
||||||
|
|
||||||
/// Index of body 1 in the constraint solver
|
/// Index of body 1 in the constraint solver
|
||||||
uint indexBody1;
|
int32 indexBody1;
|
||||||
|
|
||||||
/// Index of body 2 in the constraint solver
|
/// Index of body 2 in the constraint solver
|
||||||
uint indexBody2;
|
int32 indexBody2;
|
||||||
|
|
||||||
/// Inverse of the mass of body 1
|
/// Inverse of the mass of body 1
|
||||||
decimal massInverseBody1;
|
decimal massInverseBody1;
|
||||||
|
@ -199,18 +184,12 @@ class ContactSolver {
|
||||||
/// Inverse inertia tensor of body 2
|
/// Inverse inertia tensor of body 2
|
||||||
Matrix3x3 inverseInertiaTensorBody2;
|
Matrix3x3 inverseInertiaTensorBody2;
|
||||||
|
|
||||||
/// Number of contact points
|
|
||||||
short int nbContacts;
|
|
||||||
|
|
||||||
/// Mix friction coefficient for the two bodies
|
/// Mix friction coefficient for the two bodies
|
||||||
decimal frictionCoefficient;
|
decimal frictionCoefficient;
|
||||||
|
|
||||||
/// Rolling resistance factor between the two bodies
|
/// Rolling resistance factor between the two bodies
|
||||||
decimal rollingResistanceFactor;
|
decimal rollingResistanceFactor;
|
||||||
|
|
||||||
/// Pointer to the external contact manifold
|
|
||||||
ContactManifold* externalContactManifold;
|
|
||||||
|
|
||||||
// - Variables used when friction constraints are apply at the center of the manifold-//
|
// - Variables used when friction constraints are apply at the center of the manifold-//
|
||||||
|
|
||||||
/// Average normal vector of the contact manifold
|
/// Average normal vector of the contact manifold
|
||||||
|
@ -275,6 +254,9 @@ class ContactSolver {
|
||||||
|
|
||||||
/// Rolling resistance impulse
|
/// Rolling resistance impulse
|
||||||
Vector3 rollingResistanceImpulse;
|
Vector3 rollingResistanceImpulse;
|
||||||
|
|
||||||
|
/// Number of contact points
|
||||||
|
int8 nbContacts;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------- Constants --------------------- //
|
// -------------------- Constants --------------------- //
|
||||||
|
|
Loading…
Reference in New Issue
Block a user