summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-01-08 16:34:43 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-01-08 16:34:43 +0000
commit8cd0977a3688fa705c83867c57505a47b9269369 (patch)
treeb7b48711051299607077ed31fdf3b3f6dd6cc41f /gfx/gl/camera.cpp
parentTidy shadow map creation (diff)
downloadilt-8cd0977a3688fa705c83867c57505a47b9269369.tar.bz2
ilt-8cd0977a3688fa705c83867c57505a47b9269369.tar.xz
ilt-8cd0977a3688fa705c83867c57505a47b9269369.zip
Fix up all the static analyzer warnings
Diffstat (limited to 'gfx/gl/camera.cpp')
-rw-r--r--gfx/gl/camera.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp
index 2ea326d..b596c43 100644
--- a/gfx/gl/camera.cpp
+++ b/gfx/gl/camera.cpp
@@ -7,9 +7,10 @@
Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar) :
position {pos}, forward {::north}, up {::up}, fov {fov}, aspect {aspect}, near {zNear}, far {zFar},
- projection {glm::perspective(fov, aspect, zNear, zFar)}
+ projection {glm::perspective(fov, aspect, zNear, zFar)},
+ viewProjection {projection * glm::lookAt(position, position + forward, up)}, inverseViewProjection {
+ glm::inverse(viewProjection)}
{
- updateView();
}
Ray
@@ -38,9 +39,9 @@ std::array<glm::vec4, 4>
Camera::extentsAtDist(const float dist) const
{
const auto clampToSeaFloor = [this, dist](const glm::vec3 & target) {
- if (target.z < -1.5f) {
+ if (target.z < -1.5F) {
const auto vec = glm::normalize(target - position);
- constexpr glm::vec3 seafloor {0, 0, -1.5};
+ constexpr glm::vec3 seafloor {0, 0, -1.5F};
float outdist;
if (glm::intersectRayPlane(position, vec, seafloor, ::up, outdist)) {
return (vec * outdist + position) ^ outdist;
@@ -48,11 +49,11 @@ Camera::extentsAtDist(const float dist) const
}
return target ^ dist;
};
- const auto depth = -(2.f * (dist - near) * far) / (dist * (near - far)) - 1.f;
+ const auto depth = -(2.F * (dist - near) * far) / (dist * (near - far)) - 1.F;
static constexpr const std::array extents {-1.F, 1.F};
static constexpr const auto cartesianExtents = extents * extents;
return cartesianExtents * [&depth, this, &clampToSeaFloor](const auto & extent) {
- const glm::vec4 in {extent.first, extent.second, depth, 1.f};
+ const glm::vec4 in {extent.first, extent.second, depth, 1.F};
return clampToSeaFloor(perspective_divide(inverseViewProjection * in));
};
}