Ejemplo n.º 1
0
void AvatarManager::updateOtherAvatars(float deltaTime) {
    PerformanceWarning warn(Application::getInstance()->getPipelineWarningsOption(), "Application::updateAvatars()");

    Application* applicationInstance = Application::getInstance();
    glm::vec3 mouseOrigin = applicationInstance->getMouseRayOrigin();
    glm::vec3 mouseDirection = applicationInstance->getMouseRayDirection();

    // simulate avatars
    AvatarHash::iterator avatarIterator = _avatarHash.begin();
    while (avatarIterator != _avatarHash.end()) {
        Avatar* avatar = static_cast<Avatar*>(avatarIterator.value().data());
        if (avatar == static_cast<Avatar*>(_myAvatar.data())) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            //updateMyAvatar(deltaTime);
            ++avatarIterator;
            continue;
        }
        if (avatar->getOwningAvatarMixer()) {
            // this avatar's mixer is still around, go ahead and simulate it
            avatar->simulate(deltaTime);
            avatar->setMouseRay(mouseOrigin, mouseDirection);
            ++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
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()) {
        auto avatar = std::dynamic_pointer_cast<Avatar>(avatarIterator.value());
        
        if (avatar == _myAvatar || !avatar->isInitialized()) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            // DO NOT update or fade out uninitialized Avatars
            ++avatarIterator;
        } else if (avatar->shouldDie()) {
            removeAvatarMotionState(avatar);
            _avatarFades.push_back(avatarIterator.value());
            avatarIterator = _avatarHash.erase(avatarIterator);
        } else {
            avatar->simulate(deltaTime);
            ++avatarIterator;
        }
    }
    
    // simulate avatar fades
    simulateAvatarFades(deltaTime);
}
Ejemplo n.º 3
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.º 4
0
void AvatarManager::updateOtherAvatars(float deltaTime) {
    // lock the hash for read to check the size
    QReadLocker lock(&_hashLock);

    if (_avatarHash.size() < 2 && _avatarFades.isEmpty()) {
        return;
    }

    lock.unlock();

    bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
    PerformanceWarning warn(showWarnings, "Application::updateAvatars()");

    PerformanceTimer perfTimer("otherAvatars");

    // simulate avatars
    auto hashCopy = getHashCopy();

    AvatarHash::iterator avatarIterator = hashCopy.begin();
    while (avatarIterator != hashCopy.end()) {
        auto avatar = std::static_pointer_cast<Avatar>(avatarIterator.value());

        if (avatar == _myAvatar || !avatar->isInitialized()) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            // DO NOT update or fade out uninitialized Avatars
            ++avatarIterator;
        } else if (avatar->shouldDie()) {
            removeAvatar(avatarIterator.key());
            ++avatarIterator;
        } else {
            avatar->startUpdate();
            avatar->simulate(deltaTime);
            avatar->endUpdate();
            ++avatarIterator;
        }
    }

    // simulate avatar fades
    simulateAvatarFades(deltaTime);
}