Small refactoring into class Camera
This commit is contained in:
parent
dced3ce783
commit
83e8cfa206
1 changed files with 9 additions and 16 deletions
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
#if !ENABLE_6DOF_CAMERA
|
||||||
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
||||||
|
#endif // !ENABLE_6DOF_CAMERA
|
||||||
|
|
||||||
// phi / theta angles to orient the camera.
|
// phi / theta angles to orient the camera.
|
||||||
static const float VIEW_DEFAULT[2] = { 45.0f, 45.0f };
|
static const float VIEW_DEFAULT[2] = { 45.0f, 45.0f };
|
||||||
|
@ -66,13 +68,10 @@ std::string Camera::get_type_as_string() const
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case Unknown:
|
case Unknown: return "unknown";
|
||||||
return "unknown";
|
case Perspective: return "perspective";
|
||||||
case Perspective:
|
|
||||||
return "perspective";
|
|
||||||
default:
|
default:
|
||||||
case Ortho:
|
case Ortho: return "orthographic";
|
||||||
return "orthographic";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +87,7 @@ void Camera::set_type(EType type)
|
||||||
|
|
||||||
void Camera::set_type(const std::string& type)
|
void Camera::set_type(const std::string& type)
|
||||||
{
|
{
|
||||||
if (type == "1")
|
set_type((type == "1") ? Perspective : Ortho);
|
||||||
set_type(Perspective);
|
|
||||||
else
|
|
||||||
set_type(Ortho);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::select_next_type()
|
void Camera::select_next_type()
|
||||||
|
@ -262,12 +258,9 @@ void Camera::apply_projection(const BoundingBoxf3& box, double near_z, double fa
|
||||||
w = 0.5 * (double)m_viewport[2];
|
w = 0.5 * (double)m_viewport[2];
|
||||||
h = 0.5 * (double)m_viewport[3];
|
h = 0.5 * (double)m_viewport[3];
|
||||||
|
|
||||||
if (m_zoom != 0.0)
|
double inv_zoom = get_inv_zoom();
|
||||||
{
|
w *= inv_zoom;
|
||||||
double inv_zoom = 1.0 / m_zoom;
|
h *= inv_zoom;
|
||||||
w *= inv_zoom;
|
|
||||||
h *= inv_zoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue