Ejemplo n.º 1
0
void AvatarManager::updateOtherAvatars(float deltaTime) {
    if (_avatarHash.size() < 2 && _avatarFades.isEmpty()) {
        return;
    }
    bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
    PerformanceWarning warn(showWarnings, "Application::updateAvatars()");

    PerformanceTimer perfTimer("otherAvatars");
    
    // simulate avatars
    AvatarHash::iterator avatarIterator = _avatarHash.begin();
    while (avatarIterator != _avatarHash.end()) {
        AvatarSharedPointer sharedAvatar = avatarIterator.value();
        Avatar* avatar = reinterpret_cast<Avatar*>(sharedAvatar.data());
        
        if (sharedAvatar == _myAvatar || !avatar->isInitialized()) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            // DO NOT update uninitialized Avatars
            ++avatarIterator;
            continue;
        }
        if (!shouldKillAvatar(sharedAvatar)) {
            // this avatar's mixer is still around, go ahead and simulate it
            avatar->simulate(deltaTime);
            ++avatarIterator;
        } else {
            // the mixer that owned this avatar is gone, give it to the vector of fades and kill it
            avatarIterator = erase(avatarIterator);
        }
    }
    
    // simulate avatar fades
    simulateAvatarFades(deltaTime);
}
Ejemplo n.º 2
0
bool AvatarHashMap::containsAvatarWithDisplayName(const QString& displayName) {
    
    AvatarHash::iterator avatarIterator = _avatarHash.begin();
    while (avatarIterator != _avatarHash.end()) {
        AvatarSharedPointer sharedAvatar = avatarIterator.value();
        if (avatarIterator.value()->getDisplayName() == displayName) {
            // this is a match
            // check if this avatar should still be around
            if (!shouldKillAvatar(sharedAvatar)) {
                // we have a match, return true
                return true;
            } else {
                // we should remove this avatar, do that now
                erase(avatarIterator);
            }
            
            break;
        } else {
            ++avatarIterator;
        }
    }
    
    // return false, no match
    return false;
}
Ejemplo n.º 3
0
AvatarData* AvatarHashMap::avatarWithDisplayName(const QString& displayName) {
    foreach(const AvatarSharedPointer& sharedAvatar, _avatarHash) {
        if (sharedAvatar->getDisplayName() == displayName) {
            // this is a match
            // check if this avatar should still be around
            if (!shouldKillAvatar(sharedAvatar)) {
                // we have a match, return the AvatarData
                return sharedAvatar.data();
            } else {
                // we should remove this avatar, but we might not be on a thread that is allowed
                // so we just return NULL to the caller
                return NULL;
            }
        }
    }
        
    return NULL;
}