mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 17:30:01 +02:00
Clear finger joints when finger poses no longer being updated
This commit is contained in:
parent
8682cee17a
commit
b26f5c5811
2 changed files with 29 additions and 23 deletions
|
@ -4562,20 +4562,29 @@ void Application::update(float deltaTime) {
|
||||||
auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
|
auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
|
||||||
myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix));
|
myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix));
|
||||||
|
|
||||||
|
// If have previously done finger poses or there are new valid finger poses, update finger pose values. This so that if
|
||||||
|
// fingers are not being controlled, finger joints are not updated in MySkeletonModel.
|
||||||
|
// Assumption: Finger poses are either all present and valid or not present at all; thus can test just one joint.
|
||||||
MyAvatar::FingerPosesMap leftHandFingerPoses;
|
MyAvatar::FingerPosesMap leftHandFingerPoses;
|
||||||
|
if (myAvatar->getLeftHandFingerControllerPosesInSensorFrame().size() > 0
|
||||||
|
|| userInputMapper->getPoseState(controller::Action::LEFT_HAND_THUMB1).isValid()) {
|
||||||
for (int i = (int)controller::Action::LEFT_HAND_THUMB1; i <= (int)controller::Action::LEFT_HAND_PINKY4; i++) {
|
for (int i = (int)controller::Action::LEFT_HAND_THUMB1; i <= (int)controller::Action::LEFT_HAND_PINKY4; i++) {
|
||||||
leftHandFingerPoses[i] = {
|
leftHandFingerPoses[i] = {
|
||||||
userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
|
userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
|
||||||
userInputMapper->getActionName((controller::Action)i)
|
userInputMapper->getActionName((controller::Action)i)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
MyAvatar::FingerPosesMap rightHandFingerPoses;
|
MyAvatar::FingerPosesMap rightHandFingerPoses;
|
||||||
|
if (myAvatar->getRightHandFingerControllerPosesInSensorFrame().size() > 0
|
||||||
|
|| userInputMapper->getPoseState(controller::Action::RIGHT_HAND_THUMB1).isValid()) {
|
||||||
for (int i = (int)controller::Action::RIGHT_HAND_THUMB1; i <= (int)controller::Action::RIGHT_HAND_PINKY4; i++) {
|
for (int i = (int)controller::Action::RIGHT_HAND_THUMB1; i <= (int)controller::Action::RIGHT_HAND_PINKY4; i++) {
|
||||||
rightHandFingerPoses[i] = {
|
rightHandFingerPoses[i] = {
|
||||||
userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
|
userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),
|
||||||
userInputMapper->getActionName((controller::Action)i)
|
userInputMapper->getActionName((controller::Action)i)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myAvatar->setFingerControllerPosesInSensorFrame(leftHandFingerPoses, rightHandFingerPoses);
|
myAvatar->setFingerControllerPosesInSensorFrame(leftHandFingerPoses, rightHandFingerPoses);
|
||||||
|
|
||||||
controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT);
|
controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT);
|
||||||
|
|
|
@ -172,18 +172,13 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
|
|
||||||
_rig.updateFromEyeParameters(eyeParams);
|
_rig.updateFromEyeParameters(eyeParams);
|
||||||
|
|
||||||
|
|
||||||
if (leftHandPose.isValid()) {
|
|
||||||
updateFingers(myAvatar->getLeftHandFingerControllerPosesInSensorFrame());
|
updateFingers(myAvatar->getLeftHandFingerControllerPosesInSensorFrame());
|
||||||
}
|
|
||||||
if (rightHandPose.isValid()) {
|
|
||||||
updateFingers(myAvatar->getRightHandFingerControllerPosesInSensorFrame());
|
updateFingers(myAvatar->getRightHandFingerControllerPosesInSensorFrame());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MySkeletonModel::updateFingers(const MyAvatar::FingerPosesMap& fingerPoses) {
|
void MySkeletonModel::updateFingers(const MyAvatar::FingerPosesMap& fingerPoses) {
|
||||||
// Assumes that finger poses are kept in the poses map in order.
|
// Assumes that finger poses are kept in order in the poses map.
|
||||||
|
|
||||||
if (fingerPoses.size() == 0) {
|
if (fingerPoses.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -194,21 +189,23 @@ void MySkeletonModel::updateFingers(const MyAvatar::FingerPosesMap& fingerPoses)
|
||||||
bool isLeftHand = posesMapItr->first < (int)controller::Action::RIGHT_HAND_THUMB1;
|
bool isLeftHand = posesMapItr->first < (int)controller::Action::RIGHT_HAND_THUMB1;
|
||||||
|
|
||||||
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||||
glm::quat handJointRotation = isLeftHand
|
auto handPose = isLeftHand
|
||||||
? myAvatar->getLeftHandControllerPoseInSensorFrame().getRotation()
|
? myAvatar->getLeftHandControllerPoseInSensorFrame()
|
||||||
: myAvatar->getRightHandControllerPoseInSensorFrame().getRotation();
|
: myAvatar->getRightHandControllerPoseInSensorFrame();
|
||||||
|
auto handJointRotation = handPose.getRotation();
|
||||||
|
|
||||||
|
bool isHandValid = handPose.isValid();
|
||||||
bool isFingerValid = false;
|
bool isFingerValid = false;
|
||||||
glm::quat previousJointRotation;
|
glm::quat previousJointRotation;
|
||||||
|
|
||||||
while (posesMapItr != fingerPoses.end()) {
|
while (posesMapItr != fingerPoses.end()) {
|
||||||
auto jointName = posesMapItr->second.second;
|
auto jointName = posesMapItr->second.second;
|
||||||
if (jointName.right(1) == "1") {
|
if (isHandValid && jointName.right(1) == "1") {
|
||||||
isFingerValid = posesMapItr->second.first.isValid();
|
isFingerValid = posesMapItr->second.first.isValid();
|
||||||
previousJointRotation = handJointRotation;
|
previousJointRotation = handJointRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFingerValid) {
|
if (isHandValid && isFingerValid) {
|
||||||
auto thisJointRotation = posesMapItr->second.first.getRotation();
|
auto thisJointRotation = posesMapItr->second.first.getRotation();
|
||||||
const float CONTROLLER_PRIORITY = 2.0f;
|
const float CONTROLLER_PRIORITY = 2.0f;
|
||||||
_rig.setJointRotation(_rig.indexOfJoint(jointName), true, glm::inverse(previousJointRotation) * thisJointRotation,
|
_rig.setJointRotation(_rig.indexOfJoint(jointName), true, glm::inverse(previousJointRotation) * thisJointRotation,
|
||||||
|
|
Loading…
Reference in a new issue