Skip to content
Snippets Groups Projects
Commit 8c78953e authored by Zain Selman's avatar Zain Selman :speech_balloon:
Browse files

finalizes resizing. adds centerdrag: when not clicking the corners, the plane...

finalizes resizing. adds centerdrag: when not clicking the corners, the plane itself will be translated while preserving normal direction
parent 9d0682ea
No related branches found
No related tags found
1 merge request!2Plane interaction
...@@ -204,12 +204,10 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) { ...@@ -204,12 +204,10 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
wMouseDownPosition_ = (w * p0) + (u * p1) + (v * p2); wMouseDownPosition_ = (w * p0) + (u * p1) + (v * p2);
} }
if (target_idx == 0) pickedCorner_ = target_idx;
return;
// We hit a corner so start dragging // We hit a corner so start dragging
dragging_ = true; dragging_ = true;
pickedCorner_ = target_idx;
} }
} }
} }
...@@ -219,7 +217,6 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) { ...@@ -219,7 +217,6 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
case QEvent::MouseMove: { case QEvent::MouseMove: {
// We are actually dragging a corner
if (dragging_ && curPlane_) { if (dragging_ && curPlane_) {
QPoint position = _event->pos(); QPoint position = _event->pos();
...@@ -227,8 +224,8 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) { ...@@ -227,8 +224,8 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// matrix to transform points from image plane to curPlane_ /// matrix to transform points from image plane to curPlane_
auto plane = origPlane_; auto plane = origPlane_;
/// get the world position of the projected cursor by intersecting plane /// get the world position of the projected cursor by intersecting
/// equation with ray /// plane equation with ray
{ {
/// view coords in worldspace, with flipped y-axis /// view coords in worldspace, with flipped y-axis
const auto viewCoord = ACG::Vec3d( const auto viewCoord = ACG::Vec3d(
...@@ -259,12 +256,16 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) { ...@@ -259,12 +256,16 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
} }
/// relative to plane /// relative to plane
const auto wCurrMousePos = wCurrMousePos_ - plane.position;
const auto wMouseDownPosition = wMouseDownPosition_ - plane.position; const auto wMouseDownPosition = wMouseDownPosition_ - plane.position;
/// relative to plane
const auto wCurrMousePos = wCurrMousePos_ - plane.position;
/// update vector in worldspace /// update vector in worldspace
const auto worldSpaceUpdate = (wCurrMousePos - wMouseDownPosition) / 2.; const auto worldSpaceUpdate = (wCurrMousePos - wMouseDownPosition) / 2.;
if (pickedCorner_ != 0) {
/// We are actually dragging a corner
const auto distClickOrigin = wMouseDownPosition; const auto distClickOrigin = wMouseDownPosition;
/// scale by half updates length /// scale by half updates length
...@@ -274,10 +275,15 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) { ...@@ -274,10 +275,15 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
const auto xscale = scale[0] * plane.xDirection.length(); const auto xscale = scale[0] * plane.xDirection.length();
const auto yscale = scale[1] * plane.yDirection.length(); const auto yscale = scale[1] * plane.yDirection.length();
plane.setSize(xscale, yscale); plane.setSize(xscale, yscale);
}
/// we are just dragging the plane along (also happens when scaling,
/// dont worry)
plane.position += worldSpaceUpdate; plane.position += worldSpaceUpdate;
curPlane_->plane() = plane; /// overwrite plane curPlane_->plane() = plane; /// overwrite plane
/// signal for updates
if (lastObjId_ > 0) if (lastObjId_ > 0)
emit updatedObject(lastObjId_, UPDATE_GEOMETRY); emit updatedObject(lastObjId_, UPDATE_GEOMETRY);
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment