Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 1 file). Show all
Unified · Split
| @@ -320,16 +320,16 @@ void SkeletonModel::setHandPosition(int jointIndex, const glm::vec3& position, c · 319 unmodified lines | |||
| 320 | glm::vec3 handNormal = glm::cross(rotation * glm::vec3(0.0f, 1.0f, 0.0f), shoulderToWrist); // elbow rotating with wrist | 320 | glm::vec3 handNormal = glm::cross(rotation * glm::vec3(0.0f, 1.0f, 0.0f), shoulderToWrist); // elbow rotating with wrist |
| 321 | glm::vec3 relaxedNormal = glm::cross(glm::vec3(0.0f, 1.0f, 0.0f), shoulderToWrist); // elbow pointing straight down | 321 | glm::vec3 relaxedNormal = glm::cross(glm::vec3(0.0f, 1.0f, 0.0f), shoulderToWrist); // elbow pointing straight down |
| 322 | const float NORMAL_WEIGHT = 0.5f; | 322 | const float NORMAL_WEIGHT = 0.5f; |
| 323 | glm::vec3 finalNormal = glm::mix(relaxedNormal, handNormal, NORMAL_WEIGHT); | 323 | glm::vec3 finalNormal = glm::mix(relaxedNormal, handNormal, NORMAL_WEIGHT); |
| 324 | 324 | ||
| 325 | bool rightHand = (jointIndex == geometry.rightHandJointIndex); | 325 | bool rightHand = (jointIndex == geometry.rightHandJointIndex); |
| 326 | if (rightHand ? (finalNormal.y > 0.0f) : (finalNormal.y < 0.0f)) { | 326 | if (rightHand ? (finalNormal.y > 0.0f) : (finalNormal.y < 0.0f)) { |
| 327 | finalNormal.y = 0.0f; // dont allow elbows to point inward (y is vertical axis) | 327 | finalNormal.y = 0.0f; // dont allow elbows to point inward (y is vertical axis) |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | glm::vec3 tangent = glm::normalize(glm::cross(shoulderToWrist, finalNormal)); | 330 | glm::vec3 tangent = glm::normalize(glm::cross(shoulderToWrist, finalNormal)); |
| 331 | 331 | ||
| 332 | // ik solution | 332 | // ik solution |
| 333 | glm::vec3 elbowPosition = shoulderPosition + glm::normalize(shoulderToWrist) * mid - tangent * height; | 333 | glm::vec3 elbowPosition = shoulderPosition + glm::normalize(shoulderToWrist) * mid - tangent * height; |
| 334 | 334 | ||
| 335 | glm::vec3 forwardVector(rightHand ? -1.0f : 1.0f, 0.0f, 0.0f); | 335 | glm::vec3 forwardVector(rightHand ? -1.0f : 1.0f, 0.0f, 0.0f); |