From 75c88681ee470ffb1f54a23df68602b97c7cf6b0 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sat, 15 Nov 2014 14:26:17 +0100 Subject: [PATCH] Adding updateDistance to camera. --- camera.cc | 12 ++++++++++++ camera.hh | 1 + 2 files changed, 13 insertions(+) diff --git a/camera.cc b/camera.cc index 08ea557..62736ba 100644 --- a/camera.cc +++ b/camera.cc @@ -42,3 +42,15 @@ void Camera::updateRotation(glm::vec2 rotation) { this-> rotation += rotation; } } + +void Camera:: updateDistance(float distance) { + if (this->distance + distance <= 1.0f) { + this->distance = 1.0f; + } + else if (this->distance + distance >= 100.0f) { + this->distance = 100.f; + } + else { + this->distance += distance; + } +} diff --git a/camera.hh b/camera.hh index 7391fa3..ee21e98 100644 --- a/camera.hh +++ b/camera.hh @@ -10,6 +10,7 @@ class Camera { ~Camera(); float getDistance(); void setDistance(float distance); + void updateDistance(float distance); //adds to current distance glm::vec2 getRotation(); void setRotation(glm::vec2 rotation); void updateRotation(glm::vec2 rotation); //adds to current rotation