diff --git a/ext/ghoul b/ext/ghoul index 200401261c..c37ff8beb5 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 200401261cba513fb1faa4b7e92bd213435625ad +Subproject commit c37ff8beb5b8825ecb67b121ae4deac34677e1bd diff --git a/modules/touch/include/TouchInteraction.h b/modules/touch/include/TouchInteraction.h index 64f3f57059..c81bbcdfdb 100644 --- a/modules/touch/include/TouchInteraction.h +++ b/modules/touch/include/TouchInteraction.h @@ -85,7 +85,7 @@ struct FunctionData { std::vector selectedPoints; std::vector screenPoints; int nDOF; - glm::dvec2(*castToScreen)(glm::dvec3, Camera&, SceneGraphNode*, double); + glm::dvec2(*castToNDC)(glm::dvec3, Camera&, SceneGraphNode*, double); double(*distToMinimize)(double* par, int x, void* fdata); Camera* camera; SceneGraphNode* node; @@ -107,7 +107,6 @@ class TouchInteraction : public properties::PropertyOwner void step(double dt); void configSensitivities(double dist); void decelerate(); - glm::dvec2 modelToScreenSpace(glm::dvec3 vec, SceneGraphNode* node, double aspectRatio); void clear(); void tap(); diff --git a/modules/touch/src/TouchInteraction.cpp b/modules/touch/src/TouchInteraction.cpp index 541e40f96a..17893d7d0f 100644 --- a/modules/touch/src/TouchInteraction.cpp +++ b/modules/touch/src/TouchInteraction.cpp @@ -86,8 +86,6 @@ void TouchInteraction::update(const std::vector& list, std::vector

(fdata); - glm::dvec3 selectedPoint = ptr->selectedPoints.at(x); - glm::dvec3 pointInWorld = (ptr->node->rotationMatrix() * selectedPoint) + ptr->node->worldPosition(); // Apply transform to camera and find the new screen point of the updated camera state double vel[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // { vec2 globalRot, zoom, roll, vec2 localRot } @@ -122,7 +120,7 @@ void TouchInteraction::update(const std::vector& list, std::vector

& list, std::vector

castToScreen(selectedPoint, cam, ptr->node, ptr->aspectRatio); + glm::dvec2 newScreenPoint = ptr->castToNDC(ptr->selectedPoints.at(x), cam, ptr->node, ptr->aspectRatio); /* 2 DOF = trans in XY, 4DOF = trans XYZ + roll case // Create transformation matrix M(q) and apply transform for newPointInModelView @@ -182,7 +180,6 @@ void TouchInteraction::update(const std::vector& list, std::vector

nDOF; ++j) { dPar[j] = par[j]; } - dPar[i] += h; f1 = ptr->distToMinimize(dPar, x, fdata); g[i] = (f1 - f0) / h; @@ -193,6 +190,16 @@ void TouchInteraction::update(const std::vector& list, std::vector

rotationMatrix() * vec) + node->worldPosition() - camera.positionVec3())); + backToScreenSpace *= (-3.2596558 / backToScreenSpace.z); + backToScreenSpace.x /= aspectRatio; + + return glm::dvec2(backToScreenSpace); + }; + + const int nFingers = list.size(); int nDOF = std::min(nFingers * 2, 6); double* par = new double[nDOF]; @@ -210,21 +217,11 @@ void TouchInteraction::update(const std::vector& list, std::vector

rotationMatrix() * vec) + node->worldPosition() - camera.positionVec3())); - backToScreenSpace *= (-3.2596558 / backToScreenSpace.z); - backToScreenSpace.x /= aspectRatio; - - return glm::dvec2(backToScreenSpace); - }; - - - FunctionData fData = { selectedPoints, screenPoints, nDOF, castToScreen, distToMinimize, _camera, node, aspectRatio }; + FunctionData fData = { selectedPoints, screenPoints, nDOF, castToNDC, distToMinimize, _camera, node, aspectRatio }; void* dataPtr = reinterpret_cast(&fData); levmarq_init(&_lmstat); @@ -254,10 +251,10 @@ void TouchInteraction::update(const std::vector& list, std::vector

0.3 && _selected.size() == list.size()) { // good value to make any planet sufficiently large for direct-touch, needs better definition _directTouchMode = true; @@ -548,16 +545,6 @@ void TouchInteraction::step(double dt) { } } - -glm::dvec2 TouchInteraction::modelToScreenSpace(glm::dvec3 vec, SceneGraphNode* node, double aspectRatio) { // probably not needed, if squaredError isnt - glm::dvec3 backToScreenSpace = glm::inverse(_camera->rotationQuaternion()) - * glm::normalize(((node->rotationMatrix() * vec) + node->worldPosition() - _camera->positionVec3())); - backToScreenSpace *= (-3.2596558 / backToScreenSpace.z); - backToScreenSpace.x /= aspectRatio; - - return glm::dvec2(backToScreenSpace); -} - void TouchInteraction::configSensitivities(double dist) { // Configurates sensitivities to appropriate values when the camera is close to the focus node. std::shared_ptr gbim =