Skip to content

Commit 1196bb8

Browse files
authored
Merge pull request #44 from orange-cpp/feature/noexcept
Feature/noexcept
2 parents f6f8bba + 5489c29 commit 1196bb8

File tree

35 files changed

+235
-233
lines changed

35 files changed

+235
-233
lines changed

include/omath/3d_primitives/box.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ namespace omath::primitives
1313
[[nodiscard]]
1414
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
1515
const Vector3<float>& dir_forward, const Vector3<float>& dir_right,
16-
float ratio = 4.f);
16+
float ratio = 4.f) noexcept;
1717
}

include/omath/angle.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace omath
2020
class Angle
2121
{
2222
Type m_angle;
23-
constexpr explicit Angle(const Type& degrees)
23+
constexpr explicit Angle(const Type& degrees) noexcept
2424
{
2525
if constexpr (flags == AngleFlags::Normalized)
2626
m_angle = angles::wrap_angle(degrees, min, max);
@@ -36,68 +36,68 @@ namespace omath
3636

3737
public:
3838
[[nodiscard]]
39-
constexpr static Angle from_degrees(const Type& degrees)
39+
constexpr static Angle from_degrees(const Type& degrees) noexcept
4040
{
4141
return Angle{degrees};
4242
}
43-
constexpr Angle(): m_angle(0)
43+
constexpr Angle() noexcept: m_angle(0)
4444
{
4545
}
4646
[[nodiscard]]
47-
constexpr static Angle from_radians(const Type& degrees)
47+
constexpr static Angle from_radians(const Type& degrees) noexcept
4848
{
4949
return Angle{angles::radians_to_degrees<Type>(degrees)};
5050
}
5151

5252
[[nodiscard]]
53-
constexpr const Type& operator*() const
53+
constexpr const Type& operator*() const noexcept
5454
{
5555
return m_angle;
5656
}
5757

5858
[[nodiscard]]
59-
constexpr Type as_degrees() const
59+
constexpr Type as_degrees() const noexcept
6060
{
6161
return m_angle;
6262
}
6363

6464
[[nodiscard]]
65-
constexpr Type as_radians() const
65+
constexpr Type as_radians() const noexcept
6666
{
6767
return angles::degrees_to_radians(m_angle);
6868
}
6969

7070
[[nodiscard]]
71-
Type sin() const
71+
Type sin() const noexcept
7272
{
7373
return std::sin(as_radians());
7474
}
7575

7676
[[nodiscard]]
77-
Type cos() const
77+
Type cos() const noexcept
7878
{
7979
return std::cos(as_radians());
8080
}
8181

8282
[[nodiscard]]
83-
Type tan() const
83+
Type tan() const noexcept
8484
{
8585
return std::tan(as_radians());
8686
}
8787

8888
[[nodiscard]]
89-
Type atan() const
89+
Type atan() const noexcept
9090
{
9191
return std::atan(as_radians());
9292
}
9393

9494
[[nodiscard]]
95-
Type cot() const
95+
Type cot() const noexcept
9696
{
9797
return cos() / sin();
9898
}
9999

100-
constexpr Angle& operator+=(const Angle& other)
100+
constexpr Angle& operator+=(const Angle& other) noexcept
101101
{
102102
if constexpr (flags == AngleFlags::Normalized)
103103
m_angle = angles::wrap_angle(m_angle + other.m_angle, min, max);
@@ -114,15 +114,15 @@ namespace omath
114114
}
115115

116116
[[nodiscard]]
117-
constexpr std::partial_ordering operator<=>(const Angle& other) const = default;
117+
constexpr std::partial_ordering operator<=>(const Angle& other) const noexcept = default;
118118

119-
constexpr Angle& operator-=(const Angle& other)
119+
constexpr Angle& operator-=(const Angle& other) noexcept
120120
{
121121
return operator+=(-other);
122122
}
123123

124124
[[nodiscard]]
125-
constexpr Angle& operator+(const Angle& other)
125+
constexpr Angle& operator+(const Angle& other) noexcept
126126
{
127127
if constexpr (flags == AngleFlags::Normalized)
128128
return {angles::wrap_angle(m_angle + other.m_angle, min, max)};
@@ -137,13 +137,13 @@ namespace omath
137137
}
138138

139139
[[nodiscard]]
140-
constexpr Angle& operator-(const Angle& other)
140+
constexpr Angle& operator-(const Angle& other) noexcept
141141
{
142142
return operator+(-other);
143143
}
144144

145145
[[nodiscard]]
146-
constexpr Angle operator-() const
146+
constexpr Angle operator-() const noexcept
147147
{
148148
return Angle{-m_angle};
149149
}

include/omath/angles.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ namespace omath::angles
1010
{
1111
template<class Type>
1212
requires std::is_floating_point_v<Type>
13-
[[nodiscard]] constexpr Type radians_to_degrees(const Type& radians)
13+
[[nodiscard]] constexpr Type radians_to_degrees(const Type& radians) noexcept
1414
{
1515
return radians * (static_cast<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 degrees_to_radians(const Type& degrees)
20+
[[nodiscard]] constexpr Type degrees_to_radians(const Type& degrees) noexcept
2121
{
2222
return degrees * (std::numbers::pi_v<Type> / static_cast<Type>(180));
2323
}
2424

2525
template<class Type>
2626
requires std::is_floating_point_v<Type>
27-
[[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect)
27+
[[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect) noexcept
2828
{
2929
const auto fov_rad = degrees_to_radians(horizontal_fov);
3030

@@ -35,19 +35,19 @@ namespace omath::angles
3535

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

42-
const auto horizontal_fov
43-
= static_cast<Type>(2) * std::atan(std::tan(fov_as_radians / static_cast<Type>(2)) * aspect);
42+
const auto horizontal_fov =
43+
static_cast<Type>(2) * std::atan(std::tan(fov_as_radians / static_cast<Type>(2)) * aspect);
4444

4545
return radians_to_degrees(horizontal_fov);
4646
}
4747

4848
template<class Type>
4949
requires std::is_arithmetic_v<Type>
50-
[[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max)
50+
[[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max) noexcept
5151
{
5252
if (angle <= max && angle >= min)
5353
return angle;

include/omath/collision/line_tracer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ namespace omath::collision
1616
bool infinite_length = false;
1717

1818
[[nodiscard]]
19-
Vector3<float> direction_vector() const;
19+
Vector3<float> direction_vector() const noexcept;
2020

2121
[[nodiscard]]
22-
Vector3<float> direction_vector_normalized() const;
22+
Vector3<float> direction_vector_normalized() const noexcept;
2323
};
2424
class LineTracer
2525
{
2626
public:
2727
LineTracer() = delete;
2828

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

3232
// Realization of Möller–Trumbore intersection algorithm
3333
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
3434
[[nodiscard]]
35-
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle);
35+
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
3636
};
3737
} // namespace omath::collision

include/omath/color.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ namespace omath
2828
class Color final : public Vector4<float>
2929
{
3030
public:
31-
constexpr Color(const float r, const float g, const float b, const float a): Vector4(r, g, b, a)
31+
constexpr Color(const float r, const float g, const float b, const float a) noexcept: Vector4(r, g, b, a)
3232
{
3333
clamp(0.f, 1.f);
3434
}
3535

36-
constexpr explicit Color() = default;
36+
constexpr explicit Color() noexcept = default;
3737
[[nodiscard]]
38-
constexpr static Color from_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a)
38+
constexpr static Color from_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a) noexcept
3939
{
4040
return Color{Vector4(r, g, b, a) / 255.f};
4141
}
4242

4343
[[nodiscard]]
44-
constexpr static Color from_hsv(float hue, const float saturation, const float value)
44+
constexpr static Color from_hsv(float hue, const float saturation, const float value) noexcept
4545
{
4646
float r{}, g{}, b{};
4747

@@ -82,13 +82,13 @@ namespace omath
8282
}
8383

8484
[[nodiscard]]
85-
constexpr static Color from_hsv(const Hsv& hsv)
85+
constexpr static Color from_hsv(const Hsv& hsv) noexcept
8686
{
8787
return from_hsv(hsv.hue, hsv.saturation, hsv.value);
8888
}
8989

9090
[[nodiscard]]
91-
constexpr Hsv to_hsv() const
91+
constexpr Hsv to_hsv() const noexcept
9292
{
9393
Hsv hsv_data;
9494

@@ -120,35 +120,35 @@ namespace omath
120120
return hsv_data;
121121
}
122122

123-
constexpr explicit Color(const Vector4& vec): Vector4(vec)
123+
constexpr explicit Color(const Vector4& vec) noexcept: Vector4(vec)
124124
{
125125
clamp(0.f, 1.f);
126126
}
127-
constexpr void set_hue(const float hue)
127+
constexpr void set_hue(const float hue) noexcept
128128
{
129129
auto hsv = to_hsv();
130130
hsv.hue = hue;
131131

132132
*this = from_hsv(hsv);
133133
}
134134

135-
constexpr void set_saturation(const float saturation)
135+
constexpr void set_saturation(const float saturation) noexcept
136136
{
137137
auto hsv = to_hsv();
138138
hsv.saturation = saturation;
139139

140140
*this = from_hsv(hsv);
141141
}
142142

143-
constexpr void set_value(const float value)
143+
constexpr void set_value(const float value) noexcept
144144
{
145145
auto hsv = to_hsv();
146146
hsv.value = value;
147147

148148
*this = from_hsv(hsv);
149149
}
150150
[[nodiscard]]
151-
constexpr Color blend(const Color& other, float ratio) const
151+
constexpr Color blend(const Color& other, float ratio) const noexcept
152152
{
153153
ratio = std::clamp(ratio, 0.f, 1.f);
154154
return Color(*this * (1.f - ratio) + other * ratio);

include/omath/engines/iw_engine/camera.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace omath::iw_engine
1616
void look_at(const Vector3<float>& target) override;
1717

1818
protected:
19-
[[nodiscard]] Mat4X4 calc_view_matrix() const override;
20-
[[nodiscard]] Mat4X4 calc_projection_matrix() const override;
19+
[[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
20+
[[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
2121
};
2222
} // namespace omath::iw_engine

include/omath/engines/opengl_engine/camera.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace omath::opengl_engine
1313
Camera(const Vector3<float>& position, const ViewAngles& view_angles, const projection::ViewPort& view_port,
1414
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
1515
void look_at(const Vector3<float>& target) override;
16-
[[nodiscard]] Mat4X4 calc_view_matrix() const override;
17-
[[nodiscard]] Mat4X4 calc_projection_matrix() const override;
16+
[[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
17+
[[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
1818
};
1919
} // namespace omath::opengl_engine

include/omath/engines/opengl_engine/formulas.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
namespace omath::opengl_engine
99
{
1010
[[nodiscard]]
11-
Vector3<float> forward_vector(const ViewAngles& angles);
11+
Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
1212

1313
[[nodiscard]]
14-
Vector3<float> right_vector(const ViewAngles& angles);
14+
Vector3<float> right_vector(const ViewAngles& angles) noexcept;
1515

1616
[[nodiscard]]
17-
Vector3<float> up_vector(const ViewAngles& angles);
17+
Vector3<float> up_vector(const ViewAngles& angles) noexcept;
1818

19-
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
19+
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
2020

2121
[[nodiscard]]
22-
Mat4X4 rotation_matrix(const ViewAngles& angles);
22+
Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
2323

2424
[[nodiscard]]
25-
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far);
25+
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
2626
} // namespace omath::opengl_engine

include/omath/engines/source_engine/camera.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace omath::source_engine
1515
void look_at(const Vector3<float>& target) override;
1616

1717
protected:
18-
[[nodiscard]] Mat4X4 calc_view_matrix() const override;
19-
[[nodiscard]] Mat4X4 calc_projection_matrix() const override;
18+
[[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
19+
[[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
2020
};
2121
} // namespace omath::source_engine

include/omath/engines/source_engine/formulas.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
namespace omath::source_engine
88
{
99
[[nodiscard]]
10-
Vector3<float> forward_vector(const ViewAngles& angles);
10+
Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
1111

1212
[[nodiscard]]
13-
Mat4X4 rotation_matrix(const ViewAngles& angles);
13+
Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
1414

1515
[[nodiscard]]
16-
Vector3<float> right_vector(const ViewAngles& angles);
16+
Vector3<float> right_vector(const ViewAngles& angles) noexcept;
1717

1818
[[nodiscard]]
19-
Vector3<float> up_vector(const ViewAngles& angles);
19+
Vector3<float> up_vector(const ViewAngles& angles) noexcept;
2020

21-
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
21+
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
2222

2323
[[nodiscard]]
24-
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far);
24+
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
2525
} // namespace omath::source_engine

0 commit comments

Comments
 (0)