From 2a0ddc1e89ec7b947152c8d0cb132d58f2c00a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 15 Jan 2017 22:15:47 +0100 Subject: Style: Various fixes to play nice with clang-format --- core/math/camera_matrix.cpp | 45 +++++++++++++++++------- core/math/triangle_mesh.cpp | 45 +++++++++++++----------- core/os/input_event.cpp | 3 ++ core/os/keyboard.cpp | 7 ++-- core/profile_clock.cpp | 3 -- core/profile_clock.h | 7 ---- core/typedefs.h | 74 +++++++++++++++++---------------------- core/variant_call.cpp | 22 ++++++------ core/variant_construct_string.cpp | 2 +- 9 files changed, 109 insertions(+), 99 deletions(-) delete mode 100644 core/profile_clock.cpp delete mode 100644 core/profile_clock.h (limited to 'core') 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<= 4 ) -# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline +#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline #elif defined(__llvm__) -# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline +#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline #elif defined(_MSC_VER) -# define _ALWAYS_INLINE_ __forceinline +#define _ALWAYS_INLINE_ __forceinline #else -# define _ALWAYS_INLINE_ inline +#define _ALWAYS_INLINE_ inline #endif #endif #ifndef _FORCE_INLINE_ - #ifdef DEBUG_ENABLED - #define _FORCE_INLINE_ inline - #else - #define _FORCE_INLINE_ _ALWAYS_INLINE_ - #endif - #endif @@ -97,16 +95,16 @@ T *_nullptr() { T*t=NULL; return t; } */ #ifdef _WIN32 -# undef min // override standard definition -# undef max // override standard definition -# undef ERROR // override (really stupid) wingdi.h standard definition -# undef DELETE // override (another really stupid) winnt.h standard definition -# undef MessageBox // override winuser.h standard definition -# undef MIN // override standard definition -# undef MAX // override standard definition -# undef CLAMP // override standard definition -# undef Error -# undef OK +#undef min // override standard definition +#undef max // override standard definition +#undef ERROR // override (really stupid) wingdi.h standard definition +#undef DELETE // override (another really stupid) winnt.h standard definition +#undef MessageBox // override winuser.h standard definition +#undef MIN // override standard definition +#undef MAX // override standard definition +#undef CLAMP // override standard definition +#undef Error +#undef OK #endif #include "error_macros.h" @@ -150,30 +148,30 @@ inline void __swap_tmpl(T &x, T &y ) { #endif //swap -#define HEX2CHR( m_hex ) ( (m_hex>='0' && m_hex<='9')?(m_hex-'0'):\ - ((m_hex>='A' && m_hex<='F')?(10+m_hex-'A'):\ - ((m_hex>='a' && m_hex<='f')?(10+m_hex-'a'):0))) +/* clang-format off */ +#define HEX2CHR(m_hex) \ + ((m_hex >= '0' && m_hex <= '9') ? (m_hex - '0') : \ + ((m_hex >= 'A' && m_hex <= 'F') ? (10 + m_hex - 'A') : \ + ((m_hex >= 'a' && m_hex <= 'f') ? (10 + m_hex - 'a') : 0))) +/* clang-format on */ // Macro to check whether we are compiled by clang // and we have a specific builtin #if defined(__llvm__) && defined(__has_builtin) - #define _llvm_has_builtin(x) __has_builtin(x) +#define _llvm_has_builtin(x) __has_builtin(x) #else - #define _llvm_has_builtin(x) 0 +#define _llvm_has_builtin(x) 0 #endif #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_mul_overflow) -# define _mul_overflow __builtin_mul_overflow +#define _mul_overflow __builtin_mul_overflow #endif #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_add_overflow) -# define _add_overflow __builtin_add_overflow +#define _add_overflow __builtin_add_overflow #endif - - - /** Function to find the nearest (bigger) power of 2 to an integer */ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) { @@ -276,14 +274,11 @@ struct _GlobalLock { }; #define GLOBAL_LOCK_FUNCTION _GlobalLock _global_lock_; -#ifdef NO_SAFE_CAST +#ifdef NO_SAFE_CAST #define SAFE_CAST static_cast - #else - #define SAFE_CAST dynamic_cast - #endif #define MT_SAFE @@ -291,7 +286,4 @@ struct _GlobalLock { #define __STRX(m_index) #m_index #define __STR(m_index) __STRX(m_index) - - #endif /* typedefs.h */ - diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 9476f93652..022faede1e 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1053,31 +1053,31 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i // math types - case VECTOR2: return Vector2(); // 5 + case VECTOR2: return Vector2(); // 5 case RECT2: return Rect2(); case VECTOR3: return Vector3(); case TRANSFORM2D: return Transform2D(); case PLANE: return Plane(); case QUAT: return Quat(); - case RECT3: return Rect3(); //sorry naming convention fail :( not like it's used often // 10 + case RECT3: return Rect3(); // 10 case BASIS: return Basis(); case TRANSFORM: return Transform(); // misc types case COLOR: return Color(); case IMAGE: return Image(); - case NODE_PATH: return NodePath();; // 15 + case NODE_PATH: return NodePath(); // 15 case _RID: return RID(); case OBJECT: return (Object*)NULL; case INPUT_EVENT: return InputEvent(); case DICTIONARY: return Dictionary(); - case ARRAY: return Array();; // 20 + case ARRAY: return Array(); // 20 case POOL_BYTE_ARRAY: return PoolByteArray(); case POOL_INT_ARRAY: return PoolIntArray(); case POOL_REAL_ARRAY: return PoolRealArray(); case POOL_STRING_ARRAY: return PoolStringArray(); - case POOL_VECTOR2_ARRAY: return PoolVector2Array();; // 25 - case POOL_VECTOR3_ARRAY: return PoolVector3Array();; // 25 + case POOL_VECTOR2_ARRAY: return PoolVector2Array(); // 25 + case POOL_VECTOR3_ARRAY: return PoolVector3Array(); case POOL_COLOR_ARRAY: return PoolColorArray(); default: return Variant(); } @@ -1127,27 +1127,27 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i case VECTOR3: return (Vector3(*p_args[0])); case PLANE: return (Plane(*p_args[0])); case QUAT: return (Quat(*p_args[0])); - case RECT3: return (Rect3(*p_args[0])); //sorry naming convention fail :( not like it's used often // 10 + case RECT3: return (Rect3(*p_args[0])); // 10 case BASIS: return (Basis(p_args[0]->operator Basis())); case TRANSFORM: return (Transform(p_args[0]->operator Transform())); // misc types case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]); case IMAGE: return (Image(*p_args[0])); - case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15 + case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15 case _RID: return (RID(*p_args[0])); case OBJECT: return ((Object*)(p_args[0]->operator Object *())); case INPUT_EVENT: return (InputEvent(*p_args[0])); case DICTIONARY: return p_args[0]->operator Dictionary(); - case ARRAY: return p_args[0]->operator Array(); + case ARRAY: return p_args[0]->operator Array(); // 20 // arrays case POOL_BYTE_ARRAY: return (PoolByteArray(*p_args[0])); case POOL_INT_ARRAY: return (PoolIntArray(*p_args[0])); case POOL_REAL_ARRAY: return (PoolRealArray(*p_args[0])); case POOL_STRING_ARRAY: return (PoolStringArray(*p_args[0])); - case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25 - case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0])); // 25 + case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25 + case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0])); case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0])); default: return Variant(); } diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp index 8db756aa79..56aa9891fb 100644 --- a/core/variant_construct_string.cpp +++ b/core/variant_construct_string.cpp @@ -169,7 +169,7 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T case 'r': res=13; break; case '\"': res='\"'; break; case '\\': res='\\'; break; - case '/': res='/'; break; //wtf + case '/': res='/'; break; case 'u': { //hexnumbarh - oct is deprecated -- cgit v1.2.3