mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
Refactors projectile prediction engine
Refactors the projectile prediction engine by introducing an interface and making the legacy implementation more flexible. The legacy engine is updated to allow for coordinate system customization through virtual methods, enabling usage in different game environments. Also introduces vcpkg support for easier dependency management and adds boost-asio as a dependency.
This commit is contained in:
@@ -8,12 +8,12 @@
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
class ProjPredEngine
|
||||
class ProjPredEngineInterface
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
virtual std::optional<Vector3<float>> maybe_calculate_aim_point(const Projectile& projectile,
|
||||
const Target& target) const = 0;
|
||||
virtual ~ProjPredEngine() = default;
|
||||
virtual ~ProjPredEngineInterface() = default;
|
||||
};
|
||||
} // namespace omath::projectile_prediction
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
class ProjPredEngineAvx2 final : public ProjPredEngine
|
||||
class ProjPredEngineAvx2 final : public ProjPredEngineInterface
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] std::optional<Vector3<float>>
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
class ProjPredEngineLegacy final : public ProjPredEngine
|
||||
// ReSharper disable once CppClassCanBeFinal
|
||||
class ProjPredEngineLegacy : public ProjPredEngineInterface
|
||||
{
|
||||
public:
|
||||
explicit ProjPredEngineLegacy(float gravity_constant, float simulation_time_step, float maximum_simulation_time,
|
||||
@@ -48,5 +49,25 @@ namespace omath::projectile_prediction
|
||||
[[nodiscard]]
|
||||
bool is_projectile_reached_target(const Vector3<float>& target_position, const Projectile& projectile,
|
||||
float pitch, float time) const noexcept;
|
||||
|
||||
protected:
|
||||
// NOTE: Override this if you need to use engine with different coordinate system
|
||||
// Like where Z is not height coordinate
|
||||
// ===============================================================================================
|
||||
[[nodiscard]]
|
||||
virtual float calc_vector_2d_distance(const Vector3<float>& delta) const;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual float get_vector_height_coordinate(const Vector3<float>& vec) const;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual Vector3<float> calc_viewpoint_from_angles(const Projectile& projectile,
|
||||
Vector3<float> predicted_target_position,
|
||||
std::optional<float> projectile_pitch) const;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual Vector3<float> predict_projectile_position(const Projectile& projectile, float pitch, float yaw,
|
||||
float time, float gravity) const;
|
||||
// ===============================================================================================
|
||||
};
|
||||
} // namespace omath::projectile_prediction
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace omath::projectile_prediction
|
||||
class Projectile final
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
Vector3<float> predict_position(float pitch, float yaw, float time, float gravity) const noexcept;
|
||||
|
||||
Vector3<float> m_origin;
|
||||
float m_launch_speed{};
|
||||
float m_gravity_scale{};
|
||||
|
||||
Reference in New Issue
Block a user