当前位置: 首页>>代码示例>>C++>>正文


C++ perfTimer函数代码示例

本文整理汇总了C++中perfTimer函数的典型用法代码示例。如果您正苦于以下问题:C++ perfTimer函数的具体用法?C++ perfTimer怎么用?C++ perfTimer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了perfTimer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: perfTimer

// protected
void EntitySimulation::sortEntitiesThatMoved() {
    // NOTE: this is only for entities that have been moved by THIS EntitySimulation.
    // External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
    PerformanceTimer perfTimer("sortingEntities");
    MovingEntitiesOperator moveOperator(_entityTree);
    AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE);
    SetOfEntities::iterator itemItr = _entitiesToSort.begin();
    while (itemItr != _entitiesToSort.end()) {
        EntityItemPointer entity = *itemItr;
        // check to see if this movement has sent the entity outside of the domain.
        AACube newCube = entity->getMaximumAACube();
        if (!domainBounds.touches(newCube)) {
            qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
            _entitiesToDelete.insert(entity);
            _mortalEntities.remove(entity);
            _entitiesToUpdate.remove(entity);
            _simpleKinematicEntities.remove(entity);
            removeEntityInternal(entity);

            _allEntities.remove(entity);
            entity->_simulated = false;

            itemItr = _entitiesToSort.erase(itemItr);
        } else {
            moveOperator.addEntityToMoveList(entity, newCube);
            ++itemItr;
        }
    }
    if (moveOperator.hasMovingEntities()) {
        PerformanceTimer perfTimer("recurseTreeWithOperator");
        _entityTree->recurseTreeWithOperator(&moveOperator);
    }

    _entitiesToSort.clear();
}
开发者ID:MarcelEdward,项目名称:hifi,代码行数:36,代码来源:EntitySimulation.cpp

示例2: lock

// protected
void EntitySimulation::sortEntitiesThatMoved() {
    QMutexLocker lock(&_mutex);
    // NOTE: this is only for entities that have been moved by THIS EntitySimulation.
    // External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
    PerformanceTimer perfTimer("sortingEntities");
    MovingEntitiesOperator moveOperator(_entityTree);
    AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
    SetOfEntities::iterator itemItr = _entitiesToSort.begin();
    while (itemItr != _entitiesToSort.end()) {
        EntityItemPointer entity = *itemItr;
        // check to see if this movement has sent the entity outside of the domain.
        bool success;
        AACube newCube = entity->getQueryAACube(success);
        if (success && !domainBounds.touches(newCube)) {
            qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
            itemItr = _entitiesToSort.erase(itemItr);
            entity->die();
            prepareEntityForDelete(entity);
        } else {
            moveOperator.addEntityToMoveList(entity, newCube);
            ++itemItr;
        }
    }
    if (moveOperator.hasMovingEntities()) {
        PerformanceTimer perfTimer("recurseTreeWithOperator");
        _entityTree->recurseTreeWithOperator(&moveOperator);
    }

    _entitiesToSort.clear();
}
开发者ID:AaronHillaker,项目名称:hifi,代码行数:31,代码来源:EntitySimulation.cpp

示例3: perfTimer

// TODO: we need a solution for changes to the postion/rotation/etc of a model...
// this current code path only addresses that in this setup case... not the changing/moving case
bool RenderableModelEntityItem::readyToAddToScene(RenderArgs* renderArgs) {
    if (!_model && renderArgs) {
        // TODO: this getModel() appears to be about 3% of model render time. We should optimize
        PerformanceTimer perfTimer("getModel");
        EntityTreeRenderer* renderer = static_cast<EntityTreeRenderer*>(renderArgs->_renderer);
        getModel(renderer);
    }
    if (renderArgs && _model && _needsInitialSimulation && _model->isActive() && _model->isLoaded()) {
        _model->setScaleToFit(true, getDimensions());
        _model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
        _model->setRotation(getRotation());
        _model->setTranslation(getPosition());
    
        // make sure to simulate so everything gets set up correctly for rendering
        {
            PerformanceTimer perfTimer("_model->simulate");
            _model->simulate(0.0f);
        }
        _needsInitialSimulation = false;

        _model->renderSetup(renderArgs);
    }
    bool ready = !_needsInitialSimulation && _model && _model->readyToAddToScene(renderArgs);
    return ready; 
}
开发者ID:mochidog,项目名称:hifi,代码行数:27,代码来源:RenderableModelEntityItem.cpp

示例4: Q_ASSERT

void RenderableZoneEntityItem::render(RenderArgs* args) {
    Q_ASSERT(getType() == EntityTypes::Zone);
    
    if (_drawZoneBoundaries) {
        switch (getShapeType()) {
            case SHAPE_TYPE_COMPOUND: {
                PerformanceTimer perfTimer("zone->renderCompound");
                updateGeometry();
                if (_model && _model->needsFixupInScene()) {
                    // check to see if when we added our models to the scene they were ready, if they were not ready, then
                    // fix them up in the scene
                    render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
                    render::PendingChanges pendingChanges;
                    _model->removeFromScene(scene, pendingChanges);
                    _model->addToScene(scene, pendingChanges);
                    
                    scene->enqueuePendingChanges(pendingChanges);
                    
                    _model->setVisibleInScene(getVisible(), scene);
                }
                break;
            }
            case SHAPE_TYPE_BOX:
            case SHAPE_TYPE_SPHERE: {
                PerformanceTimer perfTimer("zone->renderPrimitive");
                glm::vec4 DEFAULT_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
                
                Q_ASSERT(args->_batch);
                gpu::Batch& batch = *args->_batch;
                batch.setModelTransform(getTransformToCenter());
                
                auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
                
                if (getShapeType() == SHAPE_TYPE_SPHERE) {
                    const int SLICES = 15, STACKS = 15;
                    deferredLightingEffect->renderWireSphere(batch, 0.5f, SLICES, STACKS, DEFAULT_COLOR);
                } else {
                    deferredLightingEffect->renderWireCube(batch, 1.0f, DEFAULT_COLOR);
                }
                break;
            }
            default:
                // Not handled
                break;
        }
    }
    
    if ((!_drawZoneBoundaries || getShapeType() != SHAPE_TYPE_COMPOUND) &&
        _model && !_model->needsFixupInScene()) {
        // If the model is in the scene but doesn't need to be, remove it.
        render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
        render::PendingChanges pendingChanges;
        _model->removeFromScene(scene, pendingChanges);
        scene->enqueuePendingChanges(pendingChanges);
    }
}
开发者ID:CiaranLaval,项目名称:hifi,代码行数:56,代码来源:RenderableZoneEntityItem.cpp

示例5: switch

void RenderableZoneEntityItem::render(RenderArgs* args) {
    if (_drawZoneBoundaries) {
        switch (getShapeType()) {
            case SHAPE_TYPE_COMPOUND: {
                updateGeometry();
                
                if (_model && _model->isActive()) {
                    PerformanceTimer perfTimer("zone->renderCompound");
                    glPushMatrix();
                    _model->renderInScene(getLocalRenderAlpha(), args);
                    glPopMatrix();
                }
                break;
            }
            case SHAPE_TYPE_BOX:
            case SHAPE_TYPE_SPHERE: {
                PerformanceTimer perfTimer("zone->renderPrimitive");
                glm::vec3 position = getPosition();
                glm::vec3 center = getCenter();
                glm::vec3 dimensions = getDimensions();
                glm::quat rotation = getRotation();
                
                glm::vec4 DEFAULT_COLOR(1.0f, 1.0f, 1.0f, getLocalRenderAlpha());
                
                glPushMatrix(); {
                    glTranslatef(position.x, position.y, position.z);
                    glm::vec3 axis = glm::axis(rotation);
                    glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
                    glPushMatrix(); {
                        glm::vec3 positionToCenter = center - position;
                        glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
                        glScalef(dimensions.x, dimensions.y, dimensions.z);
                        
                        auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
                        
                        if (getShapeType() == SHAPE_TYPE_SPHERE) {
                            const int SLICES = 15;
                            const int STACKS = 15;
                            deferredLightingEffect->renderWireSphere(0.5f, SLICES, STACKS, DEFAULT_COLOR);
                        } else {
                            deferredLightingEffect->renderWireCube(1.0f, DEFAULT_COLOR);
                        }
                    } glPopMatrix();
                } glPopMatrix();
                break;
            }
            default:
                // Not handled
                break;
        }
    }
}
开发者ID:bakarih,项目名称:hifi,代码行数:52,代码来源:RenderableZoneEntityItem.cpp

示例6: usecTimestampNow

void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) {
    ++_frameCount;
    if (!_ragdoll) {
        return;
    }
    quint64 now = usecTimestampNow();
    quint64 startTime = now;
    quint64 expiry = startTime + maxUsec;

    moveRagdolls(deltaTime);
    enforceContacts();
    int numDolls = _otherRagdolls.size();
    {
        PerformanceTimer perfTimer("enforce");
        _ragdoll->enforceConstraints();
        for (int i = 0; i < numDolls; ++i) {
            _otherRagdolls[i]->enforceConstraints();
        }
    }

    bool collidedWithOtherRagdoll = false;
    int iterations = 0;
    float error = 0.0f;
    do {
        collidedWithOtherRagdoll = computeCollisions() || collidedWithOtherRagdoll;
        updateContacts();
        resolveCollisions();

        { // enforce constraints
            PerformanceTimer perfTimer("enforce");
            error = _ragdoll->enforceConstraints();
            for (int i = 0; i < numDolls; ++i) {
                error = glm::max(error, _otherRagdolls[i]->enforceConstraints());
            }
        }
        applyContactFriction();
        ++iterations;

        now = usecTimestampNow();
    } while (_collisions.size() != 0 && (iterations < maxIterations) && (error > minError) && (now < expiry));

    // the collisions may have moved the main ragdoll from the simulation center
    // so we remove this offset (potentially storing it as movement of the Ragdoll owner)
    _ragdoll->removeRootOffset(collidedWithOtherRagdoll);

    // also remove any offsets from the other ragdolls
    for (int i = 0; i < numDolls; ++i) {
        _otherRagdolls[i]->removeRootOffset(false);
    }
    pruneContacts();
}
开发者ID:JeroMiya,项目名称:hifi,代码行数:51,代码来源:PhysicsSimulation.cpp

示例7: perfTimer

void RenderableLightEntityItem::render(RenderArgs* args) {
    PerformanceTimer perfTimer("RenderableLightEntityItem::render");
    assert(getType() == EntityTypes::Light);
    glm::vec3 position = getPosition();
    glm::vec3 dimensions = getDimensions();
    glm::quat rotation = getRotation();
    float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);

    glm::vec3 color = toGlm(getXColor());

    float intensity = getIntensity();
    float exponent = getExponent();
    float cutoff = glm::radians(getCutoff());

    if (_isSpotlight) {
        DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
            color, intensity, rotation, exponent, cutoff);
    } else {
        DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
            color, intensity);
    }
    
#ifdef WANT_DEBUG
    Q_ASSERT(args->_batch);
    gpu::Batch& batch = *args->_batch;
    batch.setModelTransform(getTransformToCenter());
    DependencyManager::get<GeometryCache>()->renderWireSphere(batch, 0.5f, 15, 15, glm::vec4(color, 1.0f));
#endif
};
开发者ID:mochidog,项目名称:hifi,代码行数:29,代码来源:RenderableLightEntityItem.cpp

示例8: perfTimer

void RenderableBoxEntityItem::render(RenderArgs* args) {
    PerformanceTimer perfTimer("RenderableBoxEntityItem::render");
    Q_ASSERT(getType() == EntityTypes::Box);
    Q_ASSERT(args->_batch);

    if (!_procedural) {
        _procedural.reset(new Procedural(this->getUserData()));
        _procedural->_vertexSource = simple_vert;
        _procedural->_fragmentSource = simple_frag;
        _procedural->_state->setCullMode(gpu::State::CULL_NONE);
        _procedural->_state->setDepthTest(true, true, gpu::LESS_EQUAL);
        _procedural->_state->setBlendFunction(false,
            gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
            gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
    }

    gpu::Batch& batch = *args->_batch;
    glm::vec4 cubeColor(toGlm(getXColor()), getLocalRenderAlpha());

    if (_procedural->ready()) {
        batch.setModelTransform(getTransformToCenter()); // we want to include the scale as well
        _procedural->prepare(batch, this->getDimensions());
        auto color = _procedural->getColor(cubeColor);
        batch._glColor4f(color.r, color.g, color.b, color.a);
        DependencyManager::get<GeometryCache>()->renderCube(batch);
    } else {
        DependencyManager::get<DeferredLightingEffect>()->renderSolidCubeInstance(batch, getTransformToCenter(), cubeColor);
    }

    RenderableDebugableEntityItem::render(this, args);
};
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:31,代码来源:RenderableBoxEntityItem.cpp

示例9: lock

void RenderablePolyLineEntityItem::render(RenderArgs* args) {
    QWriteLocker lock(&_quadReadWriteLock);
    if (_points.size() < 2 || _normals.size () < 2 || _vertices.size() < 2) {
        return;
    }

    if (!_pipeline) {
        createPipeline();
    }

    PerformanceTimer perfTimer("RenderablePolyLineEntityItem::render");
    Q_ASSERT(getType() == EntityTypes::PolyLine);

    Q_ASSERT(args->_batch);
    if (_pointsChanged) {
        updateGeometry();
    }

    gpu::Batch& batch = *args->_batch;
    Transform transform = Transform();
    transform.setTranslation(getPosition());
    transform.setRotation(getRotation());
    batch.setModelTransform(transform);

    batch.setPipeline(_pipeline);
    batch.setResourceTexture(PAINTSTROKE_GPU_SLOT, _texture);

    batch.setInputFormat(_format);
    batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride);

    batch.draw(gpu::TRIANGLE_STRIP, _numVertices, 0);

    RenderableDebugableEntityItem::render(this, args);
};
开发者ID:AlanZimmerman,项目名称:hifi,代码行数:34,代码来源:RenderablePolyLineEntityItem.cpp

示例10: perfTimer

void PrioVR::update(float deltaTime) {
#ifdef HAVE_PRIOVR
    if (!_skeletalDevice) {
        return;
    }
    PerformanceTimer perfTimer("PrioVR");
    unsigned int timestamp;
    yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(),
        _jointRotations.size() * sizeof(glm::quat), &timestamp);

    // convert to our expected coordinate system, average with last rotations to smooth
    for (int i = 0; i < _jointRotations.size(); i++) {
        _jointRotations[i].y *= -1.0f;
        _jointRotations[i].z *= -1.0f;
        
        glm::quat lastRotation = _lastJointRotations.at(i);
        _lastJointRotations[i] = _jointRotations.at(i);
        _jointRotations[i] = safeMix(lastRotation, _jointRotations.at(i), 0.5f);
    }
    
    // convert the joysticks into palm data
    setPalm(deltaTime, LEFT_HAND_INDEX);
    setPalm(deltaTime, RIGHT_HAND_INDEX);
#endif
}
开发者ID:RyanDowne,项目名称:hifi,代码行数:25,代码来源:PrioVR.cpp

示例11: Q_ASSERT

void RenderableParticleEffectEntityItem::render(RenderArgs* args) {
    Q_ASSERT(getType() == EntityTypes::ParticleEffect);
    PerformanceTimer perfTimer("RenderableParticleEffectEntityItem::render");

    if (_texturesChangedFlag) {
        if (_textures.isEmpty()) {
            _texture.clear();
        } else {
            // for now use the textures string directly.
            // Eventually we'll want multiple textures in a map or array.
            _texture = DependencyManager::get<TextureCache>()->getTexture(_textures);
        }
        _texturesChangedFlag = false;
    }

    bool textured = _texture && _texture->isLoaded();
    updateQuads(args, textured);
    
    Q_ASSERT(args->_batch);
    gpu::Batch& batch = *args->_batch;
    if (textured) {
        batch.setUniformTexture(0, _texture->getGPUTexture());
    }
    batch.setModelTransform(getTransformToCenter());
    DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, textured);
    DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::QUADS, _cacheID);
};
开发者ID:DaveDubUK,项目名称:hifi,代码行数:27,代码来源:RenderableParticleEffectEntityItem.cpp

示例12: warn

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);
}
开发者ID:DaveDubUK,项目名称:hifi,代码行数:31,代码来源:AvatarManager.cpp

示例13: warn

void AvatarManager::updateMyAvatar(float deltaTime) {
    bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
    PerformanceWarning warn(showWarnings, "AvatarManager::updateMyAvatar()");

    AvatarTransit::Status status = _myAvatar->updateTransit(deltaTime, _myAvatar->getNextPosition(), _myAvatar->getSensorToWorldScale(), _transitConfig);
    handleTransitAnimations(status);

    _myAvatar->update(deltaTime);
    render::Transaction transaction;
    _myAvatar->updateRenderItem(transaction);
    qApp->getMain3DScene()->enqueueTransaction(transaction);

    quint64 now = usecTimestampNow();
    quint64 dt = now - _lastSendAvatarDataTime;

    if (dt > MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS && !_myAvatarDataPacketsPaused) {
        // send head/hand data to the avatar mixer and voxel server
        PerformanceTimer perfTimer("send"); 
        _myAvatar->sendAvatarDataPacket();
        _lastSendAvatarDataTime = now;
        _myAvatarSendRate.increment();
    }

    static AvatarCertifyBanner theftBanner;
    if (_myAvatar->isCertifyFailed()) {
        theftBanner.show(_myAvatar->getSessionUUID());
    } else {
        theftBanner.clear();
    }
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:30,代码来源:AvatarManager.cpp

示例14: perfTimer

void PhysicsSimulation::computeCollisions() {
    PerformanceTimer perfTimer("collide");
    _collisions.clear();

    const QVector<Shape*> shapes = _entity->getShapes();
    int numShapes = shapes.size();
    // collide main ragdoll with self
    for (int i = 0; i < numShapes; ++i) {
        const Shape* shape = shapes.at(i);
        if (!shape) {
            continue;
        }
        for (int j = i+1; j < numShapes; ++j) {
            const Shape* otherShape = shapes.at(j);
            if (otherShape && _entity->collisionsAreEnabled(i, j)) {
                ShapeCollider::collideShapes(shape, otherShape, _collisions);
            }
        }
    }

    // collide main ragdoll with others
    int numEntities = _otherEntities.size();
    for (int i = 0; i < numEntities; ++i) {
        const QVector<Shape*> otherShapes = _otherEntities.at(i)->getShapes();
        ShapeCollider::collideShapesWithShapes(shapes, otherShapes, _collisions);
    }
}
开发者ID:noirsoft,项目名称:hifi,代码行数:27,代码来源:PhysicsSimulation.cpp

示例15: perfTimer

void RenderableBoxEntityItem::render(RenderArgs* args) {
    PerformanceTimer perfTimer("RenderableBoxEntityItem::render");
    assert(getType() == EntityTypes::Box);
    glm::vec3 position = getPositionInMeters();
    glm::vec3 center = getCenter() * (float)TREE_SCALE;
    glm::vec3 dimensions = getDimensions() * (float)TREE_SCALE;
    glm::quat rotation = getRotation();

    const float MAX_COLOR = 255.0f;

    glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR, 
                    getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());

    glPushMatrix();
        glTranslatef(position.x, position.y, position.z);
        glm::vec3 axis = glm::axis(rotation);
        glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
        glPushMatrix();
            glm::vec3 positionToCenter = center - position;
            glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
            glScalef(dimensions.x, dimensions.y, dimensions.z);
            DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
        glPopMatrix();
    glPopMatrix();

};
开发者ID:ey6es,项目名称:hifi,代码行数:26,代码来源:RenderableBoxEntityItem.cpp


注:本文中的perfTimer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。