Skip to content

Commit df6d75e

Browse files
committed
changed code style
1 parent be3fae6 commit df6d75e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1259
-1313
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AllowShortBlocksOnASingleLine: Never
1414
AllowShortFunctionsOnASingleLine: None
1515
AllowShortIfStatementsOnASingleLine: false
1616
AllowShortLoopsOnASingleLine: false
17-
AlwaysBreakTemplateDeclarations: No
17+
BreakTemplateDeclarations: Leave
1818
BreakBeforeBraces: Custom
1919
BraceWrapping:
2020
AfterCaseLabel: true

include/omath/3d_primitives/box.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace omath::primitives
1212
{
1313
[[nodiscard]]
14-
std::array<Triangle<Vector3<float>>, 12> CreateBox(const Vector3<float>& top, const Vector3<float>& bottom,
15-
const Vector3<float>& dirForward, const Vector3<float>& dirRight,
14+
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
15+
const Vector3<float>& dir_forward, const Vector3<float>& dir_right,
1616
float ratio = 4.f);
1717
}

include/omath/angle.hpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
//
44

55
#pragma once
6+
#include "omath/angles.hpp"
67
#include <algorithm>
78
#include <utility>
8-
#include "omath/angles.hpp"
9-
109

1110
namespace omath
1211
{
@@ -17,14 +16,14 @@ namespace omath
1716
};
1817

1918
template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized>
20-
requires std::is_arithmetic_v<Type>
19+
requires std::is_arithmetic_v<Type>
2120
class Angle
2221
{
2322
Type m_angle;
2423
constexpr explicit Angle(const Type& degrees)
2524
{
2625
if constexpr (flags == AngleFlags::Normalized)
27-
m_angle = angles::WrapAngle(degrees, min, max);
26+
m_angle = angles::wrap_angle(degrees, min, max);
2827

2928
else if constexpr (flags == AngleFlags::Clamped)
3029
m_angle = std::clamp(degrees, min, max);
@@ -37,17 +36,17 @@ namespace omath
3736

3837
public:
3938
[[nodiscard]]
40-
constexpr static Angle FromDegrees(const Type& degrees)
39+
constexpr static Angle from_degrees(const Type& degrees)
4140
{
4241
return Angle{degrees};
4342
}
44-
constexpr Angle() : m_angle(0)
43+
constexpr Angle(): m_angle(0)
4544
{
4645
}
4746
[[nodiscard]]
48-
constexpr static Angle FromRadians(const Type& degrees)
47+
constexpr static Angle from_radians(const Type& degrees)
4948
{
50-
return Angle{angles::RadiansToDegrees<Type>(degrees)};
49+
return Angle{angles::radians_to_degrees<Type>(degrees)};
5150
}
5251

5352
[[nodiscard]]
@@ -57,51 +56,51 @@ namespace omath
5756
}
5857

5958
[[nodiscard]]
60-
constexpr Type AsDegrees() const
59+
constexpr Type as_degrees() const
6160
{
6261
return m_angle;
6362
}
6463

6564
[[nodiscard]]
66-
constexpr Type AsRadians() const
65+
constexpr Type as_radians() const
6766
{
68-
return angles::DegreesToRadians(m_angle);
67+
return angles::degrees_to_radians(m_angle);
6968
}
7069

7170
[[nodiscard]]
72-
Type Sin() const
71+
Type sin() const
7372
{
74-
return std::sin(AsRadians());
73+
return std::sin(as_radians());
7574
}
7675

7776
[[nodiscard]]
78-
Type Cos() const
77+
Type cos() const
7978
{
80-
return std::cos(AsRadians());
79+
return std::cos(as_radians());
8180
}
8281

8382
[[nodiscard]]
84-
Type Tan() const
83+
Type tan() const
8584
{
86-
return std::tan(AsRadians());
85+
return std::tan(as_radians());
8786
}
8887

8988
[[nodiscard]]
90-
Type Atan() const
89+
Type atan() const
9190
{
92-
return std::atan(AsRadians());
91+
return std::atan(as_radians());
9392
}
9493

9594
[[nodiscard]]
96-
Type Cot() const
95+
Type cot() const
9796
{
98-
return Cos() / Sin();
97+
return cos() / sin();
9998
}
10099

101100
constexpr Angle& operator+=(const Angle& other)
102101
{
103102
if constexpr (flags == AngleFlags::Normalized)
104-
m_angle = angles::WrapAngle(m_angle + other.m_angle, min, max);
103+
m_angle = angles::wrap_angle(m_angle + other.m_angle, min, max);
105104

106105
else if constexpr (flags == AngleFlags::Clamped)
107106
m_angle = std::clamp(m_angle + other.m_angle, min, max);
@@ -115,7 +114,8 @@ namespace omath
115114
}
116115

117116
[[nodiscard]]
118-
constexpr std::partial_ordering operator<=>(const Angle& other) const = default;
117+
constexpr std::partial_ordering operator<=>(const Angle& other) const
118+
= default;
119119

120120
constexpr Angle& operator-=(const Angle& other)
121121
{
@@ -126,7 +126,7 @@ namespace omath
126126
constexpr Angle& operator+(const Angle& other)
127127
{
128128
if constexpr (flags == AngleFlags::Normalized)
129-
return {angles::WrapAngle(m_angle + other.m_angle, min, max)};
129+
return {angles::wrap_angle(m_angle + other.m_angle, min, max)};
130130

131131
else if constexpr (flags == AngleFlags::Clamped)
132132
return {std::clamp(m_angle + other.m_angle, min, max)};

include/omath/angles.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@ namespace omath::angles
1010
{
1111
template<class Type>
1212
requires std::is_floating_point_v<Type>
13-
[[nodiscard]] constexpr Type RadiansToDegrees(const Type& radians)
13+
[[nodiscard]] constexpr Type radians_to_degrees(const Type& radians)
1414
{
1515
return radians * (Type(180) / std::numbers::pi_v<Type>);
1616
}
1717

1818
template<class Type>
1919
requires std::is_floating_point_v<Type>
20-
[[nodiscard]] constexpr Type DegreesToRadians(const Type& degrees)
20+
[[nodiscard]] constexpr Type degrees_to_radians(const Type& degrees)
2121
{
2222
return degrees * (std::numbers::pi_v<Type> / Type(180));
2323
}
2424

2525
template<class type>
2626
requires std::is_floating_point_v<type>
27-
[[nodiscard]] type HorizontalFovToVertical(const type& horFov, const type& aspect)
27+
[[nodiscard]] type horizontal_fov_to_vertical(const type& horizontal_fov, const type& aspect)
2828
{
29-
const auto fovRad = DegreesToRadians(horFov);
29+
const auto fov_rad = degrees_to_radians(horizontal_fov);
3030

31-
const auto vertFov = type(2) * std::atan(std::tan(fovRad / type(2)) / aspect);
31+
const auto vert_fov = type(2) * std::atan(std::tan(fov_rad / type(2)) / aspect);
3232

33-
return RadiansToDegrees(vertFov);
33+
return radians_to_degrees(vert_fov);
3434
}
3535

3636
template<class Type>
3737
requires std::is_floating_point_v<Type>
38-
[[nodiscard]] Type VerticalFovToHorizontal(const Type& vertFov, const Type& aspect)
38+
[[nodiscard]] Type vertical_fov_to_horizontal(const Type& vertical_fov, const Type& aspect)
3939
{
40-
const auto fovRad = DegreesToRadians(vertFov);
40+
const auto fov_as_radians = degrees_to_radians(vertical_fov);
4141

42-
const auto horFov = Type(2) * std::atan(std::tan(fovRad / Type(2)) * aspect);
42+
const auto horizontal_fov = Type(2) * std::atan(std::tan(fov_as_radians / Type(2)) * aspect);
4343

44-
return RadiansToDegrees(horFov);
44+
return radians_to_degrees(horizontal_fov);
4545
}
4646

4747
template<class Type>
4848
requires std::is_arithmetic_v<Type>
49-
[[nodiscard]] Type WrapAngle(const Type& angle, const Type& min, const Type& max)
49+
[[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max)
5050
{
5151
if (angle <= max && angle >= min)
5252
return angle;
@@ -60,4 +60,4 @@ namespace omath::angles
6060

6161
return wrappedAngle + min;
6262
}
63-
}
63+
} // namespace omath::angles

include/omath/collision/line_tracer.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ namespace omath::collision
1414
Vector3<float> start;
1515
Vector3<float> end;
1616
bool infinite_length = false;
17+
1718
[[nodiscard]]
18-
Vector3<float> DirectionVector() const;
19+
Vector3<float> direction_vector() const;
1920

2021
[[nodiscard]]
21-
Vector3<float> DirectionVectorNormalized() const;
22+
Vector3<float> direction_vector_normalized() const;
2223
};
2324
class LineTracer
2425
{
2526
public:
2627
LineTracer() = delete;
2728

28-
2929
[[nodiscard]]
30-
static bool CanTraceLine(const Ray& ray, const Triangle<Vector3<float>>& triangle);
31-
30+
static bool can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle);
3231

3332
// Realization of Möller–Trumbore intersection algorithm
3433
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
3534
[[nodiscard]]
36-
static Vector3<float> GetRayHitPoint(const Ray& ray, const Triangle<Vector3<float>>& triangle);
35+
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle);
3736
};
38-
}
37+
} // namespace omath::collision

0 commit comments

Comments
 (0)