Skip to content

Commit

Permalink
- bugix in XPBD FEM code
Browse files Browse the repository at this point in the history
  • Loading branch information
janbender committed Feb 21, 2024
1 parent 00db2e0 commit 1b06319
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.2.1
- bugfix in XPBD FEM code
- updated GenericParameters
- fixed meshes

Expand Down
13 changes: 7 additions & 6 deletions PositionBasedDynamics/XPBD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,20 @@ bool XPBD::solve_FEMTetraConstraint(
invMass3 * gradU_[3].squaredNorm();

Real alpha = static_cast<Real>(1.0) / (youngsModulus * dt * dt);
// Note that grad C = 1/C grad U'
// Note that grad C = 1/C grad U', by multiplying C^2 to alpha, we now can add the factor C^2 to the nominator
sum_normGradU_ += C * C * alpha;

if (sum_normGradU_ < eps)
return false;

// compute scaling factor
const Real s = (C * C + C * alpha * multiplier) / sum_normGradU_;
const Real lambda = -C * (C + alpha * multiplier) / sum_normGradU_; // since in the next step we use gradU instead of gradC, we only add the factor C instead of C^2
multiplier += lambda;

corr0 = -s * invMass0 * gradU_[0];
corr1 = -s * invMass1 * gradU_[1];
corr2 = -s * invMass2 * gradU_[2];
corr3 = -s * invMass3 * gradU_[3];
corr0 = lambda * invMass0 * gradU_[0];
corr1 = lambda * invMass1 * gradU_[1];
corr2 = lambda * invMass2 * gradU_[2];
corr3 = lambda * invMass3 * gradU_[3];

return true;
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.1

0 comments on commit 1b06319

Please sign in to comment.