remove unecessary motor constraint

This commit is contained in:
Irlan 2018-07-25 16:06:35 -03:00
parent e970e09541
commit ba601c2390
4 changed files with 2 additions and 33 deletions

View File

@ -89,9 +89,6 @@ struct b3ClothSolverContactVelocityConstraint
b3Vec3 tangent2;
b3Mat22 tangentMass;
b3Vec2 tangentImpulse;
float32 motorMass;
float32 motorImpulse;
};
struct b3ClothSolverContactPositionConstraint

View File

@ -90,9 +90,6 @@ public:
// Friction constraint
b3Vec3 t1, t2;
b3Vec2 tangentImpulse;
// Motor constraint
float32 motorImpulse;
//
bool active;

View File

@ -574,13 +574,11 @@ void b3Cloth::UpdateContacts()
c->t2 = b3Cross(c->t1, n);
c->normalImpulse = 0.0f;
c->tangentImpulse.SetZero();
c->motorImpulse = 0.0f;
if (c0.active == true)
{
c->normalImpulse = c->normalImpulse;
c->tangentImpulse = c->tangentImpulse;
c->motorImpulse = c->motorImpulse;
}
}
}

View File

@ -498,7 +498,6 @@ void b3ClothSolver::InitializeConstraints()
vc->normalImpulse = c->normalImpulse;
vc->tangentImpulse = c->tangentImpulse;
vc->motorImpulse = c->motorImpulse;
{
b3Vec3 n = vc->normal;
@ -536,11 +535,6 @@ void b3ClothSolver::InitializeConstraints()
vc->tangentMass = b3Inverse(K);
}
{
float32 mass = b3Dot(vc->normal, (iA + iB) * vc->normal);
vc->motorMass = mass > 0.0f ? 1.0f / mass : 0.0f;
}
}
}
@ -577,13 +571,12 @@ void b3ClothSolver::WarmStart()
b3Vec3 P1 = vc->tangentImpulse.x * vc->tangent1;
b3Vec3 P2 = vc->tangentImpulse.y * vc->tangent2;
b3Vec3 P3 = vc->motorImpulse * vc->normal;
vA -= mA * (P1 + P2);
wA -= iA * (b3Cross(vc->rA, P1 + P2) + P3);
wA -= iA * b3Cross(vc->rA, P1 + P2);
vB += mB * (P1 + P2);
wB += iB * (b3Cross(vc->rB, P1 + P2) + P3);
wB += iB * b3Cross(vc->rB, P1 + P2);
v[indexA] = vA;
@ -680,21 +673,6 @@ void b3ClothSolver::SolveVelocityConstraints()
wB += iB * b3Cross(rB, P);
}
// Solve motor constraint.
{
float32 Cdot = b3Dot(vc->normal, wB - wA);
float32 impulse = -vc->motorMass * Cdot;
float32 oldImpulse = vc->motorImpulse;
float32 maxImpulse = vc->friction * vc->normalImpulse;
vc->motorImpulse = b3Clamp(vc->motorImpulse + impulse, -maxImpulse, maxImpulse);
impulse = vc->motorImpulse - oldImpulse;
b3Vec3 P = impulse * vc->normal;
wA -= iA * P;
wB += iB * P;
}
v[indexA] = vA;
bodyB->SetLinearVelocity(vB);
@ -711,7 +689,6 @@ void b3ClothSolver::StoreImpulses()
c->normalImpulse = vc->normalImpulse;
c->tangentImpulse = vc->tangentImpulse;
c->motorImpulse = vc->motorImpulse;
}
}