fix problems with ctrl/shift key drag modifiers

When dragging points we must always update position and mark them dirty
through all code paths.
Ensure the ctrl and shift modifier rotation quarternion is always set to
something reasonable.
separate extraLine tracking code from drag tracking code
This commit is contained in:
robnee 2021-02-27 12:52:50 -05:00 committed by phkahler
parent 60dca4cb79
commit 3309181773

View File

@ -270,15 +270,16 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
return; return;
} }
if(pending.operation == Pending::DRAGGING_POINTS && ctrlDown) {
SS.extraLine.ptA = UnProjectPoint(orig.mouseOnButtonDown);
SS.extraLine.ptB = UnProjectPoint(mp);
SS.extraLine.draw = true;
}
// We're currently dragging something; so do that. But if we haven't // We're currently dragging something; so do that. But if we haven't
// painted since the last time we solved, do nothing, because there's // painted since the last time we solved, do nothing, because there's
// no sense solving a frame and not displaying it. // no sense solving a frame and not displaying it.
if(!havePainted) { if(!havePainted) {
if(pending.operation == Pending::DRAGGING_POINTS && ctrlDown) {
SS.extraLine.ptA = UnProjectPoint(orig.mouseOnButtonDown);
SS.extraLine.ptB = UnProjectPoint(mp);
SS.extraLine.draw = true;
}
return; return;
} }
@ -319,20 +320,16 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
// Don't start dragging the position about the normal // Don't start dragging the position about the normal
// until we're a little ways out, to get a reasonable // until we're a little ways out, to get a reasonable
// reference pos // reference pos
orig.mouse = mp; qt = Quaternion::IDENTITY;
break; } else {
double theta = atan2(orig.mouse.y-orig.mouseOnButtonDown.y,
orig.mouse.x-orig.mouseOnButtonDown.x);
theta -= atan2(y-orig.mouseOnButtonDown.y,
x-orig.mouseOnButtonDown.x);
Vector gn = projRight.Cross(projUp);
qt = Quaternion::From(gn, -theta);
} }
double theta = atan2(orig.mouse.y-orig.mouseOnButtonDown.y,
orig.mouse.x-orig.mouseOnButtonDown.x);
theta -= atan2(y-orig.mouseOnButtonDown.y,
x-orig.mouseOnButtonDown.x);
Vector gn = projRight.Cross(projUp);
qt = Quaternion::From(gn, -theta);
SS.extraLine.draw = true;
SS.extraLine.ptA = UnProjectPoint(orig.mouseOnButtonDown);
SS.extraLine.ptB = UnProjectPoint(mp);
} else { } else {
double dx = -(x - orig.mouse.x); double dx = -(x - orig.mouse.x);
double dy = -(y - orig.mouse.y); double dy = -(y - orig.mouse.y);
@ -340,7 +337,6 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
qt = Quaternion::From(projUp, -s*dx).Times( qt = Quaternion::From(projUp, -s*dx).Times(
Quaternion::From(projRight, s*dy)); Quaternion::From(projRight, s*dy));
} }
orig.mouse = mp;
// Now apply this rotation to the points being dragged. // Now apply this rotation to the points being dragged.
List<hEntity> *lhe = &(pending.points); List<hEntity> *lhe = &(pending.points);
@ -353,18 +349,18 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
p = qt.Rotate(p); p = qt.Rotate(p);
p = p.Plus(SS.extraLine.ptA); p = p.Plus(SS.extraLine.ptA);
e->PointForceTo(p); e->PointForceTo(p);
SS.MarkGroupDirtyByEntity(e->h); } else {
UpdateDraggedPoint(*he, x, y);
} }
continue; } else {
Quaternion q = e->PointGetQuaternion();
Vector p = e->PointGetNum();
q = qt.Times(q);
e->PointForceQuaternionTo(q);
// Let's rotate about the selected point; so fix up the
// translation so that that point didn't move.
e->PointForceTo(p);
} }
Quaternion q = e->PointGetQuaternion();
Vector p = e->PointGetNum();
q = qt.Times(q);
e->PointForceQuaternionTo(q);
// Let's rotate about the selected point; so fix up the
// translation so that that point didn't move.
e->PointForceTo(p);
SS.MarkGroupDirtyByEntity(e->h); SS.MarkGroupDirtyByEntity(e->h);
} }
} else { } else {
@ -373,8 +369,8 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
UpdateDraggedPoint(*he, x, y); UpdateDraggedPoint(*he, x, y);
SS.MarkGroupDirtyByEntity(*he); SS.MarkGroupDirtyByEntity(*he);
} }
orig.mouse = mp;
} }
orig.mouse = mp;
break; break;
case Pending::DRAGGING_NEW_CUBIC_POINT: { case Pending::DRAGGING_NEW_CUBIC_POINT: {