Skip to content

Commit e1d6c38

Browse files
authored
Merge pull request #186 from orange-cpp/feauture/camera_numeric_template
Feauture/camera numeric template
2 parents 35bb1bc + 77a8770 commit e1d6c38

30 files changed

Lines changed: 481 additions & 444 deletions

.idea/editor.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmark/benchmark_projectile_pred.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ constexpr float hit_distance_tolerance = 5.f;
1212

1313
void source_engine_projectile_prediction(benchmark::State& state)
1414
{
15-
constexpr Target target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_is_airborne = false};
16-
constexpr Projectile projectile = {.m_origin = {3, 2, 1}, .m_launch_speed = 5000, .m_gravity_scale = 0.4};
15+
constexpr Target<float> target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_is_airborne = false};
16+
constexpr Projectile<float> projectile = {.m_origin = {3, 2, 1}, .m_launch_speed = 5000.f, .m_gravity_scale = 0.4f};
1717

1818
for ([[maybe_unused]] const auto _: state)
19-
std::ignore = ProjPredEngineLegacy(400, simulation_time_step, 50, hit_distance_tolerance)
19+
std::ignore = ProjPredEngineLegacy<>(400.f, simulation_time_step, 50.f, hit_distance_tolerance)
2020
.maybe_calculate_aim_point(projectile, target);
2121
}
2222

include/omath/engines/cry_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace omath::cry_engine
1212
class PredEngineTrait final
1313
{
1414
public:
15-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
15+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1616
const float pitch, const float yaw,
1717
const float time, const float gravity) noexcept
1818
{
@@ -26,7 +26,7 @@ namespace omath::cry_engine
2626
return current_pos;
2727
}
2828
[[nodiscard]]
29-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
29+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3030
const float time, const float gravity) noexcept
3131
{
3232
auto predicted = target.m_origin + target.m_velocity * time;
@@ -49,7 +49,7 @@ namespace omath::cry_engine
4949
}
5050

5151
[[nodiscard]]
52-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
52+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5353
Vector3<float> predicted_target_position,
5454
const std::optional<float> projectile_pitch) noexcept
5555
{

include/omath/engines/frostbite_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace omath::frostbite_engine
1212
class PredEngineTrait final
1313
{
1414
public:
15-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
15+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1616
const float pitch, const float yaw,
1717
const float time, const float gravity) noexcept
1818
{
@@ -26,7 +26,7 @@ namespace omath::frostbite_engine
2626
return current_pos;
2727
}
2828
[[nodiscard]]
29-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
29+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3030
const float time, const float gravity) noexcept
3131
{
3232
auto predicted = target.m_origin + target.m_velocity * time;
@@ -49,7 +49,7 @@ namespace omath::frostbite_engine
4949
}
5050

5151
[[nodiscard]]
52-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
52+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5353
Vector3<float> predicted_target_position,
5454
const std::optional<float> projectile_pitch) noexcept
5555
{

include/omath/engines/iw_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace omath::iw_engine
1313
class PredEngineTrait final
1414
{
1515
public:
16-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
16+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1717
const float pitch, const float yaw,
1818
const float time, const float gravity) noexcept
1919
{
@@ -27,7 +27,7 @@ namespace omath::iw_engine
2727
return current_pos;
2828
}
2929
[[nodiscard]]
30-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
30+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3131
const float time, const float gravity) noexcept
3232
{
3333
auto predicted = target.m_origin + target.m_velocity * time;
@@ -50,7 +50,7 @@ namespace omath::iw_engine
5050
}
5151

5252
[[nodiscard]]
53-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
53+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5454
Vector3<float> predicted_target_position,
5555
const std::optional<float> projectile_pitch) noexcept
5656
{

include/omath/engines/opengl_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace omath::opengl_engine
1212
class PredEngineTrait final
1313
{
1414
public:
15-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
15+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1616
const float pitch, const float yaw,
1717
const float time, const float gravity) noexcept
1818
{
@@ -26,7 +26,7 @@ namespace omath::opengl_engine
2626
return current_pos;
2727
}
2828
[[nodiscard]]
29-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
29+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3030
const float time, const float gravity) noexcept
3131
{
3232
auto predicted = target.m_origin + target.m_velocity * time;
@@ -49,7 +49,7 @@ namespace omath::opengl_engine
4949
}
5050

5151
[[nodiscard]]
52-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
52+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5353
Vector3<float> predicted_target_position,
5454
const std::optional<float> projectile_pitch) noexcept
5555
{

include/omath/engines/source_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace omath::source_engine
1313
class PredEngineTrait final
1414
{
1515
public:
16-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
16+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1717
const float pitch, const float yaw,
1818
const float time, const float gravity) noexcept
1919
{
@@ -27,7 +27,7 @@ namespace omath::source_engine
2727
return current_pos;
2828
}
2929
[[nodiscard]]
30-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
30+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3131
const float time, const float gravity) noexcept
3232
{
3333
auto predicted = target.m_origin + target.m_velocity * time;
@@ -50,7 +50,7 @@ namespace omath::source_engine
5050
}
5151

5252
[[nodiscard]]
53-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
53+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5454
Vector3<float> predicted_target_position,
5555
const std::optional<float> projectile_pitch) noexcept
5656
{

include/omath/engines/unity_engine/traits/pred_engine_trait.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace omath::unity_engine
1212
class PredEngineTrait final
1313
{
1414
public:
15-
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile& projectile,
15+
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
1616
const float pitch, const float yaw,
1717
const float time, const float gravity) noexcept
1818
{
@@ -26,7 +26,7 @@ namespace omath::unity_engine
2626
return current_pos;
2727
}
2828
[[nodiscard]]
29-
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target& target,
29+
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
3030
const float time, const float gravity) noexcept
3131
{
3232
auto predicted = target.m_origin + target.m_velocity * time;
@@ -49,7 +49,7 @@ namespace omath::unity_engine
4949
}
5050

5151
[[nodiscard]]
52-
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile& projectile,
52+
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
5353
Vector3<float> predicted_target_position,
5454
const std::optional<float> projectile_pitch) noexcept
5555
{

include/omath/engines/unreal_engine/camera.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
namespace omath::unreal_engine
1111
{
12-
using Camera = projection::Camera<Mat4X4, ViewAngles, CameraTrait, NDCDepthRange::ZERO_TO_ONE>;
12+
using Camera = projection::Camera<Mat4X4, ViewAngles, CameraTrait, NDCDepthRange::ZERO_TO_ONE, {}, double>;
1313
} // namespace omath::unreal_engine

include/omath/engines/unreal_engine/constants.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
namespace omath::unreal_engine
1313
{
14-
constexpr Vector3<float> k_abs_up = {0, 0, 1};
15-
constexpr Vector3<float> k_abs_right = {0, 1, 0};
16-
constexpr Vector3<float> k_abs_forward = {1, 0, 0};
14+
constexpr Vector3<double> k_abs_up = {0, 0, 1};
15+
constexpr Vector3<double> k_abs_right = {0, 1, 0};
16+
constexpr Vector3<double> k_abs_forward = {1, 0, 0};
1717

18-
using Mat4X4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
19-
using Mat3X3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
20-
using Mat1X3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>;
21-
using PitchAngle = Angle<float, -90.f, 90.f, AngleFlags::Clamped>;
22-
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
23-
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
18+
using Mat4X4 = Mat<4, 4, double, MatStoreType::ROW_MAJOR>;
19+
using Mat3X3 = Mat<4, 4, double, MatStoreType::ROW_MAJOR>;
20+
using Mat1X3 = Mat<1, 3, double, MatStoreType::ROW_MAJOR>;
21+
using PitchAngle = Angle<double, -90., 90., AngleFlags::Clamped>;
22+
using YawAngle = Angle<double, -180., 180., AngleFlags::Normalized>;
23+
using RollAngle = Angle<double, -180., 180., AngleFlags::Normalized>;
2424

2525
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
2626
} // namespace omath::unreal_engine

0 commit comments

Comments
 (0)