getViewFrustum() provides const pointer

This commit is contained in:
Andrew Meadows 2016-02-29 14:58:38 -08:00
parent 16a5030159
commit 60a72c6660
10 changed files with 12 additions and 23 deletions

View file

@ -1512,6 +1512,7 @@ void Application::paintGL() {
auto lodManager = DependencyManager::get<LODManager>();
_viewFrustum.calculate();
RenderArgs renderArgs(_gpuContext, getEntities(), getViewFrustum(), lodManager->getOctreeSizeScale(),
lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
@ -3874,16 +3875,6 @@ glm::vec3 Application::getAvatarPosition() const {
return getMyAvatar()->getPosition();
}
ViewFrustum* Application::getViewFrustum() {
#ifdef DEBUG
if (QThread::currentThread() == activeRenderingThread) {
// FIXME, figure out a better way to do this
//qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
}
#endif
return &_viewFrustum;
}
const ViewFrustum* Application::getViewFrustum() const {
#ifdef DEBUG
if (QThread::currentThread() == activeRenderingThread) {

View file

@ -128,7 +128,6 @@ public:
Camera* getCamera() { return &_myCamera; }
const Camera* getCamera() const { return &_myCamera; }
// Represents the current view frustum of the avatar.
ViewFrustum* getViewFrustum();
const ViewFrustum* getViewFrustum() const;
// Represents the view frustum of the current rendering pass,
// which might be different from the viewFrustum, i.e. shadowmap

View file

@ -51,8 +51,8 @@ public:
/// render the content of the octree
virtual void render(RenderArgs* renderArgs);
ViewFrustum* getViewFrustum() const { return _viewFrustum; }
void setViewFrustum(ViewFrustum* viewFrustum) { _viewFrustum = viewFrustum; }
const ViewFrustum* getViewFrustum() const { return _viewFrustum; }
void setViewFrustum(const ViewFrustum* viewFrustum) { _viewFrustum = viewFrustum; }
static bool renderOperation(OctreeElementPointer element, void* extraData);
@ -75,7 +75,7 @@ protected:
OctreePointer _tree;
bool _managedTree;
ViewFrustum* _viewFrustum;
const ViewFrustum* _viewFrustum;
SimpleMovingAverage _elementsPerPacket;
SimpleMovingAverage _entitiesPerPacket;

View file

@ -630,7 +630,7 @@ void ViewFrustum::getFurthestPointFromCamera(const AACube& box, glm::vec3& furth
}
}
const ViewFrustum::Corners ViewFrustum::getCorners(const float& depth) {
const ViewFrustum::Corners ViewFrustum::getCorners(const float& depth) const {
glm::vec3 normal = glm::normalize(_direction);
auto getCorner = [&](enum::BoxVertex nearCorner, enum::BoxVertex farCorner) {

View file

@ -74,7 +74,7 @@ public:
glm::vec3 bottomRight;
// Get the corners depth units from frustum position, along frustum orientation
};
const Corners getCorners(const float& depth);
const Corners getCorners(const float& depth) const;
// getters for corners
const glm::vec3& getFarTopLeft() const { return _cornersWorld[TOP_LEFT_FAR]; }

View file

@ -20,7 +20,7 @@ LightStage::Shadow::Shadow(model::LightPointer light) : _light{ light}, _frustum
_schemaBuffer = std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema);
}
void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth) {
void LightStage::Shadow::setKeylightFrustum(const ViewFrustum* viewFrustum, float nearDepth, float farDepth) {
assert(nearDepth < farDepth);
// Orient the keylight frustum
@ -43,7 +43,6 @@ void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float near
const Transform view{ _frustum->getView()};
const Transform viewInverse{ view.getInverseMatrix() };
viewFrustum->calculate();
auto nearCorners = viewFrustum->getCorners(nearDepth);
auto farCorners = viewFrustum->getCorners(farDepth);

View file

@ -28,7 +28,7 @@ public:
Shadow(model::LightPointer light);
void setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth);
void setKeylightFrustum(const ViewFrustum* viewFrustum, float nearDepth, float farDepth);
const std::shared_ptr<ViewFrustum> getFrustum() const { return _frustum; }

View file

@ -146,7 +146,7 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render
}
// Cache old render args
ViewFrustum* viewFrustum = args->_viewFrustum;
const ViewFrustum* viewFrustum = args->_viewFrustum;
RenderArgs::RenderMode mode = args->_renderMode;
auto nearClip = viewFrustum->getNearClip();

View file

@ -26,7 +26,7 @@ void render::cullItems(const RenderContextPointer& renderContext, const CullFunc
assert(renderContext->args->_viewFrustum);
RenderArgs* args = renderContext->args;
ViewFrustum* frustum = args->_viewFrustum;
const ViewFrustum* frustum = args->_viewFrustum;
details._considered += (int)inItems.size();

View file

@ -77,7 +77,7 @@ public:
RenderArgs(std::shared_ptr<gpu::Context> context = nullptr,
OctreeRenderer* renderer = nullptr,
ViewFrustum* viewFrustum = nullptr,
const ViewFrustum* viewFrustum = nullptr,
float sizeScale = 1.0f,
int boundaryLevelAdjust = 0,
RenderMode renderMode = DEFAULT_RENDER_MODE,
@ -99,7 +99,7 @@ public:
std::shared_ptr<gpu::Framebuffer> _blitFramebuffer = nullptr;
std::shared_ptr<render::ShapePipeline> _pipeline = nullptr;
OctreeRenderer* _renderer = nullptr;
ViewFrustum* _viewFrustum = nullptr;
const ViewFrustum* _viewFrustum = nullptr;
glm::ivec4 _viewport{ 0.0f, 0.0f, 1.0f, 1.0f };
glm::vec3 _boomOffset{ 0.0f, 0.0f, 1.0f };
float _sizeScale = 1.0f;