Merge pull request #444 from Ventrella/master

fixed bug causing camera to not get updated position of other avatar
This commit is contained in:
ZappoMan 2013-05-28 18:56:17 -07:00
commit 6ff2d1a102
3 changed files with 42 additions and 32 deletions

View file

@ -509,6 +509,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
if (_interactingOther) { if (_interactingOther) {
_avatarTouch.setHasInteractingOther(true);
_avatarTouch.setYourBodyPosition(_interactingOther->_position); _avatarTouch.setYourBodyPosition(_interactingOther->_position);
_avatarTouch.setYourOrientation (_interactingOther->_orientation); _avatarTouch.setYourOrientation (_interactingOther->_orientation);
_avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); _avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
@ -561,6 +562,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
_velocity += vectorFromMyHandToYourHand * force; _velocity += vectorFromMyHandToYourHand * force;
} }
} }
} else {
_avatarTouch.setHasInteractingOther(false);
} }
}//if (_isMine) }//if (_isMine)

View file

@ -28,6 +28,7 @@ AvatarTouch::AvatarTouch() {
_weAreHoldingHands = false; _weAreHoldingHands = false;
_canReachToOtherAvatar = false; _canReachToOtherAvatar = false;
_handsCloseEnoughToGrasp = false; _handsCloseEnoughToGrasp = false;
_hasInteractingOther = false;
_myOrientation.setToIdentity(); _myOrientation.setToIdentity();
_yourOrientation.setToIdentity(); _yourOrientation.setToIdentity();
@ -38,34 +39,38 @@ AvatarTouch::AvatarTouch() {
void AvatarTouch::simulate (float deltaTime) { void AvatarTouch::simulate (float deltaTime) {
glm::vec3 vectorBetweenBodies = _yourBodyPosition - _myBodyPosition; _canReachToOtherAvatar = false; // default
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)) {
facingEachOther = true;
}
if ((distanceBetweenBodies < _reachableRadius) if (_hasInteractingOther) {
&& (facingEachOther)) {
_vectorBetweenHands = _yourHandPosition - _myHandPosition; glm::vec3 vectorBetweenBodies = _yourBodyPosition - _myBodyPosition;
float distanceBetweenBodies = glm::length(vectorBetweenBodies);
glm::vec3 directionBetweenBodies = vectorBetweenBodies / distanceBetweenBodies;
float distanceBetweenHands = glm::length(_vectorBetweenHands); bool facingEachOther = false;
if (distanceBetweenHands < HANDS_CLOSE_ENOUGH_TO_GRASP) {
_handsCloseEnoughToGrasp = true; if (( glm::dot(_myOrientation.getFront(), _yourOrientation.getFront()) < -AVATAR_FACING_THRESHOLD) // we're facing each other
} else { && ( glm::dot(_myOrientation.getFront(), directionBetweenBodies ) > AVATAR_FACING_THRESHOLD)) { // I'm facing you
_handsCloseEnoughToGrasp = false; facingEachOther = true;
} }
_canReachToOtherAvatar = true; if ((distanceBetweenBodies < _reachableRadius)
} else { && (facingEachOther)) {
_canReachToOtherAvatar = false; _canReachToOtherAvatar = true;
}
_vectorBetweenHands = _yourHandPosition - _myHandPosition;
float distanceBetweenHands = glm::length(_vectorBetweenHands);
if (distanceBetweenHands < HANDS_CLOSE_ENOUGH_TO_GRASP) {
_handsCloseEnoughToGrasp = true;
} else {
_handsCloseEnoughToGrasp = false;
}
}
}
} }
void AvatarTouch::render(glm::vec3 cameraPosition) { void AvatarTouch::render(glm::vec3 cameraPosition) {
if (_canReachToOtherAvatar) { if (_canReachToOtherAvatar) {

View file

@ -28,16 +28,17 @@ public:
void simulate(float deltaTime); void simulate(float deltaTime);
void render(glm::vec3 cameraPosition); void render(glm::vec3 cameraPosition);
void setMyHandPosition (glm::vec3 position ) { _myHandPosition = position; } void setHasInteractingOther(bool hasInteractingOther) { _hasInteractingOther = hasInteractingOther;}
void setYourHandPosition(glm::vec3 position ) { _yourHandPosition = position; } void setMyHandPosition (glm::vec3 position ) { _myHandPosition = position;}
void setMyOrientation (Orientation orientation) { _myOrientation = orientation; } void setYourHandPosition (glm::vec3 position ) { _yourHandPosition = position;}
void setYourOrientation (Orientation orientation) { _yourOrientation = orientation; } void setMyOrientation (Orientation orientation ) { _myOrientation = orientation;}
void setMyBodyPosition (glm::vec3 position ) { _myBodyPosition = position; } void setYourOrientation (Orientation orientation ) { _yourOrientation = orientation;}
void setYourBodyPosition(glm::vec3 position ) { _yourBodyPosition = position; } void setMyBodyPosition (glm::vec3 position ) { _myBodyPosition = position;}
void setMyHandState (int state ) { _myHandState = state; } void setYourBodyPosition (glm::vec3 position ) { _yourBodyPosition = position;}
void setYourHandState (int state ) { _yourHandState = state; } void setMyHandState (int state ) { _myHandState = state;}
void setReachableRadius (float radius ) { _reachableRadius = radius; } void setYourHandState (int state ) { _yourHandState = state;}
void setHoldingHands (bool holding ) { _weAreHoldingHands = holding; } void setReachableRadius (float radius ) { _reachableRadius = radius;}
void setHoldingHands (bool holding ) { _weAreHoldingHands = holding;}
bool getAbleToReachOtherAvatar () const {return _canReachToOtherAvatar; } bool getAbleToReachOtherAvatar () const {return _canReachToOtherAvatar; }
bool getHandsCloseEnoughToGrasp() const {return _handsCloseEnoughToGrasp;} bool getHandsCloseEnoughToGrasp() const {return _handsCloseEnoughToGrasp;}
@ -47,6 +48,7 @@ private:
static const int NUM_POINTS = 100; static const int NUM_POINTS = 100;
bool _hasInteractingOther;
bool _weAreHoldingHands; bool _weAreHoldingHands;
glm::vec3 _point [NUM_POINTS]; glm::vec3 _point [NUM_POINTS];
glm::vec3 _myBodyPosition; glm::vec3 _myBodyPosition;