History

hand information is in correct coordinate space, cleanup

SamGondelman committed 11 years ago

Commit d88e4841 parent 01c740f2 files · +12 −17Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+11−16
@@ -2881,10 +2881,15 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 2880 unmodified lines
28812881
28822882 palm->setActive(pose.isValid());
28832883
2884− glm::vec3 position = pose.getTranslation();
2885− glm::quat rotation = pose.getRotation();
2884+ // transform from sensor space, to world space, to avatar model space.
2885+ glm::mat4 poseMat = createMatFromQuatAndPos(pose.getRotation(), pose.getTranslation());
2886+ glm::mat4 sensorToWorldMat = _myAvatar->getSensorToWorldMatrix();
2887+ glm::mat4 modelMat = createMatFromQuatAndPos(_myAvatar->getOrientation(), _myAvatar->getPosition());
2888+ glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
2889+
2890+ glm::vec3 position = extractTranslation(objectPose);
2891+ glm::quat rotation = glm::quat_cast(objectPose);
28862892
2887− // TODO: velocity and tip position information should be converted to model space
28882893 // Compute current velocity from position change
28892894 glm::vec3 rawVelocity;
28902895 if (deltaTime > 0.0f) {
@@ -2913,6 +2918,8 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 22 unmodified lines
29132918 position = palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter);
29142919 rotation = safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter);
29152920 }
2921+ palm->setRawPosition(position);
2922+ palm->setRawRotation(rotation);
29162923
29172924 // Store the one fingertip in the palm structure so we can track velocity
29182925 const float FINGER_LENGTH = 0.3f; // meters
@@ -2925,15 +2932,6 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 6 unmodified lines
29252932 palm->setTipVelocity(glm::vec3(0.0f));
29262933 }
29272934 palm->setTipPosition(newTipPosition);
2928−
2929− // transform from sensor space, to world space, to avatar model space.
2930− glm::mat4 poseMat = createMatFromQuatAndPos(rotation, position);
2931− glm::mat4 sensorToWorldMat = _myAvatar->getSensorToWorldMatrix();
2932− glm::mat4 modelMat = createMatFromQuatAndPos(_myAvatar->getOrientation(), _myAvatar->getPosition());
2933− glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
2934−
2935− palm->setRawPosition(extractTranslation(objectPose));
2936− palm->setRawRotation(glm::quat_cast(objectPose));
29372935 }
29382936
29392937 void Application::emulateMouse(Hand* hand, float click, float shift, int index) {
@@ -2947,7 +2945,6 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) · 7 unmodified lines
29472945 break;
29482946 }
29492947 }
2950− //qDebug() << "emulateMouse" << !foundHand << !palm->isActive();
29512948 if (!foundHand || !palm->isActive()) {
29522949 return;
29532950 }
@@ -2975,9 +2972,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) · 21 unmodified lines
29752972 pos.setY(canvasSize.y / 2.0f + cursorRange * yAngle);
29762973
29772974 }
2978−
2979− //qDebug() << index << " " << click << " " << shift << " " << pos;
2980−
2975+
29812976 //If we are off screen then we should stop processing, and if a trigger or bumper is pressed,
29822977 //we should unpress them.
29832978 if (pos.x() == INT_MAX) {