diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 6f293f2fef..25d26d0502 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -136,6 +136,7 @@ Head::Head(bool isMine) { for (int o=0; ogetLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) { Head *otherAvatar = (Head *)agent->getLinkedData(); - if ( _numOtherAvatarsInView < MAX_OTHER_AVATARS ) { + if ( _numOtherAvatarsInView < MAX_OTHER_AVATARS ) { + + //------------------------------------------------------ + // check for collisions with other avatars and respond + //------------------------------------------------------ + updateAvatarCollisionDetectionAndResponse + ( + otherAvatar->getBodyPosition(), + otherAvatar->getGirth(), + otherAvatar->getHeight(), + otherAvatar->getBodyUpDirection(), + deltaTime + ); //----------------------------------------------------------- - // test other avatar hand position for proximity... + // test other avatar hand position for proximity and state //----------------------------------------------------------- _otherAvatarHandPosition[ _numOtherAvatarsInView ] = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); + _otherAvatarHandState [ _numOtherAvatarsInView ] = (int)otherAvatar->getHandState(); + glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); v -= _otherAvatarHandPosition[ _numOtherAvatarsInView ]; + //if ( otherAvatar->getHandState() == 1 ) + { + printf( "otherAvatar->getHandState() is %d\n", (int)otherAvatar->getHandState() ); + } + float distance = glm::length( v ); if ( distance < _maxArmLength ) { if ( distance < closestDistance ) { @@ -347,7 +367,14 @@ void Head::simulate(float deltaTime) { //-------------------------------------------------------------- // test for avatar collision response (using a big sphere :) //-------------------------------------------------------------- - updateAvatarCollisionDetectionAndResponse(_TEST_bigSpherePosition, _TEST_bigSphereRadius, deltaTime); + updateAvatarCollisionDetectionAndResponse + ( + _TEST_bigSpherePosition, + _TEST_bigSphereRadius, + _TEST_bigSphereRadius, + glm::vec3( 0.0, 1.0, 0.0 ), + deltaTime + ); } if ( AVATAR_GRAVITY ) { @@ -565,37 +592,25 @@ float Head::getHeight() { glm::vec3 Head::getBodyUpDirection() { return _orientation.getUp(); } - - -bool Head::testForCollision( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector ) { - _collisionElipsoid.colliding = false; - _collisionElipsoid.position = glm::vec3( 0.0, 0.0, 0.0 ); - _collisionElipsoid.upVector = glm::vec3( 0.0, 0.0, 0.0 ); - _collisionElipsoid.girth = 0.0; - _collisionElipsoid.height = 0.0; - - return false; -} - - //-------------------------------------------------------------------------------- // This is a workspace for testing avatar body collision detection and response //-------------------------------------------------------------------------------- -void Head::updateAvatarCollisionDetectionAndResponse( glm::vec3 collisionPosition, float collisionRadius, float deltaTime ) { +void Head::updateAvatarCollisionDetectionAndResponse +( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector, float deltaTime ) { float myBodyApproximateBoundingRadius = 1.0f; glm::vec3 vectorFromMyBodyToBigSphere(_bodyPosition - collisionPosition); bool jointCollision = false; float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere); - if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionRadius ) + if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionGirth ) { for (int b=0; b::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++) { @@ -1502,9 +1502,6 @@ void idle(void) { { Head *avatar = (Head *)agent->getLinkedData(); avatar->simulate(deltaTime); - - //not ready yet... - //myAvatar.testForCollision( avatar->getBodyPosition(), avatar->getGirth(), avatar->getHeight(), avatar->getBodyUpDirection() ); } } @@ -1515,7 +1512,6 @@ void idle(void) { glutPostRedisplay(); lastTimeIdle = check; - } // Read serial data diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 4655873dcd..e133d965c5 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -48,7 +48,7 @@ public: // Hand State void setHandState(char s) { _handState = s; }; - const float getHandState() const {return _handState; }; + const float getHandState() const {return _handState; }; //@Philip - shouldn't this be an int or a char? // Instantaneous audio loudness to drive mouth/facial animation void setLoudness(float l) { _audioLoudness = l; };