summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-09-15 20:06:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-09-15 20:06:37 -0300
commit642c63319eb7471c9accc0c50dfffef5d72c0078 (patch)
tree6d1a3c4ee4a591d9dc9ec9bdbf4054d66ea61774 /core/math
parent8cab401d08f8e25aa9b2dc710204785858ff3dbb (diff)
Camera Fixes
-=-=-=-=-=-= -Object Picking and orthogonal camera related functions fixed (i hope) -Going to preview mode in the camera shows a frame with the correct game aspect ratio -Changed Camera API and properties a little t make it more straightforward -Fixed bug in shader compiler. -Fixed bug in ShaderGL
Diffstat (limited to 'core/math')
-rw-r--r--core/math/camera_matrix.cpp7
-rw-r--r--core/math/camera_matrix.h2
2 files changed, 5 insertions, 4 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 52d77b6ebc..a60dea7379 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -67,9 +67,10 @@ Plane CameraMatrix::xform4(const Plane& p_vec4) {
void CameraMatrix::set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov) {
- if (p_flip_fov)
- p_fovy_degrees=get_fovy(p_fovy_degrees,p_aspect);
+ if (p_flip_fov) {
+ p_fovy_degrees=get_fovy(p_fovy_degrees,1.0/p_aspect);
+ }
float sine, cotangent, deltaZ;
float radians = p_fovy_degrees / 2.0 * Math_PI / 180.0;
@@ -110,7 +111,7 @@ void CameraMatrix::set_orthogonal(float p_left, float p_right, float p_bottom, f
void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov) {
- if (p_flip_fov) {
+ if (!p_flip_fov) {
p_size*=p_aspect;
}
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 6ffcb0ed0b..767236ea04 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -60,7 +60,7 @@ struct CameraMatrix {
static float get_fovy(float p_fovx,float p_aspect) {
- return Math::atan(p_aspect * Math::tan(p_fovx * 0.5))*2.0;
+ return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5))*2.0);
}
float get_z_far() const;