mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 12:10:44 +02:00
Merge pull request #444 from Ventrella/master
fixed bug causing camera to not get updated position of other avatar
This commit is contained in:
commit
6ff2d1a102
3 changed files with 42 additions and 32 deletions
|
@ -509,6 +509,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
|
||||
if (_interactingOther) {
|
||||
|
||||
_avatarTouch.setHasInteractingOther(true);
|
||||
_avatarTouch.setYourBodyPosition(_interactingOther->_position);
|
||||
_avatarTouch.setYourOrientation (_interactingOther->_orientation);
|
||||
_avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
|
||||
|
@ -561,6 +562,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
_velocity += vectorFromMyHandToYourHand * force;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_avatarTouch.setHasInteractingOther(false);
|
||||
}
|
||||
}//if (_isMine)
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ AvatarTouch::AvatarTouch() {
|
|||
_weAreHoldingHands = false;
|
||||
_canReachToOtherAvatar = false;
|
||||
_handsCloseEnoughToGrasp = false;
|
||||
_hasInteractingOther = false;
|
||||
_myOrientation.setToIdentity();
|
||||
_yourOrientation.setToIdentity();
|
||||
|
||||
|
@ -38,19 +39,25 @@ AvatarTouch::AvatarTouch() {
|
|||
|
||||
void AvatarTouch::simulate (float deltaTime) {
|
||||
|
||||
_canReachToOtherAvatar = false; // default
|
||||
|
||||
if (_hasInteractingOther) {
|
||||
|
||||
glm::vec3 vectorBetweenBodies = _yourBodyPosition - _myBodyPosition;
|
||||
float distanceBetweenBodies = glm::length(vectorBetweenBodies);
|
||||
glm::vec3 directionBetweenBodies = vectorBetweenBodies / distanceBetweenBodies;
|
||||
|
||||
bool facingEachOther = false;
|
||||
|
||||
if (( glm::dot(_myOrientation.getFront(), _yourOrientation.getFront()) < -AVATAR_FACING_THRESHOLD)
|
||||
&& ( glm::dot(_myOrientation.getFront(), directionBetweenBodies ) > AVATAR_FACING_THRESHOLD)) {
|
||||
if (( glm::dot(_myOrientation.getFront(), _yourOrientation.getFront()) < -AVATAR_FACING_THRESHOLD) // we're facing each other
|
||||
&& ( glm::dot(_myOrientation.getFront(), directionBetweenBodies ) > AVATAR_FACING_THRESHOLD)) { // I'm facing you
|
||||
facingEachOther = true;
|
||||
}
|
||||
|
||||
if ((distanceBetweenBodies < _reachableRadius)
|
||||
&& (facingEachOther)) {
|
||||
_canReachToOtherAvatar = true;
|
||||
|
||||
_vectorBetweenHands = _yourHandPosition - _myHandPosition;
|
||||
|
||||
float distanceBetweenHands = glm::length(_vectorBetweenHands);
|
||||
|
@ -59,12 +66,10 @@ void AvatarTouch::simulate (float deltaTime) {
|
|||
} else {
|
||||
_handsCloseEnoughToGrasp = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_canReachToOtherAvatar = true;
|
||||
} else {
|
||||
_canReachToOtherAvatar = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AvatarTouch::render(glm::vec3 cameraPosition) {
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
void simulate(float deltaTime);
|
||||
void render(glm::vec3 cameraPosition);
|
||||
|
||||
void setHasInteractingOther(bool hasInteractingOther) { _hasInteractingOther = hasInteractingOther;}
|
||||
void setMyHandPosition (glm::vec3 position ) { _myHandPosition = position;}
|
||||
void setYourHandPosition (glm::vec3 position ) { _yourHandPosition = position;}
|
||||
void setMyOrientation (Orientation orientation ) { _myOrientation = orientation;}
|
||||
|
@ -47,6 +48,7 @@ private:
|
|||
|
||||
static const int NUM_POINTS = 100;
|
||||
|
||||
bool _hasInteractingOther;
|
||||
bool _weAreHoldingHands;
|
||||
glm::vec3 _point [NUM_POINTS];
|
||||
glm::vec3 _myBodyPosition;
|
||||
|
|
Loading…
Reference in a new issue