diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /core/math/camera_matrix.h | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
download | redot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'core/math/camera_matrix.h')
-rw-r--r-- | core/math/camera_matrix.h | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index c96f8259b5..857628c703 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -29,14 +29,12 @@ #ifndef CAMERA_MATRIX_H #define CAMERA_MATRIX_H -#include "transform.h" #include "math_2d.h" +#include "transform.h" /** @author Juan Linietsky <reduzio@gmail.com> */ - - struct CameraMatrix { enum Planes { @@ -48,21 +46,20 @@ struct CameraMatrix { PLANE_BOTTOM }; - real_t matrix[4][4]; - + real_t matrix[4][4]; void set_identity(); void set_zero(); void set_light_bias(); - void set_light_atlas_rect(const Rect2& p_rect); - void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far,bool p_flip_fov=false); - void set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar); - void set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar,bool p_flip_fov=false); + void set_light_atlas_rect(const Rect2 &p_rect); + void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false); + void set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar); + void set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov = false); void set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far); - static real_t get_fovy(real_t p_fovx,real_t p_aspect) { + static real_t get_fovy(real_t p_fovx, real_t p_aspect) { - return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5))*2.0); + return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0); } real_t get_z_far() const; @@ -70,40 +67,39 @@ struct CameraMatrix { real_t get_aspect() const; real_t get_fov() const; - Vector<Plane> get_projection_planes(const Transform& p_transform) const; + Vector<Plane> get_projection_planes(const Transform &p_transform) const; - bool get_endpoints(const Transform& p_transform,Vector3 *p_8points) const; - void get_viewport_size(real_t& r_width, real_t& r_height) const; + bool get_endpoints(const Transform &p_transform, Vector3 *p_8points) const; + void get_viewport_size(real_t &r_width, real_t &r_height) const; void invert(); CameraMatrix inverse() const; - CameraMatrix operator*(const CameraMatrix& p_matrix) const; + CameraMatrix operator*(const CameraMatrix &p_matrix) const; - Plane xform4(const Plane& p_vec4) const; - _FORCE_INLINE_ Vector3 xform(const Vector3& p_vec3) const; + Plane xform4(const Plane &p_vec4) const; + _FORCE_INLINE_ Vector3 xform(const Vector3 &p_vec3) const; operator String() const; - void scale_translate_to_fit(const Rect3& p_aabb); + void scale_translate_to_fit(const Rect3 &p_aabb); void make_scale(const Vector3 &p_scale); int get_pixels_per_meter(int p_for_pixel_width) const; operator Transform() const; CameraMatrix(); - CameraMatrix(const Transform& p_transform); + CameraMatrix(const Transform &p_transform); ~CameraMatrix(); - }; -Vector3 CameraMatrix::xform(const Vector3& p_vec3) const { +Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const { Vector3 ret; ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0]; ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1]; ret.z = matrix[0][2] * p_vec3.x + matrix[1][2] * p_vec3.y + matrix[2][2] * p_vec3.z + matrix[3][2]; real_t w = matrix[0][3] * p_vec3.x + matrix[1][3] * p_vec3.y + matrix[2][3] * p_vec3.z + matrix[3][3]; - return ret/w; + return ret / w; } #endif |