From c0114440450a30f75e7f08425af3f33173acce04 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 21 Jan 2016 08:24:58 +0000 Subject: [PATCH] Perform rank test after solving the system. Before this change, it was possible to adjust constraints in a way that removes a degree of freedom and makes the sketch unsolvable, but rank test was performed before solving the system, and an error was not displayed immediately. Instead, a solution would seemingly be found, but it would be very unstable--unrelated changes to the sketch would cause rank test to fail. To reproduce the bug, do this: * Draw a triangle. * Create a length constraint for all sides. * Set side lengths to a, b, and c such that a + b = c. * Add a line segment. --- src/system.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index ae82cf0e..154d269f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -446,6 +446,11 @@ int System::Solve(Group *g, int *dof, List *bad, return System::TOO_MANY_UNKNOWNS; } + // And do the leftovers as one big system + if(!NewtonSolve(0)) { + goto didnt_converge; + } + EvalJacobian(); int rank; rank = CalculateRank(); @@ -460,11 +465,6 @@ int System::Solve(Group *g, int *dof, List *bad, // on the number of DOF. if(dof) *dof = mat.n - mat.m; - // And do the leftovers as one big system - if(!NewtonSolve(0)) { - goto didnt_converge; - } - // If requested, find all the free (unbound) variables. This might be // more than the number of degrees of freedom. Don't always do this, // because the display would get annoying and it's slow.