X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fcamera.cpp;h=bc8de57e51068b3eaa450ee996ccb79d108fc72b;hb=64de7412ba2d6b4c93f0379895bf775f74f00541;hp=7ffe0c155e60f6a6b968869901485a2c399fd7e6;hpb=4f2f558123db15393607d8b21b949d7798561dec;p=libs%2Fgl.git diff --git a/source/render/camera.cpp b/source/render/camera.cpp index 7ffe0c15..bc8de57e 100644 --- a/source/render/camera.cpp +++ b/source/render/camera.cpp @@ -110,7 +110,7 @@ Vector3 Camera::project(const Vector4 &p) const Vector3 Camera::project(const Vector3 &p) const { - return project(Vector4(p.x, p.y, p.z, 1.0)); + return project(compose(p, 1.0f)); } Vector4 Camera::unproject(const Vector4 &p) const @@ -122,7 +122,7 @@ Vector4 Camera::unproject(const Vector4 &p) const Vector3 Camera::unproject(const Vector3 &p) const { - return unproject(Vector4(p.x, p.y, p.z, 1.0f)).slice<3>(0); + return unproject(compose(p, 1.0f)).slice<3>(0); } bool Camera::is_in_frustum(const Renderable &renderable) const @@ -148,16 +148,16 @@ bool Camera::is_in_frustum(const Renderable &renderable) const void Camera::update_projection_matrix() { - float frustum_h = (fov!=Geometry::Angle::zero() ? tan(fov/2.0f)*clip_near : height/2); + float frustum_h = (is_orthographic() ? height/2 : tan(fov/2.0f)*clip_near); float frustum_w = frustum_h*aspect; float left = frustum_w*(frustum_x-1.0f); float right = frustum_w*(frustum_x+1.0f); float bottom = frustum_h*(frustum_y-1.0f); float top = frustum_h*(frustum_y+1.0f); - if(fov>Geometry::Angle::zero()) - proj_matrix = Matrix::frustum(left, right, bottom, top, clip_near, clip_far); - else + if(is_orthographic()) proj_matrix = Matrix::ortho(left, right, bottom, top, clip_near, clip_far); + else + proj_matrix = Matrix::frustum(left, right, bottom, top, clip_near, clip_far); proj_matrix = Matrix::rotation(rotate, Vector3(0, 0, 1))*proj_matrix; shdata.uniform("clip_eye_matrix", proj_matrix);