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:
parent
60dca4cb79
commit
3309181773
@ -270,15 +270,16 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
// no sense solving a frame and not displaying it.
|
|
||||||
if(!havePainted) {
|
|
||||||
if(pending.operation == Pending::DRAGGING_POINTS && ctrlDown) {
|
if(pending.operation == Pending::DRAGGING_POINTS && ctrlDown) {
|
||||||
SS.extraLine.ptA = UnProjectPoint(orig.mouseOnButtonDown);
|
SS.extraLine.ptA = UnProjectPoint(orig.mouseOnButtonDown);
|
||||||
SS.extraLine.ptB = UnProjectPoint(mp);
|
SS.extraLine.ptB = UnProjectPoint(mp);
|
||||||
SS.extraLine.draw = true;
|
SS.extraLine.draw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// no sense solving a frame and not displaying it.
|
||||||
|
if(!havePainted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,9 +320,8 @@ 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,
|
double theta = atan2(orig.mouse.y-orig.mouseOnButtonDown.y,
|
||||||
orig.mouse.x-orig.mouseOnButtonDown.x);
|
orig.mouse.x-orig.mouseOnButtonDown.x);
|
||||||
theta -= atan2(y-orig.mouseOnButtonDown.y,
|
theta -= atan2(y-orig.mouseOnButtonDown.y,
|
||||||
@ -329,10 +329,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||||||
|
|
||||||
Vector gn = projRight.Cross(projUp);
|
Vector gn = projRight.Cross(projUp);
|
||||||
qt = Quaternion::From(gn, -theta);
|
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,11 +349,10 @@ 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();
|
Quaternion q = e->PointGetQuaternion();
|
||||||
Vector p = e->PointGetNum();
|
Vector p = e->PointGetNum();
|
||||||
q = qt.Times(q);
|
q = qt.Times(q);
|
||||||
@ -365,6 +360,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||||||
// Let's rotate about the selected point; so fix up the
|
// Let's rotate about the selected point; so fix up the
|
||||||
// translation so that that point didn't move.
|
// translation so that that point didn't move.
|
||||||
e->PointForceTo(p);
|
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: {
|
||||||
|
Loading…
Reference in New Issue
Block a user