Showing the changes to interface/src/Head.cpp (1 of 2 files). Show all
Unified · Split
| @@ -59,7 +59,6 @@ Head::Head(bool isMine) { · 58 unmodified lines | ||
| 59 | 59 | //_transmitterTimer = 0; |
| 60 | 60 | _transmitterHz = 0.0; |
| 61 | 61 | _transmitterPackets = 0; |
| 62 | − //_numOtherAvatars = 0; | |
| 63 | 62 | |
| 64 | 63 | initializeSkeleton(); |
| 65 | 64 | |
| @@ -307,8 +306,6 @@ void Head::simulate(float deltaTime) { · 241 unmodified lines | ||
| 307 | 306 | float closestDistance = 10000.0f; |
| 308 | 307 | |
| 309 | 308 | AgentList * agentList = AgentList::getInstance(); |
| 310 | − | |
| 311 | − //_numOtherAvatars = 0; | |
| 312 | 309 | |
| 313 | 310 | for(std::vector<Agent>::iterator agent = agentList->getAgents().begin(); |
| 314 | 311 | agent != agentList->getAgents().end(); |
| @@ -316,35 +313,31 @@ void Head::simulate(float deltaTime) { · 1 unmodified line | ||
| 316 | 313 | if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) { |
| 317 | 314 | Head *otherAvatar = (Head *)agent->getLinkedData(); |
| 318 | 315 | |
| 319 | − // if ( _numOtherAvatars < MAX_OTHER_AVATARS ) | |
| 320 | − { | |
| 321 | − | |
| 322 | − //------------------------------------------------------ | |
| 323 | − // check for collisions with other avatars and respond | |
| 324 | − //------------------------------------------------------ | |
| 325 | − updateAvatarCollisionDetectionAndResponse | |
| 326 | − ( | |
| 327 | − otherAvatar->getPosition(), | |
| 328 | − otherAvatar->getGirth(), | |
| 329 | − otherAvatar->getHeight(), | |
| 330 | − otherAvatar->getBodyUpDirection(), | |
| 331 | − deltaTime | |
| 332 | − ); | |
| 333 | − | |
| 334 | − //------------------------------------------------- | |
| 335 | − // test other avatar hand position for proximity | |
| 336 | − //------------------------------------------------ | |
| 337 | − glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); | |
| 338 | − v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); | |
| 339 | − | |
| 340 | − float distance = glm::length( v ); | |
| 341 | − if ( distance < _maxArmLength ) { | |
| 342 | − if ( distance < closestDistance ) { | |
| 343 | − closestDistance = distance; | |
| 344 | − _otherAvatar.nearby = true; | |
| 345 | − _otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); | |
| 346 | − _otherAvatar.handState = (int)otherAvatar->getHandState(); | |
| 347 | − } | |
| 316 | + //------------------------------------------------------ | |
| 317 | + // check for collisions with other avatars and respond | |
| 318 | + //------------------------------------------------------ | |
| 319 | + updateAvatarCollisionDetectionAndResponse | |
| 320 | + ( | |
| 321 | + otherAvatar->getPosition(), | |
| 322 | + otherAvatar->getGirth(), | |
| 323 | + otherAvatar->getHeight(), | |
| 324 | + otherAvatar->getBodyUpDirection(), | |
| 325 | + deltaTime | |
| 326 | + ); | |
| 327 | + | |
| 328 | + //------------------------------------------------- | |
| 329 | + // test other avatar hand position for proximity | |
| 330 | + //------------------------------------------------ | |
| 331 | + glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); | |
| 332 | + v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); | |
| 333 | + | |
| 334 | + float distance = glm::length( v ); | |
| 335 | + if ( distance < _maxArmLength ) { | |
| 336 | + if ( distance < closestDistance ) { | |
| 337 | + closestDistance = distance; | |
| 338 | + _otherAvatar.nearby = true; | |
| 339 | + _otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); | |
| 340 | + _otherAvatar.handState = (int)otherAvatar->getHandState(); | |
| 348 | 341 | } |
| 349 | 342 | } |
| 350 | 343 | } |
| @@ -1130,13 +1123,14 @@ void Head::updateHandMovement( float deltaTime ) { · 779 unmodified lines | ||
| 1130 | 1123 | |
| 1131 | 1124 | setHandState(_mousePressed); |
| 1132 | 1125 | |
| 1126 | + /* | |
| 1133 | 1127 | if ( _otherAvatar.nearby ) { |
| 1134 | 1128 | if ( _otherAvatar.handState == 1 ) { |
| 1135 | 1129 | printf( "(1)" ); |
| 1136 | 1130 | } |
| 1137 | − //else { | |
| 1138 | − // printf( "(0)" ); | |
| 1139 | − //} | |
| 1131 | + else { | |
| 1132 | + printf( "(0)" ); | |
| 1133 | + } | |
| 1140 | 1134 | |
| 1141 | 1135 | if ( _handState == 1 ) { |
| 1142 | 1136 | printf( "1" ); |
| @@ -1145,27 +1139,31 @@ void Head::updateHandMovement( float deltaTime ) { · 2 unmodified lines | ||
| 1145 | 1139 | printf( "0" ); |
| 1146 | 1140 | } |
| 1147 | 1141 | } |
| 1142 | + */ | |
| 1148 | 1143 | |
| 1149 | 1144 | //--------------------------------------------------------------------- |
| 1150 | − // if holding hands with another avatar, add a force to the hand... | |
| 1145 | + // if I am holding hands with another avatar, a force is added | |
| 1146 | + // to my hand, causing it to move closer to the other avatar's hand... | |
| 1151 | 1147 | //--------------------------------------------------------------------- |
| 1152 | − if (( _handState == 1 ) | |
| 1153 | − || ( _otherAvatar.handState == 1 )) { | |
| 1148 | + if ( _isMine ) | |
| 1149 | + { | |
| 1154 | 1150 | if ( _otherAvatar.nearby ) { |
| 1155 | − | |
| 1156 | − glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position; | |
| 1157 | − glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position; | |
| 1158 | − | |
| 1159 | − _handHolding.velocity *= 0.7; | |
| 1160 | − _handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime; | |
| 1161 | − _handHolding.position += _handHolding.velocity; | |
| 1162 | − | |
| 1163 | − _bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position; | |
| 1164 | − } | |
| 1165 | − } | |
| 1166 | − else { | |
| 1167 | − _handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position; | |
| 1168 | − _handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 ); | |
| 1151 | + if (( getHandState() == 1 ) | |
| 1152 | + || ( _otherAvatar.handState == 1 )) { | |
| 1153 | + glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position; | |
| 1154 | + glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position; | |
| 1155 | + | |
| 1156 | + _handHolding.velocity *= 0.7; | |
| 1157 | + _handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime; | |
| 1158 | + _handHolding.position += _handHolding.velocity; | |
| 1159 | + | |
| 1160 | + _bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position; | |
| 1161 | + } | |
| 1162 | + } | |
| 1163 | + else { | |
| 1164 | + _handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position; | |
| 1165 | + _handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 ); | |
| 1166 | + } | |
| 1169 | 1167 | } |
| 1170 | 1168 | |
| 1171 | 1169 | //------------------------------------------------------------------------------- |