Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp')
-rw-r--r--extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
index e3603ccec67..a23d5c13f7f 100644
--- a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
+++ b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
@@ -23,16 +23,29 @@ static SimdScalar ContactThreshold = -10.0f;
float useGlobalSettingContacts = false;//true;
SimdScalar contactDamping = 0.9f;
-SimdScalar contactTau = .2f;//0.02f;//*0.02f;
+SimdScalar contactTau = .02f;//0.02f;//*0.02f;
SimdScalar restitutionCurve(SimdScalar rel_vel, SimdScalar restitution)
{
- return restitution;
+ return 0.f;
// return restitution * GEN_min(1.0f, rel_vel / ContactThreshold);
}
+float MAX_FRICTION = 100.f;
+
+SimdScalar calculateCombinedFriction(RigidBody& body0,RigidBody& body1)
+{
+ SimdScalar friction = body0.getFriction() * body1.getFriction();
+ if (friction < 0.f)
+ friction = 0.f;
+ if (friction > MAX_FRICTION)
+ friction = MAX_FRICTION;
+ return friction;
+
+}
+
void applyFrictionInContactPointOld(RigidBody& body1, const SimdVector3& pos1,
RigidBody& body2, const SimdVector3& pos2,
const SimdVector3& normal,float normalImpulse,
@@ -51,6 +64,8 @@ void applyFrictionInContactPointOld(RigidBody& body1, const SimdVector3& pos1,
SimdScalar rel_vel = normal.dot(vel);
+ float combinedFriction = calculateCombinedFriction(body1,body2);
+
#define PER_CONTACT_FRICTION
#ifdef PER_CONTACT_FRICTION
SimdVector3 lat_vel = vel - normal * rel_vel;
@@ -63,7 +78,7 @@ void applyFrictionInContactPointOld(RigidBody& body1, const SimdVector3& pos1,
SimdVector3 temp2 = body2.getInvInertiaTensorWorld() * rel_pos2.cross(lat_vel);
SimdScalar frictionMaxImpulse = lat_rel_vel /
(body1.getInvMass() + body2.getInvMass() + lat_vel.dot(temp1.cross(rel_pos1) + temp2.cross(rel_pos2)));
- SimdScalar frictionImpulse = (normalImpulse) * solverInfo.m_friction;
+ SimdScalar frictionImpulse = (normalImpulse) * combinedFriction;
GEN_set_min(frictionImpulse,frictionMaxImpulse );
body1.applyImpulse(lat_vel * -frictionImpulse, rel_pos1);
@@ -129,7 +144,6 @@ void resolveSingleBilateral(RigidBody& body1, const SimdVector3& pos1,
SimdScalar massTerm = 1.f / (body1.getInvMass() + body2.getInvMass());
- float contactDamping = 0.9f;
impulse = - contactDamping * rel_vel * massTerm;//jacDiagABInv;
//SimdScalar velocityImpulse = -contactDamping * rel_vel * jacDiagABInv;
@@ -167,9 +181,11 @@ float resolveSingleCollision(RigidBody& body1, const SimdVector3& pos1,
// if (rel_vel< 0.f)//-SIMD_EPSILON)
// {
- SimdScalar rest = restitutionCurve(rel_vel, solverInfo.m_restitution);
+ float combinedRestitution = body1.getRestitution() * body2.getRestitution();
+
+ SimdScalar rest = restitutionCurve(rel_vel, combinedRestitution);
- SimdScalar timeCorrection = 1.f;///timeStep;
+ SimdScalar timeCorrection = 360.f*solverInfo.m_timeStep;
float damping = solverInfo.m_damping ;
float tau = solverInfo.m_tau;
@@ -252,7 +268,9 @@ SimdScalar rel_vel;
// if (rel_vel< 0.f)//-SIMD_EPSILON)
// {
- SimdScalar rest = restitutionCurve(rel_vel, solverInfo.m_restitution);
+ float combinedRestitution = body1.getRestitution() * body2.getRestitution();
+
+ SimdScalar rest = restitutionCurve(rel_vel, combinedRestitution);
// SimdScalar massTerm = 1.f / (body1.getInvMass() + body2.getInvMass());
SimdScalar timeCorrection = 0.5f / solverInfo.m_timeStep ;
@@ -302,6 +320,8 @@ SimdScalar rel_vel;
SimdVector3 lat_vel = vel - normal * rel_vel;
SimdScalar lat_rel_vel = lat_vel.length();
+ float combinedFriction = calculateCombinedFriction(body1,body2);
+
if (lat_rel_vel > SIMD_EPSILON)
{
lat_vel /= lat_rel_vel;
@@ -310,7 +330,7 @@ SimdScalar rel_vel;
friction_impulse = lat_rel_vel /
(body1.getInvMass() + body2.getInvMass() + lat_vel.dot(temp1.cross(rel_pos1) + temp2.cross(rel_pos2)));
SimdScalar normal_impulse = (penetrationImpulse+
- velocityImpulse) * solverInfo.m_friction;
+ velocityImpulse) * combinedFriction;
GEN_set_min(friction_impulse, normal_impulse);
body1.applyImpulse(lat_vel * -friction_impulse, rel_pos1);