overte-HifiExperiments/libraries/render-utils/src/AbstractViewStateInterface.h
Anthony J. Thibault 115fd607a0 Address performance issues introduced with this PR.
* Prevent clusterMatrices from being invalidated and re-computed in each updateItem lambda.
  We do this by not setting _model->_needsUpdateClusterMatrices = true;
* Prevent redundant work if Model::enqueueLocationChange is called multiple times per frame.
  We do this by introducing a preRenderLambdas map in the Application class.
  Instead of adding work directly to the scene PendingChanges queue Model::enqueueLocationChange
  adds a lambda to the Application preRenderLambdas map.  The Application ensures that only one lambda will
  be invoked for each model per frame.
2016-03-28 19:47:30 -07:00

57 lines
1.7 KiB
C++

//
// AbstractViewStateInterface.h
// interface/src/renderer
//
// Created by Brad Hefta-Gaub on 12/16/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_AbstractViewStateInterface_h
#define hifi_AbstractViewStateInterface_h
#include <glm/glm.hpp>
#include <functional>
#include <render/Scene.h>
#include <render/Engine.h>
#include <QtGlobal>
class Transform;
class QThread;
class ViewFrustum;
class PickRay;
/// Interface provided by Application to other objects that need access to the current view state details
class AbstractViewStateInterface {
public:
/// gets the current view frustum for rendering the view state
virtual ViewFrustum* getCurrentViewFrustum() = 0;
/// gets the shadow view frustum for rendering the view state
virtual ViewFrustum* getShadowViewFrustum() = 0;
virtual QThread* getMainThread() = 0;
virtual PickRay computePickRay(float x, float y) const = 0;
virtual glm::vec3 getAvatarPosition() const = 0;
virtual void postLambdaEvent(std::function<void()> f) = 0;
virtual qreal getDevicePixelRatio() = 0;
virtual render::ScenePointer getMain3DScene() = 0;
virtual render::EnginePointer getRenderEngine() = 0;
virtual void pushPreRenderLambda(void* key, std::function<void()> func) = 0;
// FIXME - we shouldn't assume that there's a single instance of an AbstractViewStateInterface
static AbstractViewStateInterface* instance();
static void setInstance(AbstractViewStateInterface* instance);
};
#endif // hifi_AbstractViewStateInterface_h