History

more cleanup of hand holding code

Jeffrey Ventrella committed 13 years ago

Commit 4e7f1ee1 parent eca69992 files · +51 −53Browse files

Showing the changes to interface/src/Head.cpp (1 of 2 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t