From 83dcdc8a20eec282ed030bd9260330c0f6e1dcfa Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Fri, 18 Apr 2014 18:53:07 +0200 Subject: [PATCH 01/13] minor adjustemts to stereovieweye --- src/display/stereovieweye.cpp | 9 ++++----- src/display/stereovieweye.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/display/stereovieweye.cpp b/src/display/stereovieweye.cpp index 21eb2700..c6fde02e 100644 --- a/src/display/stereovieweye.cpp +++ b/src/display/stereovieweye.cpp @@ -20,7 +20,7 @@ StereoViewEye::StereoViewEye(const glm::ivec2& viewportResolution, const StereoR m_camera(new Camera(viewportResolution.x, viewportResolution.y)), m_distortionScale(stereoRenderInfo.distortionScale()), m_fbo(new FrameBuffer()), - m_antialiasing("vfx.antialiasing") + m_antialiasing("vfx.antialiasing") { setViewportResolution(viewportResolution); @@ -35,18 +35,16 @@ StereoViewEye::StereoViewEye(const glm::ivec2& viewportResolution, const StereoR } } +StereoViewEye::~StereoViewEye() = default; + const Camera& StereoViewEye::camera() const { return *m_camera; } -StereoViewEye::~StereoViewEye() = default; - FrameBuffer& StereoViewEye::fbo() { return *m_fbo; } - - void StereoViewEye::draw(const Scene& scene, const CameraHead& cameraHead) { int samplingFactor = 1; if (m_antialiasing.get() == Antialiasing::SSAA) { @@ -76,3 +74,4 @@ void StereoViewEye::setViewportResolution(const glm::ivec2& viewportResolution) m_fbo->setResolution(m_textureSize); } + diff --git a/src/display/stereovieweye.h b/src/display/stereovieweye.h index cb209f3f..e3f0096b 100644 --- a/src/display/stereovieweye.h +++ b/src/display/stereovieweye.h @@ -8,6 +8,7 @@ #include "eyeside.h" #include "property/property.h" + namespace glow { class FrameBufferObject; } From 9f80b374983c09a807b876f64bc500b6d1e87ac4 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sat, 19 Apr 2014 00:41:35 +0200 Subject: [PATCH 02/13] switch to glowutils::Camera --- src/camera/camera.cpp | 150 ++-------------------------- src/camera/camera.h | 65 ++---------- src/display/monoview.cpp | 2 +- src/display/rendering/skybox.cpp | 2 +- src/display/rendering/starfield.cpp | 4 +- src/display/stereovieweye.cpp | 2 +- src/utils/inertiafollower.h | 1 - 7 files changed, 27 insertions(+), 199 deletions(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index c60ac19a..8f67d4d8 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -1,153 +1,25 @@ #include "camera.h" - #include -Camera::Camera(int viewportWidth, int viewportHeight): - m_fovy(glm::radians(60.f)), - m_aspect(1.f), - m_zNear(1), - m_zFar(9999) +Camera::Camera(int viewportWidth, int viewportHeight) { - setViewport(glm::ivec2(viewportWidth, viewportHeight)); -} - -Camera::~Camera(){ - -} - -void Camera::viewDirty() { - m_view = glm::mat4_cast(glm::inverse(m_orientation)) * glm::translate(-m_position); - m_viewProjection = m_projection * m_view; -} - -void Camera::projectionDirty() { - m_projection = glm::perspective(m_fovy, m_aspect, m_zNear, m_zFar); - m_projection = glm::translate(m_projectionOffset) * m_projection; - m_viewProjection = m_projection * m_view; -} - -void Camera::move(glm::vec3 dist){ - Transform::move(dist); - viewDirty(); -} - -void Camera::setPosition(glm::vec3 pos){ - Transform::setPosition(pos); - viewDirty(); -} - -void Camera::rotateX(float rot){ - Transform::rotate(glm::angleAxis(rot, glm::vec3(1,0,0))); - viewDirty(); -} - -void Camera::rotateY(float rot){ - Transform::rotate(glm::angleAxis(rot, glm::vec3(0, 1, 0))); - viewDirty(); -} - -void Camera::rotateZ(float rot){ - Transform::rotate(glm::angleAxis(rot, glm::vec3(0, 0, -1))); - viewDirty(); -} - -void Camera::setOrientation(glm::quat quat){ - Transform::setOrientation(quat); - viewDirty(); -} - -const glm::mat4& Camera::view() const{ - return m_view; -} - -const glm::mat4& Camera::viewInverted() const { - return glm::inverse(m_view); -} - -const glm::quat& Camera::orientation() const { - return Transform::orientation(); -} - -const glm::vec3& Camera::position() const { - return m_position; -} - -float Camera::zNear() const { - return m_zNear; -} - -void Camera::setZNear(const float zNear) { - if (zNear == m_zNear) { - return; - } - - m_zNear = zNear; - assert(m_zNear > 0.0); - - projectionDirty(); -} - -float Camera::zFar() const { - return m_zFar; -} - -void Camera::setZFar(const float zFar) { - if (zFar == m_zFar) { - return; - } - - m_zFar = zFar; - assert(m_zFar > m_zNear); - projectionDirty(); -} - -float Camera::fovy() const { - return m_fovy; -} + setViewport(viewportWidth, viewportHeight); -void Camera::setFovy(const float fovy) { - if (fovy == m_fovy) { - return; - } + setFovy(glm::radians(60.0f)); - m_fovy = fovy; - assert(m_fovy > 0.0); - projectionDirty(); + setZNear(1.0f); + setZFar(10000.0f); } -const glm::ivec2 Camera::viewport() const { - return m_viewport; +glm::quat Camera::orientation() const { + return m_orientation; } -void Camera::setViewport(const glm::ivec2& viewport) { - if (viewport == m_viewport) { - return; - } - - m_aspect = viewport.x / glm::max(static_cast(viewport.y), 1.f); - m_viewport = viewport; - projectionDirty(); +void Camera::setOrientation(const glm::quat& orientation) { + setUp(orientation * glm::vec3(0, 1, 0)); + setCenter(eye() + orientation * glm::vec3(0, 0, -1)); + m_orientation = orientation; } -const glm::vec3& Camera::projectionOffset() const { - return m_projectionOffset; -} - -void Camera::setProjectionOffset(const glm::vec3& projectionOffset) { - m_projectionOffset = projectionOffset; - projectionDirty(); -} - -float Camera::aspectRatio() const { - return m_aspect; -} - -const glm::mat4& Camera::projection() const { - return m_projection; -} - -const glm::mat4& Camera::viewProjection() const { - return m_viewProjection; -} diff --git a/src/camera/camera.h b/src/camera/camera.h index 637c9d65..dd7b6dde 100644 --- a/src/camera/camera.h +++ b/src/camera/camera.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include "geometry/transform.h" @@ -7,66 +9,21 @@ /** * Represents the camera. matrix thus is the view matrix for all other objects */ -class Camera : protected Transform { //protected so we don't have matrix, because we want view +class Camera : public glowutils::Camera { public: Camera(int viewportWidth, int viewportHeight); - virtual ~Camera(); - - /* Overwrite WorldObject functions for performance: - * WorldObject recalculates the matrix on every read access, - * Camera should recalculate on every write access, as reads are more common */ - - void move(glm::vec3 dist); - void setPosition(glm::vec3 pos); - - void rotateX(float rot); - void rotateY(float rot); - void rotateZ(float rot); - void setOrientation(glm::quat quat); - - const glm::mat4& view() const; - const glm::mat4& viewInverted() const; - const glm::quat& orientation() const; - const glm::vec3& position() const; - - /* Projection from glow::Camera */ - - float zNear() const; - void setZNear(float zNear); - float zFar() const; - void setZFar(float zFar); - - float fovy() const; - void setFovy(float fovy); - const glm::ivec2 viewport() const; - void setViewport(const glm::ivec2 & viewport); + /** + * Can't be set, orientation()/setOrientation() does their job. + */ + void setEye(const glm::vec3 & eye) = delete; + void setUp(const glm::vec3 & up) = delete; - const glm::vec3& projectionOffset() const; - void setProjectionOffset(const glm::vec3& projectionOffset); - - float aspectRatio() const; - - const glm::mat4& projection() const; - - const glm::mat4& viewProjection() const; + glm::quat orientation() const; + void setOrientation(const glm::quat& orientation); protected: - void viewDirty(); - void projectionDirty(); - - float m_fovy; - float m_aspect; - float m_zNear; - float m_zFar; - - glm::ivec2 m_viewport; - - glm::vec3 m_projectionOffset; - - glm::mat4 m_view; - glm::mat4 m_projection; - glm::mat4 m_viewProjection; + glm::quat m_orientation; }; diff --git a/src/display/monoview.cpp b/src/display/monoview.cpp index 0594341d..8a40fe41 100644 --- a/src/display/monoview.cpp +++ b/src/display/monoview.cpp @@ -52,7 +52,7 @@ void MonoView::draw(const Scene& scene, const CameraHead& cameraHead) { glViewport(m_viewport.x(), m_viewport.y(), sampleWidth, sampleHeight); m_camera->setViewport(glm::ivec2(sampleWidth, sampleHeight)); - m_camera->setPosition(cameraHead.position()); + m_camera->setEye(cameraHead.position()); m_camera->setOrientation(cameraHead.orientation()); scene.draw(*m_camera, glow::FrameBufferObject::defaultFBO(), m_viewport); diff --git a/src/display/rendering/skybox.cpp b/src/display/rendering/skybox.cpp index b4a93dc0..2f3b528a 100644 --- a/src/display/rendering/skybox.cpp +++ b/src/display/rendering/skybox.cpp @@ -55,7 +55,7 @@ void Skybox::initialize() { glm::vec3(-1, -1, 0), glm::vec3(1, -1, 0), glm::vec3(1, 1, 0), - glm::vec3(-1, 1, 0) + glm::vec3(-1, 1, 0) }; m_vertexArrayObject = new glow::VertexArrayObject(); diff --git a/src/display/rendering/starfield.cpp b/src/display/rendering/starfield.cpp index 3669f7d8..3fecc182 100644 --- a/src/display/rendering/starfield.cpp +++ b/src/display/rendering/starfield.cpp @@ -143,7 +143,7 @@ void Starfield::createBinding(int index, std::string name, int offset, int size) } void Starfield::addLocation(const Camera& camera, int side) { - CameraLocation location = CameraLocation{ m_time, camera.position(), camera.orientation() }; + CameraLocation location = CameraLocation{ m_time, camera.eye(), camera.orientation() }; m_locations[side].push_back(location); } @@ -172,7 +172,7 @@ glm::mat4 Starfield::getMatrixFromPast(const Camera& camera, int side) { assert(interpolation >= 0 && interpolation <= 1); Camera c(camera); - c.setPosition(glm::mix(after.position, before.position, interpolation)); + c.setEye(glm::mix(after.position, before.position, interpolation)); c.setOrientation(glm::slerp(after.orientation, before.orientation, interpolation)); return c.viewProjection(); diff --git a/src/display/stereovieweye.cpp b/src/display/stereovieweye.cpp index c6fde02e..5a36008a 100644 --- a/src/display/stereovieweye.cpp +++ b/src/display/stereovieweye.cpp @@ -54,7 +54,7 @@ void StereoViewEye::draw(const Scene& scene, const CameraHead& cameraHead) { int sampleHeight = static_cast(m_textureSize.y * samplingFactor); m_camera->setViewport(glm::ivec2(sampleWidth, sampleHeight)); - m_camera->setPosition(cameraHead.position() + cameraHead.orientation() * m_offset); + m_camera->setEye(cameraHead.position() + cameraHead.orientation() * m_offset); m_camera->setOrientation(cameraHead.orientation()); m_fbo->bind(); diff --git a/src/utils/inertiafollower.h b/src/utils/inertiafollower.h index 211b3905..c9819560 100644 --- a/src/utils/inertiafollower.h +++ b/src/utils/inertiafollower.h @@ -7,7 +7,6 @@ * Follows a position and orientation with a given inertia between * 0 = instant follow and 100 = never moves */ - class InertiaFollower { public: InertiaFollower(float directionalInertia, float angularInertia); From b96064539aae64acd5c2ce46c99f02ad91828e28 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sat, 19 Apr 2014 00:58:50 +0200 Subject: [PATCH 03/13] fixed stereo mode. we'll just propagate the view, they said.... --- lib/glow | 2 +- src/camera/camera.cpp | 4 ++-- src/camera/camera.h | 2 +- src/display/stereoview.cpp | 3 +++ src/main.cpp | 1 + src/ui/hud/hud.cpp | 5 ++++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/glow b/lib/glow index 7581ec99..23c94838 160000 --- a/lib/glow +++ b/lib/glow @@ -1 +1 @@ -Subproject commit 7581ec99b718e481fcdb7af122ce6b5b34a1868f +Subproject commit 23c948380c10cbf740e930a89f40338cc2291b8f diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index 8f67d4d8..cc874c0e 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -18,8 +18,8 @@ glm::quat Camera::orientation() const { } void Camera::setOrientation(const glm::quat& orientation) { - setUp(orientation * glm::vec3(0, 1, 0)); - setCenter(eye() + orientation * glm::vec3(0, 0, -1)); + glowutils::Camera::setUp(orientation * glm::vec3(0, 1, 0)); + glowutils::Camera::setCenter(eye() + orientation * glm::vec3(0, 0, -1)); m_orientation = orientation; } diff --git a/src/camera/camera.h b/src/camera/camera.h index dd7b6dde..72852787 100644 --- a/src/camera/camera.h +++ b/src/camera/camera.h @@ -16,7 +16,7 @@ class Camera : public glowutils::Camera { /** * Can't be set, orientation()/setOrientation() does their job. */ - void setEye(const glm::vec3 & eye) = delete; + void setCenter(const glm::vec3 & center) = delete; void setUp(const glm::vec3 & up) = delete; glm::quat orientation() const; diff --git a/src/display/stereoview.cpp b/src/display/stereoview.cpp index 54adf6a0..1715369a 100644 --- a/src/display/stereoview.cpp +++ b/src/display/stereoview.cpp @@ -2,6 +2,8 @@ #include +#include + #include "camera/camera.h" #include "camera/camerahead.h" @@ -24,6 +26,7 @@ StereoView::StereoView(const Viewport& viewport, const StereoRenderInfo& stereoR m_stereoBlitProgram(nullptr) { initialize(); + glow::info() << "StereoView: " << this; } void StereoView::initialize() { diff --git a/src/main.cpp b/src/main.cpp index 1dd069a3..0c8df30b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -243,6 +243,7 @@ int main(int argc, char* argv[]) { game->viewer().switchToStereoView(StereoRenderInfo::dummy()); } } + game->gamePlay().updateView(); delete loadingScreen; delete initTimer; diff --git a/src/ui/hud/hud.cpp b/src/ui/hud/hud.cpp index 8aaea0c1..9040220d 100644 --- a/src/ui/hud/hud.cpp +++ b/src/ui/hud/hud.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include "camera/camerahead.h" @@ -63,6 +64,8 @@ HUD::HUD(Player* player): m_elements->addHudget(m_aimHelper); m_elements->addHudget(m_crossHair); + + glow::info() << "Created HUD" << this; } HUD::~HUD() = default; @@ -254,7 +257,7 @@ void HUD::updateFov() { m_fovx = glm::atan(glm::tan(m_fovy) * m_view->aspectRatio()); } -void HUD::setView(const View* view) { +void HUD::setView(const View* view) { glow::debug() << "Set View " << view; m_view = view; } From fdb1ed81baa2a8050e2a78840336301ea81aaff4 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Tue, 22 Apr 2014 23:16:21 +0200 Subject: [PATCH 04/13] intermediate --- src/camera/camera.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index cc874c0e..b43086ff 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -1,5 +1,10 @@ #include "camera.h" +#include + +#include +#include + #include @@ -14,7 +19,12 @@ Camera::Camera(int viewportWidth, int viewportHeight) } glm::quat Camera::orientation() const { - return m_orientation; + glm::quat q = glm::quat(glm::lookAt(center(), (eye()), up())); + + glm::vec3 e = glm::eulerAngles(q); + glow::debug() << e << " vs " << glm::eulerAngles(m_orientation); + + return q; } void Camera::setOrientation(const glm::quat& orientation) { From 5d0fe9b1d945fb98d53a6fd6469476f10799f92b Mon Sep 17 00:00:00 2001 From: Moritz Eyssen Date: Wed, 23 Apr 2014 19:02:09 +0200 Subject: [PATCH 05/13] retrieve quaternion from view-matrix --- src/camera/camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index cc874c0e..4bba3bc7 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -14,7 +14,7 @@ Camera::Camera(int viewportWidth, int viewportHeight) } glm::quat Camera::orientation() const { - return m_orientation; + return glm::quat_cast(glm::inverse(view())); } void Camera::setOrientation(const glm::quat& orientation) { From b7f99b3a0fa5b42b7aff91732290ec65f1eb5453 Mon Sep 17 00:00:00 2001 From: Moritz Eyssen Date: Wed, 23 Apr 2014 19:02:18 +0200 Subject: [PATCH 06/13] retrieve quaternion from view-matrix --- src/camera/camera.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/camera/camera.h b/src/camera/camera.h index 72852787..31f5d7c3 100644 --- a/src/camera/camera.h +++ b/src/camera/camera.h @@ -13,12 +13,6 @@ class Camera : public glowutils::Camera { public: Camera(int viewportWidth, int viewportHeight); - /** - * Can't be set, orientation()/setOrientation() does their job. - */ - void setCenter(const glm::vec3 & center) = delete; - void setUp(const glm::vec3 & up) = delete; - glm::quat orientation() const; void setOrientation(const glm::quat& orientation); From 1d762b15590d5cdf366c8b75a80d350deeb74e70 Mon Sep 17 00:00:00 2001 From: Moritz Eyssen Date: Wed, 23 Apr 2014 19:03:09 +0200 Subject: [PATCH 07/13] minor adjustments --- src/camera/camera.cpp | 4 +--- src/camera/camera.h | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index 4bba3bc7..cf87fb59 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -3,8 +3,7 @@ #include -Camera::Camera(int viewportWidth, int viewportHeight) -{ +Camera::Camera(int viewportWidth, int viewportHeight) { setViewport(viewportWidth, viewportHeight); setFovy(glm::radians(60.0f)); @@ -20,6 +19,5 @@ glm::quat Camera::orientation() const { void Camera::setOrientation(const glm::quat& orientation) { glowutils::Camera::setUp(orientation * glm::vec3(0, 1, 0)); glowutils::Camera::setCenter(eye() + orientation * glm::vec3(0, 0, -1)); - m_orientation = orientation; } diff --git a/src/camera/camera.h b/src/camera/camera.h index 31f5d7c3..cd0703a8 100644 --- a/src/camera/camera.h +++ b/src/camera/camera.h @@ -15,9 +15,5 @@ class Camera : public glowutils::Camera { glm::quat orientation() const; void setOrientation(const glm::quat& orientation); - - -protected: - glm::quat m_orientation; }; From a30cd3b80d7cfb1da8040475a157b8cdf43badb2 Mon Sep 17 00:00:00 2001 From: Moritz Eyssen Date: Wed, 23 Apr 2014 19:04:48 +0200 Subject: [PATCH 08/13] removed logging --- src/display/stereoview.cpp | 3 --- src/ui/hud/hud.cpp | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/display/stereoview.cpp b/src/display/stereoview.cpp index 1715369a..54adf6a0 100644 --- a/src/display/stereoview.cpp +++ b/src/display/stereoview.cpp @@ -2,8 +2,6 @@ #include -#include - #include "camera/camera.h" #include "camera/camerahead.h" @@ -26,7 +24,6 @@ StereoView::StereoView(const Viewport& viewport, const StereoRenderInfo& stereoR m_stereoBlitProgram(nullptr) { initialize(); - glow::info() << "StereoView: " << this; } void StereoView::initialize() { diff --git a/src/ui/hud/hud.cpp b/src/ui/hud/hud.cpp index 3cb7cb28..3151a256 100644 --- a/src/ui/hud/hud.cpp +++ b/src/ui/hud/hud.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include "camera/camerahead.h" @@ -275,7 +274,7 @@ void HUD::updateFov() { m_fovx = glm::atan(glm::tan(m_fovy) * m_view->aspectRatio()); } -void HUD::setView(const View* view) { glow::debug() << "Set View " << view; +void HUD::setView(const View* view) { m_view = view; } From 9dde8201d25dacdbf81e256ff46d5b73d5ae4ea8 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Wed, 23 Apr 2014 19:07:28 +0200 Subject: [PATCH 09/13] removed more logging --- src/ui/hud/hud.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ui/hud/hud.cpp b/src/ui/hud/hud.cpp index 3151a256..a4ee1368 100644 --- a/src/ui/hud/hud.cpp +++ b/src/ui/hud/hud.cpp @@ -63,8 +63,6 @@ HUD::HUD(Player* player): m_elements->addHudget(m_aimHelper); m_elements->addHudget(m_crossHair); - - glow::info() << "Created HUD" << this; } HUD::~HUD() = default; From 1d32dd55b0ec5a17c138039e07c03a379de7fa05 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sun, 27 Apr 2014 20:32:40 +0200 Subject: [PATCH 10/13] make Camera::orientation() lazy recalc --- src/camera/camera.cpp | 26 +++++++++++++++----------- src/camera/camera.h | 11 ++++++++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index 4e491eed..1542751c 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -8,7 +8,9 @@ #include -Camera::Camera(int viewportWidth, int viewportHeight) { +Camera::Camera(int viewportWidth, int viewportHeight): + m_orientationDirty(true) +{ setViewport(viewportWidth, viewportHeight); setFovy(glm::radians(60.0f)); @@ -18,20 +20,22 @@ Camera::Camera(int viewportWidth, int viewportHeight) { } glm::quat Camera::orientation() const { -<<<<<<< HEAD - glm::quat q = glm::quat(glm::lookAt(center(), (eye()), up())); - - glm::vec3 e = glm::eulerAngles(q); - glow::debug() << e << " vs " << glm::eulerAngles(m_orientation); - - return q; -======= - return glm::quat_cast(glm::inverse(view())); ->>>>>>> 9dde8201d25dacdbf81e256ff46d5b73d5ae4ea8 + if (m_orientationDirty) { + m_orientation = glm::quat_cast(glm::inverse(view())); + m_orientationDirty = false; + } + return m_orientation; } void Camera::setOrientation(const glm::quat& orientation) { glowutils::Camera::setUp(orientation * glm::vec3(0, 1, 0)); glowutils::Camera::setCenter(eye() + orientation * glm::vec3(0, 0, -1)); + + // changed() will be called anyway, no need to set m_orientationDirty = true +} + +void Camera::changed() const { + glowutils::Camera::changed(); + m_orientationDirty = true; } diff --git a/src/camera/camera.h b/src/camera/camera.h index cd0703a8..bccee15f 100644 --- a/src/camera/camera.h +++ b/src/camera/camera.h @@ -6,14 +6,19 @@ #include "geometry/transform.h" -/** - * Represents the camera. matrix thus is the view matrix for all other objects - */ + class Camera : public glowutils::Camera { public: Camera(int viewportWidth, int viewportHeight); glm::quat orientation() const; void setOrientation(const glm::quat& orientation); + + void changed() const override; + + +protected: + mutable bool m_orientationDirty; + glm::quat m_orientation; }; From ff940343ad1500d93a8606100923b3bffdbe66b9 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sun, 27 Apr 2014 20:43:37 +0200 Subject: [PATCH 11/13] update glow --- lib/glow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/glow b/lib/glow index 7581ec99..23c94838 160000 --- a/lib/glow +++ b/lib/glow @@ -1 +1 @@ -Subproject commit 7581ec99b718e481fcdb7af122ce6b5b34a1868f +Subproject commit 23c948380c10cbf740e930a89f40338cc2291b8f From b9e6b28d55aa804fdb41e8b9be843132abcd02d9 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sun, 27 Apr 2014 20:57:21 +0200 Subject: [PATCH 12/13] const cast in Camera::orientation() to conform with qualifiers --- src/camera/camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index 1542751c..65e0971b 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -21,7 +21,7 @@ Camera::Camera(int viewportWidth, int viewportHeight): glm::quat Camera::orientation() const { if (m_orientationDirty) { - m_orientation = glm::quat_cast(glm::inverse(view())); + const_cast(m_orientation) = glm::quat_cast(glm::inverse(view())); m_orientationDirty = false; } return m_orientation; From 2c16c451d7d9eb7772a8a4b4bf28b39636c33854 Mon Sep 17 00:00:00 2001 From: mrzzzrm Date: Sun, 27 Apr 2014 20:58:58 +0200 Subject: [PATCH 13/13] update glow --- lib/glow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/glow b/lib/glow index 23c94838..c3615879 160000 --- a/lib/glow +++ b/lib/glow @@ -1 +1 @@ -Subproject commit 23c948380c10cbf740e930a89f40338cc2291b8f +Subproject commit c3615879af0f317d2b8ec8b3ae2474a233c3c965