浏览代码

chore: fix clang-format indenting

Sam Jaffe 1 年之前
父节点
当前提交
7ef396f108

+ 1 - 1
.clang-format

@@ -75,7 +75,7 @@ KeepEmptyLinesAtTheStartOfBlocks: true
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
-NamespaceIndentation: Inner
+NamespaceIndentation: None
 ObjCBlockIndentWidth: 2
 ObjCSpaceAfterProperty: false
 ObjCSpaceBeforeProtocolList: true

+ 2 - 2
engine/include/game/engine/engine_fwd.hpp

@@ -27,7 +27,7 @@ class scene;
 class text_engine;
 
 namespace event {
-  struct key_event;
-  struct mouse_event;
+struct key_event;
+struct mouse_event;
 }
 }

+ 4 - 4
engine/src/game_dispatch.cpp

@@ -21,10 +21,10 @@
 
 namespace engine {
 namespace {
-  event::event_type mask(event::event_type t, bool pressed) {
-    return static_cast<event::event_type>(
-        t | (pressed ? event::PRESSED_MASK : event::RELEASED_MASK));
-  }
+event::event_type mask(event::event_type t, bool pressed) {
+  return static_cast<event::event_type>(
+      t | (pressed ? event::PRESSED_MASK : event::RELEASED_MASK));
+}
 }
 
 game_dispatch::game_dispatch(std::shared_ptr<graphics::renderer> renderer)

+ 11 - 11
engine/test/entity_test.cxx

@@ -22,17 +22,17 @@ using testing::Eq;
 using testing::Ne;
 
 namespace math { namespace dim2 {
-  bool operator==(rectangle const & lhs, rectangle const & rhs) {
-    return lhs.origin == rhs.origin && lhs.size == rhs.size;
-  }
-  bool operator!=(rectangle const & lhs, rectangle const & rhs) {
-    return !(lhs == rhs);
-  }
-  bool operator==(quad const & lhs, quad const & rhs) {
-    return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul &&
-           lhs.ur == rhs.ur;
-  }
-  bool operator!=(quad const & lhs, quad const & rhs) { return !(lhs == rhs); }
+bool operator==(rectangle const & lhs, rectangle const & rhs) {
+  return lhs.origin == rhs.origin && lhs.size == rhs.size;
+}
+bool operator!=(rectangle const & lhs, rectangle const & rhs) {
+  return !(lhs == rhs);
+}
+bool operator==(quad const & lhs, quad const & rhs) {
+  return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul &&
+         lhs.ur == rhs.ur;
+}
+bool operator!=(quad const & lhs, quad const & rhs) { return !(lhs == rhs); }
 }}
 
 inline Json::Value to_json(std::string const & str) {

+ 3 - 3
graphics/include/game/graphics/graphics_fwd.h

@@ -23,12 +23,12 @@ struct shader;
 struct shader_program;
 class texture;
 namespace materials {
-  enum class uniform : unsigned int;
+enum class uniform : unsigned int;
 }
 namespace shaders {
-  enum class type : unsigned int;
+enum class type : unsigned int;
 }
 namespace textures {
-  enum class format : unsigned int;
+enum class format : unsigned int;
 }
 }

+ 10 - 10
graphics/src/helper.hpp

@@ -18,20 +18,20 @@
 
 namespace graphics {
 namespace textures {
-  enum class format : unsigned int { RGB, RGBA };
-  struct external_data {
-    external_data(std::string const & abs_path);
-    ~external_data();
-    format color;
-    math::vec2i size;
-    void * buffer;
-  };
+enum class format : unsigned int { RGB, RGBA };
+struct external_data {
+  external_data(std::string const & abs_path);
+  ~external_data();
+  format color;
+  math::vec2i size;
+  void * buffer;
+};
 }
 namespace shaders {
-  enum class type : unsigned int { FRAGMENT, VERTEX };
+enum class type : unsigned int { FRAGMENT, VERTEX };
 }
 namespace materials {
-  enum class uniform : unsigned int { NORMAL, DIFFUSE, SPECULAR };
+enum class uniform : unsigned int { NORMAL, DIFFUSE, SPECULAR };
 }
 }
 

+ 9 - 9
math/include/game/math/math_fwd.hpp

@@ -12,12 +12,12 @@
 
 namespace math {
 namespace vector {
-  template <typename, size_t> class vector;
+template <typename, size_t> class vector;
 }
 namespace matrix {
-  template <typename, size_t, size_t> class matrix;
+template <typename, size_t, size_t> class matrix;
 
-  template <typename T, size_t N> using square_matrix = matrix<T, N, N>;
+template <typename T, size_t N> using square_matrix = matrix<T, N, N>;
 }
 }
 
@@ -30,12 +30,12 @@ using rgba = vector::vector<uint8_t, 4>;
 using matr4 = matrix::matrix<float, 4, 4>;
 
 namespace dim2 {
-  using point = vec2;
-  struct line;
-  struct circle;
-  struct quad;
-  struct rectangle;
-  struct square;
+using point = vec2;
+struct line;
+struct circle;
+struct quad;
+struct rectangle;
+struct square;
 }
 
 struct degree;

+ 36 - 36
math/include/game/math/shape.hpp

@@ -12,46 +12,46 @@
 #include <game/math/math_fwd.hpp>
 
 namespace math { namespace dim2 {
-  using point = vec2;
-
-  struct line {
-    float length() const;
-    float slope() const;
-    point first, second;
-  };
-
-  struct circle {
-    point center;
-    float radius;
-  };
-
-  struct triangle {
-    point a, b, c;
-  };
-
-  struct quad {
-    point ll, lr, ur, ul;
-  };
-
-  struct rectangle {
-    operator quad() const;
-    point origin, size;
-  };
-
-  struct square {
-    operator rectangle() const;
-    operator quad() const;
-    point origin;
-    float size;
-  };
+using point = vec2;
+
+struct line {
+  float length() const;
+  float slope() const;
+  point first, second;
+};
+
+struct circle {
+  point center;
+  float radius;
+};
+
+struct triangle {
+  point a, b, c;
+};
+
+struct quad {
+  point ll, lr, ur, ul;
+};
+
+struct rectangle {
+  operator quad() const;
+  point origin, size;
+};
+
+struct square {
+  operator rectangle() const;
+  operator quad() const;
+  point origin;
+  float size;
+};
 }}
 
 namespace math { namespace shapes {
-  std::vector<dim2::line> segments(dim2::quad const & shape);
+std::vector<dim2::line> segments(dim2::quad const & shape);
 }}
 
 namespace math { namespace lines {
-  bool parallel(dim2::line const & lhs, dim2::line const & rhs);
-  dim2::point intersection(dim2::line const & lhs, dim2::line const & rhs);
-  dim2::line orthogonal(dim2::line const & from, dim2::point const & to);
+bool parallel(dim2::line const & lhs, dim2::line const & rhs);
+dim2::point intersection(dim2::line const & lhs, dim2::line const & rhs);
+dim2::line orthogonal(dim2::line const & from, dim2::point const & to);
 }}

+ 41 - 41
math/src/shape.cpp

@@ -12,59 +12,59 @@
 #include "game/math/compare.hpp"
 
 namespace math { namespace dim2 {
-  float line::length() const { return (second - first).magnitude(); }
+float line::length() const { return (second - first).magnitude(); }
 
-  float line::slope() const {
-    return safe_div(second[1] - first[1], second[0] - first[0]);
-  }
+float line::slope() const {
+  return safe_div(second[1] - first[1], second[0] - first[0]);
+}
 
-  rectangle::operator quad() const {
-    return {origin, origin + vec2{{size.x(), 0.0}}, origin + size,
-            origin + vec2{{0.0, size.y()}}};
-  }
+rectangle::operator quad() const {
+  return {origin, origin + vec2{{size.x(), 0.0}}, origin + size,
+          origin + vec2{{0.0, size.y()}}};
+}
 
-  square::operator rectangle() const { return {origin, vec2{{size, size}}}; }
+square::operator rectangle() const { return {origin, vec2{{size, size}}}; }
 
-  square::operator quad() const {
-    return {origin, origin + vec2{{size, 0.0}}, origin + vec2{{size, size}},
-            origin + vec2{{0.0, size}}};
-  }
+square::operator quad() const {
+  return {origin, origin + vec2{{size, 0.0}}, origin + vec2{{size, size}},
+          origin + vec2{{0.0, size}}};
+}
 }}
 
 namespace math { namespace shapes {
-  std::vector<dim2::line> segments(dim2::quad const & shape) {
-    return {{shape.ll, shape.lr},
-            {shape.lr, shape.ur},
-            {shape.ur, shape.ul},
-            {shape.ul, shape.ll}};
-  }
+std::vector<dim2::line> segments(dim2::quad const & shape) {
+  return {{shape.ll, shape.lr},
+          {shape.lr, shape.ur},
+          {shape.ur, shape.ul},
+          {shape.ul, shape.ll}};
+}
 }}
 
 namespace math { namespace lines {
-  bool parallel(dim2::line const & lhs, dim2::line const & rhs) {
-    return lhs.slope() == rhs.slope();
-  }
+bool parallel(dim2::line const & lhs, dim2::line const & rhs) {
+  return lhs.slope() == rhs.slope();
+}
 
-  inline dim2::point intersection(float b1, float s1, float b2, float s2) {
-    float const x = safe_div(b1 - b2, s2 - s1);
-    return {{x, b1 + x * s1}};
-  }
+inline dim2::point intersection(float b1, float s1, float b2, float s2) {
+  float const x = safe_div(b1 - b2, s2 - s1);
+  return {{x, b1 + x * s1}};
+}
 
-  inline dim2::point intersection(dim2::point const & p1, float s1,
-                                  dim2::point const & p2, float s2) {
-    // Solve for Inf * NaN
-    float y1 = p1[0] == 0 ? 0 : s1 * p1[0];
-    float y2 = p2[0] == 0 ? 0 : s2 * p2[0];
-    return intersection(p1[1] - y1, s1, p2[1] - y2, s2);
-  }
+inline dim2::point intersection(dim2::point const & p1, float s1,
+                                dim2::point const & p2, float s2) {
+  // Solve for Inf * NaN
+  float y1 = p1[0] == 0 ? 0 : s1 * p1[0];
+  float y2 = p2[0] == 0 ? 0 : s2 * p2[0];
+  return intersection(p1[1] - y1, s1, p2[1] - y2, s2);
+}
 
-  dim2::point intersection(dim2::line const & lhs, dim2::line const & rhs) {
-    return intersection(lhs.first, lhs.slope(), rhs.first, rhs.slope());
-  }
+dim2::point intersection(dim2::line const & lhs, dim2::line const & rhs) {
+  return intersection(lhs.first, lhs.slope(), rhs.first, rhs.slope());
+}
 
-  dim2::line orthogonal(dim2::line const & from, dim2::point const & to) {
-    float const slope = from.slope();
-    if (slope == 0 || isinf(slope)) { return {to, {{to[0], from.first[1]}}}; }
-    return {to, intersection(from.first, slope, to, -1 / slope)};
-  }
+dim2::line orthogonal(dim2::line const & from, dim2::point const & to) {
+  float const slope = from.slope();
+  if (slope == 0 || isinf(slope)) { return {to, {{to[0], from.first[1]}}}; }
+  return {to, intersection(from.first, slope, to, -1 / slope)};
+}
 }}

+ 13 - 13
math/test/test_printers.h

@@ -13,21 +13,21 @@
 #include "game/math/shape.hpp"
 
 namespace math { namespace vector {
-  inline std::ostream & operator<<(std::ostream & os, math::vec2 const & p) {
-    return os << '[' << p[0] << ',' << p[1] << ']';
-  }
+inline std::ostream & operator<<(std::ostream & os, math::vec2 const & p) {
+  return os << '[' << p[0] << ',' << p[1] << ']';
+}
 }}
 namespace math { namespace dim2 {
-  inline bool operator==(line const & lhs, line const & rhs) {
-    return lhs.first == rhs.first && lhs.second == rhs.second;
-  }
-  inline bool operator==(quad const & lhs, quad const & rhs) {
-    return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul &&
-           lhs.ur == rhs.ur;
-  }
-  inline std::ostream & operator<<(std::ostream & os, line const & l) {
-    return os << '[' << l.first << ',' << l.second << ']';
-  }
+inline bool operator==(line const & lhs, line const & rhs) {
+  return lhs.first == rhs.first && lhs.second == rhs.second;
+}
+inline bool operator==(quad const & lhs, quad const & rhs) {
+  return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul &&
+         lhs.ur == rhs.ur;
+}
+inline std::ostream & operator<<(std::ostream & os, line const & l) {
+  return os << '[' << l.first << ',' << l.second << ']';
+}
 }}
 
 #endif /* test_printers_h */