mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 15:33:26 +00:00
small fixes
This commit is contained in:
@@ -18,7 +18,7 @@ namespace omath
|
|||||||
// Constructors
|
// Constructors
|
||||||
constexpr Vector2() : x(0.f), y(0.f) {}
|
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
|
// Equality operators
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ namespace omath::prediction
|
|||||||
const auto delta = targetPosition - projectile.m_origin;
|
const auto delta = targetPosition - projectile.m_origin;
|
||||||
|
|
||||||
const auto distance2d = delta.Length2D();
|
const auto distance2d = delta.Length2D();
|
||||||
|
const auto distance2dSqr = distance2d * distance2d;
|
||||||
|
const auto launchSpeedSqr = projectile.m_launchSpeed * projectile.m_launchSpeed;
|
||||||
|
|
||||||
|
float root = launchSpeedSqr * launchSpeedSqr - bulletGravity * (bulletGravity *
|
||||||
float root = std::pow(projectile.m_launchSpeed, 4.f) - bulletGravity * (bulletGravity *
|
distance2dSqr + 2.0f * delta.z * launchSpeedSqr);
|
||||||
std::pow(distance2d, 2.f) + 2.0f * delta.z * std::pow(projectile.m_launchSpeed, 2.f));
|
|
||||||
|
|
||||||
if (root < 0.0f) [[unlikely]]
|
if (root < 0.0f) [[unlikely]]
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
Reference in New Issue
Block a user