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

refactors some variables and members

parent 54ebdf56
No related branches found
No related tags found
1 merge request!2Plane interaction
......@@ -211,7 +211,7 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
double u = -1, v = -1, w = -1;
rayPlaneIntersection(origin, viewDirection_, p0, p1, p2, u, v);
w = 1 - (u + v);
result_ = (w * p0) + (u * p1) + (v * p2);
wMouseDownPosition_ = (w * p0) + (u * p1) + (v * p2);
}
if (target_idx == 0)
......@@ -265,17 +265,17 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// we dont really care about the result here
rayPlaneIntersection(origin, dir, p0, p1, p2, u, v);
const auto w = 1. - (u + v);
currWorldPos_ = (w * p0) + (u * p1) + (v * p2);
wCurrMousePos_ = (w * p0) + (u * p1) + (v * p2);
}
/// relative to plane
const auto currWorldPos = currWorldPos_ - plane.position;
const auto result = result_ - plane.position;
const auto wCurrMousePos = wCurrMousePos_ - plane.position;
const auto wMouseDownPosition = wMouseDownPosition_ - plane.position;
/// update vector in worldspace
const auto worldSpaceUpdate = (currWorldPos - result) / 2.;
const auto worldSpaceUpdate = (wCurrMousePos - wMouseDownPosition) / 2.;
const auto distClickOrigin = result;
const auto distClickOrigin = wMouseDownPosition;
/// scale by half updates length
auto scale = (worldSpaceUpdate + distClickOrigin) / distClickOrigin;
......@@ -303,7 +303,7 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
// Stop dragging operation reset all properties
dragging_ = false;
pickedCorner_ = 0;
result_ = ACG::Vec3d{.0};
wMouseDownPosition_ = ACG::Vec3d{.0};
viewStartCoord_ = ACG::Vec3d{.0};
curPlane_ = nullptr;
lastObjId_ = -1;
......
......@@ -142,8 +142,8 @@ private:
int pickedCorner_;
// world space coords of the dragging start position (through raycast)
ACG::Vec3d result_{.0};
ACG::Vec3d currWorldPos_{.0};
ACG::Vec3d wMouseDownPosition_{.0};
ACG::Vec3d wCurrMousePos_{.0};
// view space coords of the dragging start position
ACG::Vec3d viewStartCoord_{.0};
ACG::Vec3d viewDirection_{.0};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment