small fixes

This commit is contained in:
2024-10-20 08:52:11 -07:00
parent 103c3d38e4
commit 6c85515dd0
2 changed files with 14 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ namespace omath
// Constructors
constexpr Vector2() : x(0.f), y(0.f) {}
constexpr Vector2(float x, float y) : x(x), y(y) {}
constexpr Vector2(const float x, const float y) : x(x), y(y) {}
// Equality operators
[[nodiscard]]

View File

@@ -48,10 +48,11 @@ namespace omath::prediction
const auto delta = targetPosition - projectile.m_origin;
const auto distance2d = delta.Length2D();
const auto distance2dSqr = distance2d * distance2d;
const auto launchSpeedSqr = projectile.m_launchSpeed * projectile.m_launchSpeed;
float root = std::pow(projectile.m_launchSpeed, 4.f) - bulletGravity * (bulletGravity *
std::pow(distance2d, 2.f) + 2.0f * delta.z * std::pow(projectile.m_launchSpeed, 2.f));
float root = launchSpeedSqr * launchSpeedSqr - bulletGravity * (bulletGravity *
distance2dSqr + 2.0f * delta.z * launchSpeedSqr);
if (root < 0.0f) [[unlikely]]
return std::nullopt;