Sketcher: jumping while dragging - force recalculate initial solution
===================================================================== fixes #1734 Upon dragging, the initial solution is first calculated and them DogLeg is left with the work of solving for a solution next to the initial solution. When the change is too big and the gradients are no longer accurate to continue dragging, the dragging flips and jumps. The solution offered here is, not to update always the solution, as this also creates artifacts, but update it if the dragging goes beyond 20 times the initial dragging distance. https://forum.freecadweb.org/viewtopic.php?f=3&t=7589#p203580 https://forum.freecadweb.org/viewtopic.php?f=3&t=7589#p203712
This commit is contained in:
@@ -68,7 +68,7 @@ TYPESYSTEM_SOURCE(Sketcher::Sketch, Base::Persistence)
|
||||
|
||||
Sketch::Sketch()
|
||||
: SolveTime(0), GCSsys(), ConstraintsCounter(0), isInitMove(false), isFine(true),
|
||||
defaultSolver(GCS::DogLeg),defaultSolverRedundant(GCS::DogLeg),debugMode(GCS::Minimal)
|
||||
defaultSolver(GCS::DogLeg),defaultSolverRedundant(GCS::DogLeg),debugMode(GCS::Minimal)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3193,8 +3193,22 @@ int Sketch::movePoint(int geoId, PointPos pos, Base::Vector3d toPoint, bool rela
|
||||
if (hasConflicts())
|
||||
return -1;
|
||||
|
||||
if (!isInitMove)
|
||||
if (!isInitMove) {
|
||||
initMove(geoId, pos);
|
||||
initToPoint = toPoint;
|
||||
moveStep = 0;
|
||||
}
|
||||
else {
|
||||
if (moveStep == 0) {
|
||||
moveStep = (toPoint-initToPoint).Length();
|
||||
}
|
||||
else {
|
||||
if( (toPoint-initToPoint).Length() > 20*moveStep) { // I am getting too far away from the original solution so reinit the solution
|
||||
initMove(geoId, pos);
|
||||
initToPoint = toPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (relative) {
|
||||
for (int i=0; i < int(MoveParameters.size()-1); i+=2) {
|
||||
|
||||
@@ -397,6 +397,8 @@ protected:
|
||||
|
||||
bool isInitMove;
|
||||
bool isFine;
|
||||
Base::Vector3d initToPoint;
|
||||
double moveStep;
|
||||
|
||||
public:
|
||||
GCS::Algorithm defaultSolver;
|
||||
|
||||
Reference in New Issue
Block a user