Update strech_force.cpp

This commit is contained in:
Irlan 2019-06-27 04:19:56 -03:00
parent a47c8e3e75
commit 774c0741bd
2 changed files with 77 additions and 70 deletions

View File

@ -35,6 +35,7 @@ public:
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.streching = 10000.0f;
def.damping = 100.0f;
def.thickness = 0.2f;
def.friction = 0.1f;

View File

@ -116,7 +116,7 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
m_f2.SetZero();
m_f3.SetZero();
if (len_wu > m_bu)
if (len_wu > 0.0f)
{
float32 inv_len_wu = 1.0f / len_wu;
b3Vec3 n_wu = inv_len_wu * wu;
@ -129,6 +129,8 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
}
if (m_ks > 0.0f)
{
if (len_wu > m_bu)
{
float32 Cu = alpha * (len_wu - m_bu);
@ -169,6 +171,7 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
//dfdx(i3, i2) += J[2][1];
dfdx(i3, i3) += J[2][2];
}
}
if (m_kd > 0.0f)
{
@ -216,7 +219,7 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
}
}
if (len_wv > m_bv)
if (len_wv > 0.0f)
{
float32 inv_len_wv = 1.0f / len_wv;
b3Vec3 n_wv = inv_len_wv * wv;
@ -229,6 +232,8 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
}
if (m_ks > 0.0f)
{
if (len_wv > m_bv)
{
float32 Cv = alpha * (len_wv - m_bv);
@ -269,6 +274,7 @@ void b3StrechForce::Apply(const b3ClothForceSolverData* data)
//dfdx(i3, i2) += J[2][1];
dfdx(i3, i3) += J[2][2];
}
}
if (m_kd > 0.0f)
{