diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 58ec217e06..41cc3ee04d 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -297,7 +297,6 @@ void Avatar::UpdateGyros(float frametime, SerialInterface* serialInterface, glm: if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW)) { addHeadYaw(_head.yawRate * HEAD_ROTATION_SCALE * frametime); } - } float Avatar::getAbsoluteHeadYaw() const { @@ -322,12 +321,10 @@ void Avatar::setMousePressed(bool d) { _mousePressed = d; } - bool Avatar::getIsNearInteractingOther() { return _avatarTouch.getAbleToReachOtherAvatar(); } - void Avatar::simulate(float deltaTime) { @@ -454,7 +451,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { _avatarTouch.setMyBodyPosition(_position); Avatar * _interactingOther = NULL; - float closestDistance = 10000.0f; + float closestDistance = std::numeric_limits::max();; //loop through all the other avatars for potential interactions... AgentList* agentList = AgentList::getInstance(); @@ -473,7 +470,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } if (_interactingOther) { - _avatarTouch.setYourHandPosition(_interactingOther->_position); + _avatarTouch.setYourBodyPosition(_interactingOther->_position); + _avatarTouch.setYourHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); } }//if (_isMine) @@ -486,12 +484,16 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { //Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); _handState = _mousePressed; + + _avatarTouch.setMyHandState(_handState); + + if (_handState == 1) { + _avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); + } } - } +} - - void Avatar::updateHead(float deltaTime) { //apply the head lean values to the springy position... diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index 5dd44d46cc..712a7af030 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -61,23 +61,12 @@ void AvatarTouch::setReachableRadius( float r ) { void AvatarTouch::render() { -if (_canReachToOtherAvatar) { + if (_canReachToOtherAvatar) { glPushMatrix(); - glTranslatef(_myBodyPosition.x, _myBodyPosition.y, _myBodyPosition.z); + glTranslatef(_yourBodyPosition.x, _yourBodyPosition.y, _yourBodyPosition.z); glColor4f( 0.3, 0.4, 0.5, 0.3 ); glutSolidSphere( _reachableRadius, 30.0f, 30.0f ); glPopMatrix(); - - /* - // if my hand is grasping, show it... - if ( _myHandState == 1 ) { - glPushMatrix(); - glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z); - glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); - glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f ); - glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); - glPopMatrix(); - } - + // if your hand is grasping, show it... if ( _yourHandState == 1 ) { glPushMatrix(); @@ -87,7 +76,16 @@ if (_canReachToOtherAvatar) { glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); glPopMatrix(); } - */ + } + + // if my hand is grasping, show it... + if ( _myHandState == 1 ) { + glPushMatrix(); + glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z); + glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); + glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f ); + glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); + glPopMatrix(); } /* @@ -123,12 +121,12 @@ void AvatarTouch::simulate (float deltaTime) { float distance = glm::length(v); - if (distance < _reachableRadius * 2.0f ) { + if (distance < _reachableRadius * 2.3f ) { _canReachToOtherAvatar = true; } else { _canReachToOtherAvatar = false; } - + /* for (int p=0; p