summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-01-15 22:15:47 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-01-16 08:49:52 +0100
commit2a0ddc1e89ec7b947152c8d0cb132d58f2c00a81 (patch)
treee7cafdf9c76fd6545124ead4dc5ee17f940f0a10 /core/math
parent39114178a0952e9f5efee08e23d73d70f3d8d3db (diff)
Style: Various fixes to play nice with clang-format
Diffstat (limited to 'core/math')
-rw-r--r--core/math/camera_matrix.cpp45
-rw-r--r--core/math/triangle_mesh.cpp45
2 files changed, 56 insertions, 34 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index c44ff4682a..cbf21cec4d 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -143,10 +143,22 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa
float c = - ( p_far + p_near ) / ( p_far - p_near );
float d = - 2 * p_far * p_near / ( p_far - p_near );
- te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
- te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
- te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
- te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
+ te[0] = x;
+ te[1] = 0;
+ te[2] = 0;
+ te[3] = 0;
+ te[4] = 0;
+ te[5] = y;
+ te[6] = 0;
+ te[7] = 0;
+ te[8] = a;
+ te[9] = b;
+ te[10] = c;
+ te[11] = -1;
+ te[12] = 0;
+ te[13] = 0;
+ te[14] = d;
+ te[15] = 0;
#endif
@@ -186,18 +198,21 @@ void CameraMatrix::get_viewport_size(float& r_width, float& r_height) const {
Plane near_plane=Plane(matrix[ 3] + matrix[ 2],
matrix[ 7] + matrix[ 6],
matrix[11] + matrix[10],
- -matrix[15] - matrix[14]).normalized();
+ -matrix[15] - matrix[14])
+ near_plane.normalize();
///////--- Right Plane ---///////
Plane right_plane=Plane(matrix[ 3] - matrix[ 0],
matrix[ 7] - matrix[ 4],
matrix[11] - matrix[ 8],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12])
+ right_plane.normalize();
Plane top_plane=Plane(matrix[ 3] - matrix[ 1],
matrix[ 7] - matrix[ 5],
matrix[11] - matrix[ 9],
- -matrix[15] + matrix[13]).normalized();
+ -matrix[15] + matrix[13])
+ top_plane.normalize();
Vector3 res;
near_plane.intersect_3(right_plane,top_plane,&res);
@@ -214,26 +229,29 @@ bool CameraMatrix::get_endpoints(const Transform& p_transform, Vector3 *p_8point
Plane near_plane=Plane(matrix[ 3] + matrix[ 2],
matrix[ 7] + matrix[ 6],
matrix[11] + matrix[10],
- -matrix[15] - matrix[14]).normalized();
+ -matrix[15] - matrix[14])
+ near_plane.normalize();
///////--- Far Plane ---///////
Plane far_plane=Plane(matrix[ 2] - matrix[ 3],
matrix[ 6] - matrix[ 7],
matrix[10] - matrix[11],
- matrix[15] - matrix[14]).normalized();
-
+ matrix[15] - matrix[14])
+ far_plane.normalize();
///////--- Right Plane ---///////
Plane right_plane=Plane(matrix[ 0] - matrix[ 3],
matrix[ 4] - matrix[ 7],
matrix[8] - matrix[ 11],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12])
+ right_plane.normalize();
///////--- Top Plane ---///////
Plane top_plane=Plane(matrix[ 1] - matrix[ 3],
matrix[ 5] - matrix[ 7],
matrix[9] - matrix[ 11],
- -matrix[15] + matrix[13]).normalized();
+ -matrix[15] + matrix[13])
+ top_plane.normalize();
Vector3 near_endpoint;
Vector3 far_endpoint;
@@ -549,7 +567,8 @@ float CameraMatrix::get_fov() const {
Plane right_plane=Plane(matrix[ 3] - matrix[ 0],
matrix[ 7] - matrix[ 4],
matrix[11] - matrix[ 8],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12])
+ right_plane.normalize();
return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x)))*2.0;
}
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 74c4656771..86f8bf29e7 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -236,21 +236,22 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const {
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -258,8 +259,8 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const {
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}
@@ -357,21 +358,22 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -379,8 +381,8 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}
@@ -478,21 +480,22 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -500,8 +503,8 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}