mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 18:44:00 +02:00
Merge pull request #185 from PhilipRosedale/master
Improvement to other avatar detection to help jeffrey's merge
This commit is contained in:
commit
f37923f906
2 changed files with 10 additions and 6 deletions
|
@ -142,6 +142,7 @@ Avatar::Avatar(bool isMine) {
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
//_canReachToOtherAvatar = false;
|
//_canReachToOtherAvatar = false;
|
||||||
_handHoldingPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
_handHoldingPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
_distanceToNearestAvatar = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
|
@ -230,6 +231,7 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
_head.lastLoudness = otherAvatar._head.lastLoudness;
|
_head.lastLoudness = otherAvatar._head.lastLoudness;
|
||||||
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
||||||
_head.noise = otherAvatar._head.noise;
|
_head.noise = otherAvatar._head.noise;
|
||||||
|
_distanceToNearestAvatar = otherAvatar._distanceToNearestAvatar;
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
|
@ -328,7 +330,6 @@ bool Avatar::getIsNearInteractingOther() {
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
float nearestAvatarDistance = std::numeric_limits<float>::max();
|
|
||||||
|
|
||||||
//keep this - I'm still using it to test things....
|
//keep this - I'm still using it to test things....
|
||||||
/*
|
/*
|
||||||
|
@ -361,6 +362,8 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
// all the other avatars for potential interactions...
|
// all the other avatars for potential interactions...
|
||||||
if ( _isMine )
|
if ( _isMine )
|
||||||
{
|
{
|
||||||
|
// Reset detector for nearest avatar
|
||||||
|
_distanceToNearestAvatar = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
AgentList* agentList = AgentList::getInstance();
|
AgentList* agentList = AgentList::getInstance();
|
||||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
|
@ -375,7 +378,7 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_SHOULDER );
|
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_SHOULDER );
|
||||||
|
|
||||||
float distance = glm::length( v );
|
float distance = glm::length( v );
|
||||||
if (distance < nearestAvatarDistance) { nearestAvatarDistance = distance; }
|
if (distance < _distanceToNearestAvatar) { _distanceToNearestAvatar = distance; }
|
||||||
|
|
||||||
if (distance < _maxArmLength + _maxArmLength) {
|
if (distance < _maxArmLength + _maxArmLength) {
|
||||||
|
|
||||||
|
@ -491,10 +494,10 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
// If someone is near, damp velocity as a function of closeness
|
// If someone is near, damp velocity as a function of closeness
|
||||||
const float AVATAR_BRAKING_RANGE = 1.2f;
|
const float AVATAR_BRAKING_RANGE = 1.2f;
|
||||||
const float AVATAR_BRAKING_STRENGTH = 25.f;
|
const float AVATAR_BRAKING_STRENGTH = 25.f;
|
||||||
if (_isMine && (nearestAvatarDistance < AVATAR_BRAKING_RANGE)) {
|
if (_isMine && (_distanceToNearestAvatar < AVATAR_BRAKING_RANGE)) {
|
||||||
_velocity *=
|
_velocity *=
|
||||||
(1.f - deltaTime * AVATAR_BRAKING_STRENGTH *
|
(1.f - deltaTime * AVATAR_BRAKING_STRENGTH *
|
||||||
(AVATAR_BRAKING_RANGE - nearestAvatarDistance));
|
(AVATAR_BRAKING_RANGE - _distanceToNearestAvatar));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update head information
|
// update head information
|
||||||
|
|
|
@ -263,6 +263,7 @@ private:
|
||||||
AvatarTouch _avatarTouch;
|
AvatarTouch _avatarTouch;
|
||||||
bool _displayingHead; // should be false if in first-person view
|
bool _displayingHead; // should be false if in first-person view
|
||||||
bool _returnHeadToCenter;
|
bool _returnHeadToCenter;
|
||||||
|
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
||||||
|
|
||||||
// private methods...
|
// private methods...
|
||||||
void initializeSkeleton();
|
void initializeSkeleton();
|
||||||
|
|
Loading…
Reference in a new issue