You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
#include "core/print_string.h"
|
||||
|
||||
float CameraMatrix::determinant() const {
|
||||
|
||||
return matrix[0][3] * matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[0][2] * matrix[1][3] * matrix[2][1] * matrix[3][0] -
|
||||
matrix[0][3] * matrix[1][1] * matrix[2][2] * matrix[3][0] + matrix[0][1] * matrix[1][3] * matrix[2][2] * matrix[3][0] +
|
||||
matrix[0][2] * matrix[1][1] * matrix[2][3] * matrix[3][0] - matrix[0][1] * matrix[1][2] * matrix[2][3] * matrix[3][0] -
|
||||
@@ -50,29 +49,22 @@ float CameraMatrix::determinant() const {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_identity() {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
||||
matrix[i][j] = (i == j) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CameraMatrix::set_zero() {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
||||
matrix[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
||||
|
||||
Plane ret;
|
||||
|
||||
ret.normal.x = matrix[0][0] * p_vec4.normal.x + matrix[1][0] * p_vec4.normal.y + matrix[2][0] * p_vec4.normal.z + matrix[3][0] * p_vec4.d;
|
||||
@@ -83,7 +75,6 @@ Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
||||
}
|
||||
|
||||
void CameraMatrix::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) {
|
||||
|
||||
if (p_flip_fov) {
|
||||
p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);
|
||||
}
|
||||
@@ -176,7 +167,6 @@ void CameraMatrix::set_for_hmd(int p_eye, real_t p_aspect, real_t p_intraocular_
|
||||
};
|
||||
|
||||
void CameraMatrix::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) {
|
||||
|
||||
set_identity();
|
||||
|
||||
matrix[0][0] = 2.0 / (p_right - p_left);
|
||||
@@ -189,7 +179,6 @@ void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom
|
||||
}
|
||||
|
||||
void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov) {
|
||||
|
||||
if (!p_flip_fov) {
|
||||
p_size *= p_aspect;
|
||||
}
|
||||
@@ -198,7 +187,6 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
|
||||
}
|
||||
|
||||
void CameraMatrix::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) {
|
||||
|
||||
ERR_FAIL_COND(p_right <= p_left);
|
||||
ERR_FAIL_COND(p_top <= p_bottom);
|
||||
ERR_FAIL_COND(p_far <= p_near);
|
||||
@@ -239,7 +227,6 @@ void CameraMatrix::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset,
|
||||
}
|
||||
|
||||
real_t CameraMatrix::get_z_far() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
Plane new_plane = Plane(matrix[3] - matrix[2],
|
||||
matrix[7] - matrix[6],
|
||||
@@ -252,7 +239,6 @@ real_t CameraMatrix::get_z_far() const {
|
||||
return new_plane.d;
|
||||
}
|
||||
real_t CameraMatrix::get_z_near() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
Plane new_plane = Plane(matrix[3] + matrix[2],
|
||||
matrix[7] + matrix[6],
|
||||
@@ -264,7 +250,6 @@ real_t CameraMatrix::get_z_near() const {
|
||||
}
|
||||
|
||||
Vector2 CameraMatrix::get_viewport_half_extents() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
///////--- Near Plane ---///////
|
||||
Plane near_plane = Plane(matrix[3] + matrix[2],
|
||||
@@ -293,7 +278,6 @@ Vector2 CameraMatrix::get_viewport_half_extents() const {
|
||||
}
|
||||
|
||||
void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
///////--- Far Plane ---///////
|
||||
Plane far_plane = Plane(matrix[3] - matrix[2],
|
||||
@@ -323,7 +307,6 @@ void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
|
||||
}
|
||||
|
||||
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
|
||||
|
||||
Vector<Plane> planes = get_projection_planes(Transform());
|
||||
const Planes intersections[8][3] = {
|
||||
{ PLANE_FAR, PLANE_LEFT, PLANE_TOP },
|
||||
@@ -337,7 +320,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
|
||||
};
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
Vector3 point;
|
||||
bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
|
||||
ERR_FAIL_COND_V(!res, false);
|
||||
@@ -348,7 +330,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
|
||||
}
|
||||
|
||||
Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform) const {
|
||||
|
||||
/** Fast Plane Extraction from combined modelview/projection matrices.
|
||||
* References:
|
||||
* https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
|
||||
@@ -431,14 +412,12 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform)
|
||||
}
|
||||
|
||||
CameraMatrix CameraMatrix::inverse() const {
|
||||
|
||||
CameraMatrix cm = *this;
|
||||
cm.invert();
|
||||
return cm;
|
||||
}
|
||||
|
||||
void CameraMatrix::invert() {
|
||||
|
||||
int i, j, k;
|
||||
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
|
||||
real_t pvt_val; /* Value of current pivot element */
|
||||
@@ -541,12 +520,10 @@ void CameraMatrix::flip_y() {
|
||||
}
|
||||
|
||||
CameraMatrix::CameraMatrix() {
|
||||
|
||||
set_identity();
|
||||
}
|
||||
|
||||
CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
||||
|
||||
CameraMatrix new_matrix;
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
@@ -562,7 +539,6 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_depth_correction(bool p_flip_y) {
|
||||
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
m[0] = 1;
|
||||
@@ -584,7 +560,6 @@ void CameraMatrix::set_depth_correction(bool p_flip_y) {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_light_bias() {
|
||||
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
m[0] = 0.5;
|
||||
@@ -606,7 +581,6 @@ void CameraMatrix::set_light_bias() {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
||||
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
m[0] = p_rect.size.width;
|
||||
@@ -628,7 +602,6 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
||||
}
|
||||
|
||||
CameraMatrix::operator String() const {
|
||||
|
||||
String str;
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
@@ -638,20 +611,17 @@ CameraMatrix::operator String() const {
|
||||
}
|
||||
|
||||
real_t CameraMatrix::get_aspect() const {
|
||||
|
||||
Vector2 vp_he = get_viewport_half_extents();
|
||||
return vp_he.x / vp_he.y;
|
||||
}
|
||||
|
||||
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
|
||||
|
||||
Vector3 result = xform(Vector3(1, 0, -1));
|
||||
|
||||
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
|
||||
}
|
||||
|
||||
bool CameraMatrix::is_orthogonal() const {
|
||||
|
||||
return matrix[3][3] == 1.0;
|
||||
}
|
||||
|
||||
@@ -679,7 +649,6 @@ real_t CameraMatrix::get_fov() const {
|
||||
}
|
||||
|
||||
void CameraMatrix::make_scale(const Vector3 &p_scale) {
|
||||
|
||||
set_identity();
|
||||
matrix[0][0] = p_scale.x;
|
||||
matrix[1][1] = p_scale.y;
|
||||
@@ -687,7 +656,6 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
|
||||
}
|
||||
|
||||
void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
|
||||
|
||||
Vector3 min = p_aabb.position;
|
||||
Vector3 max = p_aabb.position + p_aabb.size;
|
||||
|
||||
@@ -713,7 +681,6 @@ void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
|
||||
}
|
||||
|
||||
CameraMatrix::operator Transform() const {
|
||||
|
||||
Transform tr;
|
||||
const real_t *m = &matrix[0][0];
|
||||
|
||||
@@ -737,7 +704,6 @@ CameraMatrix::operator Transform() const {
|
||||
}
|
||||
|
||||
CameraMatrix::CameraMatrix(const Transform &p_transform) {
|
||||
|
||||
const Transform &tr = p_transform;
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user