mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 21:05:09 +02:00
Merge pull request #1065 from machinelevel/dev4
Add left-arm movement to remote avatars without changing network packet structure
This commit is contained in:
commit
67e035ee95
3 changed files with 49 additions and 37 deletions
|
@ -460,6 +460,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime, bool enableHandMovem
|
||||||
_skeleton.joint[AVATAR_JOINT_RIGHT_FINGERTIPS].position += transformedHandMovement;
|
_skeleton.joint[AVATAR_JOINT_RIGHT_FINGERTIPS].position += transformedHandMovement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableHandMovement |= updateLeapHandPositions();
|
||||||
|
|
||||||
//constrain right arm length and re-adjust elbow position as it bends
|
//constrain right arm length and re-adjust elbow position as it bends
|
||||||
// NOTE - the following must be called on all avatars - not just _isMine
|
// NOTE - the following must be called on all avatars - not just _isMine
|
||||||
if (enableHandMovement) {
|
if (enableHandMovement) {
|
||||||
|
@ -641,6 +643,51 @@ void Avatar::updateBodyBalls(float deltaTime) {
|
||||||
_bodyBall[BODY_BALL_HEAD_TOP].rotation * _skeleton.joint[BODY_BALL_HEAD_TOP].bindPosePosition;
|
_bodyBall[BODY_BALL_HEAD_TOP].rotation * _skeleton.joint[BODY_BALL_HEAD_TOP].bindPosePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if the Leap controls any of the avatar's hands.
|
||||||
|
bool Avatar::updateLeapHandPositions() {
|
||||||
|
bool returnValue = false;
|
||||||
|
// If there are leap-interaction hands visible, see if we can use them as the endpoints for IK
|
||||||
|
if (getHand().getPalms().size() > 0) {
|
||||||
|
PalmData const* leftLeapHand = NULL;
|
||||||
|
PalmData const* rightLeapHand = NULL;
|
||||||
|
// Look through all of the palms available (there may be more than two), and pick
|
||||||
|
// the leftmost and rightmost. If there's only one, we'll use a heuristic below
|
||||||
|
// to decode whether it's the left or right.
|
||||||
|
for (size_t i = 0; i < getHand().getPalms().size(); ++i) {
|
||||||
|
PalmData& palm = getHand().getPalms()[i];
|
||||||
|
if (palm.isActive()) {
|
||||||
|
if (!rightLeapHand || !leftLeapHand) {
|
||||||
|
rightLeapHand = leftLeapHand = &palm;
|
||||||
|
}
|
||||||
|
else if (palm.getRawPosition().x > rightLeapHand->getRawPosition().x) {
|
||||||
|
rightLeapHand = &palm;
|
||||||
|
}
|
||||||
|
else if (palm.getRawPosition().x < leftLeapHand->getRawPosition().x) {
|
||||||
|
leftLeapHand = &palm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If there's only one palm visible. Decide if it's the left or right
|
||||||
|
if (leftLeapHand == rightLeapHand && leftLeapHand) {
|
||||||
|
if (leftLeapHand->getRawPosition().x > 0) {
|
||||||
|
leftLeapHand = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rightLeapHand = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (leftLeapHand) {
|
||||||
|
_skeleton.joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].position = leftLeapHand->getPosition();
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
if (rightLeapHand) {
|
||||||
|
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = rightLeapHand->getPosition();
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
void Avatar::updateArmIKAndConstraints(float deltaTime, AvatarJointID fingerTipJointID) {
|
void Avatar::updateArmIKAndConstraints(float deltaTime, AvatarJointID fingerTipJointID) {
|
||||||
Skeleton::AvatarJoint& fingerJoint = _skeleton.joint[fingerTipJointID];
|
Skeleton::AvatarJoint& fingerJoint = _skeleton.joint[fingerTipJointID];
|
||||||
Skeleton::AvatarJoint& wristJoint = _skeleton.joint[fingerJoint.parent];
|
Skeleton::AvatarJoint& wristJoint = _skeleton.joint[fingerJoint.parent];
|
||||||
|
|
|
@ -231,6 +231,7 @@ protected:
|
||||||
glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
||||||
glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const;
|
glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const;
|
||||||
void updateBodyBalls(float deltaTime);
|
void updateBodyBalls(float deltaTime);
|
||||||
|
bool updateLeapHandPositions();
|
||||||
void updateArmIKAndConstraints(float deltaTime, AvatarJointID fingerTipJointID);
|
void updateArmIKAndConstraints(float deltaTime, AvatarJointID fingerTipJointID);
|
||||||
void setScale(const float scale);
|
void setScale(const float scale);
|
||||||
|
|
||||||
|
|
|
@ -912,43 +912,7 @@ void MyAvatar::updateHandMovementAndTouching(float deltaTime, bool enableHandMov
|
||||||
_avatarTouch.setHasInteractingOther(false);
|
_avatarTouch.setHasInteractingOther(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are leap-interaction hands visible, see if we can use them as the endpoints for IK
|
enableHandMovement |= updateLeapHandPositions();
|
||||||
if (getHand().getPalms().size() > 0) {
|
|
||||||
PalmData const* leftLeapHand = NULL;
|
|
||||||
PalmData const* rightLeapHand = NULL;
|
|
||||||
// Look through all of the palms available (there may be more than two), and pick
|
|
||||||
// the leftmost and rightmost. If there's only one, we'll use a heuristic below
|
|
||||||
// to decode whether it's the left or right.
|
|
||||||
for (size_t i = 0; i < getHand().getPalms().size(); ++i) {
|
|
||||||
PalmData& palm = getHand().getPalms()[i];
|
|
||||||
if (palm.isActive()) {
|
|
||||||
if (!rightLeapHand || !leftLeapHand) {
|
|
||||||
rightLeapHand = leftLeapHand = &palm;
|
|
||||||
}
|
|
||||||
else if (palm.getRawPosition().x > rightLeapHand->getRawPosition().x) {
|
|
||||||
rightLeapHand = &palm;
|
|
||||||
}
|
|
||||||
else if (palm.getRawPosition().x < leftLeapHand->getRawPosition().x) {
|
|
||||||
leftLeapHand = &palm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If there's only one palm visible. Decide if it's the left or right
|
|
||||||
if (leftLeapHand == rightLeapHand && leftLeapHand) {
|
|
||||||
if (leftLeapHand->getRawPosition().x > 0) {
|
|
||||||
leftLeapHand = NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rightLeapHand = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (leftLeapHand) {
|
|
||||||
_skeleton.joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].position = leftLeapHand->getPosition();
|
|
||||||
}
|
|
||||||
if (rightLeapHand) {
|
|
||||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = rightLeapHand->getPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//constrain right arm length and re-adjust elbow position as it bends
|
//constrain right arm length and re-adjust elbow position as it bends
|
||||||
// NOTE - the following must be called on all avatars - not just _isMine
|
// NOTE - the following must be called on all avatars - not just _isMine
|
||||||
|
|
Loading…
Reference in a new issue