mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:57:37 +02:00
improved avatar hand-holding logic
This commit is contained in:
parent
8135a45ccf
commit
ee9ae3f220
1 changed files with 17 additions and 24 deletions
|
@ -1006,11 +1006,14 @@ void Head::updateSkeleton() {
|
||||||
_bone[b].position = _bone[ _bone[b].parent ].position;
|
_bone[b].position = _bone[ _bone[b].parent ].position;
|
||||||
}
|
}
|
||||||
|
|
||||||
///TEST! - get this working and then add a comment; JJV
|
//-------------------------------------------------------------------------------------
|
||||||
|
// if this is not my avatar, then hand position comes from transmitted data
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
if ( ! _isMine ) {
|
if ( ! _isMine ) {
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the following will be replaced by a proper rotation...
|
||||||
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight() );
|
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight() );
|
||||||
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
||||||
float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront() );
|
float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront() );
|
||||||
|
@ -1024,7 +1027,6 @@ void Head::updateSkeleton() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Head::initializeBodySprings() {
|
void Head::initializeBodySprings() {
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
_bone[b].springyPosition = _bone[b].position;
|
_bone[b].springyPosition = _bone[b].position;
|
||||||
|
@ -1128,31 +1130,22 @@ void Head::updateHandMovement( float deltaTime ) {
|
||||||
|
|
||||||
setHandState(_mousePressed);
|
setHandState(_mousePressed);
|
||||||
|
|
||||||
bool atLeastOneAvatarIsGrasping = false;
|
|
||||||
|
|
||||||
if ( getHandState() == 1 ) { atLeastOneAvatarIsGrasping = true; }
|
|
||||||
|
|
||||||
//if ( _isMine ) {
|
|
||||||
//if ( _otherAvatar.handState == 1 ) {
|
|
||||||
if ( _nearOtherAvatar ) {
|
|
||||||
atLeastOneAvatarIsGrasping = true;
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// if holding hands with another avatar, add a force to the hand...
|
// if holding hands with another avatar, add a force to the hand...
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
if ( atLeastOneAvatarIsGrasping ) {
|
if (( getHandState() == 1 )
|
||||||
|
|| ( _otherAvatar.handState == 1 )) {
|
||||||
glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position;
|
if ( _nearOtherAvatar ) {
|
||||||
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position;
|
|
||||||
|
glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position;
|
||||||
_handHolding.velocity *= 0.7;
|
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position;
|
||||||
_handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime;
|
|
||||||
_handHolding.position += _handHolding.velocity;
|
_handHolding.velocity *= 0.7;
|
||||||
|
_handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime;
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position;
|
_handHolding.position += _handHolding.velocity;
|
||||||
|
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
_handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||||
|
|
Loading…
Reference in a new issue