mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:37:29 +02:00
Rotation bits for alternate IK.
This commit is contained in:
parent
94988ed5e6
commit
3eefb6a93e
1 changed files with 14 additions and 2 deletions
|
@ -322,8 +322,8 @@ void SkeletonModel::setHandPosition(int jointIndex, const glm::vec3& position, c
|
||||||
const float NORMAL_WEIGHT = 0.5f;
|
const float NORMAL_WEIGHT = 0.5f;
|
||||||
glm::vec3 finalNormal = glm::mix(relaxedNormal, handNormal, NORMAL_WEIGHT);
|
glm::vec3 finalNormal = glm::mix(relaxedNormal, handNormal, NORMAL_WEIGHT);
|
||||||
|
|
||||||
if((jointIndex == geometry.rightHandJointIndex && finalNormal.y > 0.0f) ||
|
bool rightHand = (jointIndex == geometry.rightHandJointIndex);
|
||||||
(jointIndex == geometry.leftHandJointIndex && finalNormal.y < 0)) {
|
if (rightHand ? (finalNormal.y > 0.0f) : (finalNormal.y < 0.0f)) {
|
||||||
finalNormal.y = 0.0f; // dont allow elbows to point inward (y is vertical axis)
|
finalNormal.y = 0.0f; // dont allow elbows to point inward (y is vertical axis)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,5 +331,17 @@ void SkeletonModel::setHandPosition(int jointIndex, const glm::vec3& position, c
|
||||||
|
|
||||||
// ik solution
|
// ik solution
|
||||||
glm::vec3 elbowPosition = shoulderPosition + glm::normalize(shoulderToWrist) * mid - tangent * height;
|
glm::vec3 elbowPosition = shoulderPosition + glm::normalize(shoulderToWrist) * mid - tangent * height;
|
||||||
|
|
||||||
|
glm::vec3 forwardVector(rightHand ? -1.0f : 1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::quat shoulderRotation;
|
||||||
|
getJointRotation(shoulderJointIndex, shoulderRotation, true);
|
||||||
|
applyRotationDelta(shoulderJointIndex, rotationBetween(shoulderRotation * forwardVector, elbowPosition - shoulderPosition), false);
|
||||||
|
|
||||||
|
glm::quat elbowRotation;
|
||||||
|
getJointRotation(elbowJointIndex, elbowRotation, true);
|
||||||
|
applyRotationDelta(elbowJointIndex, rotationBetween(elbowRotation * forwardVector, wristPosition - elbowPosition), false);
|
||||||
|
|
||||||
|
setJointRotation(jointIndex, rotation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue