Skip to content

Commit e02aa0b

Browse files
committed
Guarding cotton weights.
In some instances weights dropped below zero.
1 parent 4c10edc commit e02aa0b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

inc/deform/arap.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ namespace deform {
119119
_dirty = false;
120120
}
121121

122+
// Estimate positions
123+
estimatePositions();
124+
122125
for (Index i = 0; i < numberOfIterations; ++i) {
123126

124127
// Estimate rotations
@@ -209,9 +212,13 @@ namespace deform {
209212

210213
const Scalar denom = Scalar(1.0) / (Scalar(4.0) * area);
211214

212-
const Scalar cot0 = (-l0 * l0 + l1 * l1 + l2 * l2) * denom;
213-
const Scalar cot1 = (l0 * l0 - l1 * l1 + l2 * l2) * denom;
214-
const Scalar cot2 = (l0 * l0 + l1 * l1 - l2 * l2) * denom;
215+
Scalar cot0 = (-l0 * l0 + l1 * l1 + l2 * l2) * denom;
216+
Scalar cot1 = (l0 * l0 - l1 * l1 + l2 * l2) * denom;
217+
Scalar cot2 = (l0 * l0 + l1 * l1 - l2 * l2) * denom;
218+
219+
cot0 = std::max<Scalar>(Scalar(1e-8), cot0);
220+
cot1 = std::max<Scalar>(Scalar(1e-8), cot1);
221+
cot2 = std::max<Scalar>(Scalar(1e-8), cot2);
215222

216223
std::pair<Index, Index> e0 = undirectedEdge(vids(0), vids(1));
217224
std::pair<Index, Index> e1 = undirectedEdge(vids(1), vids(2));

0 commit comments

Comments
 (0)