mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
removed useless stuff
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
|||||||
[submodule "extlibs/googletest"]
|
[submodule "extlibs/googletest"]
|
||||||
path = extlibs/googletest
|
path = extlibs/googletest
|
||||||
url = https://github.com/google/googletest.git
|
url = https://github.com/google/googletest.git
|
||||||
[submodule "extlibs/glm"]
|
|
||||||
path = extlibs/glm
|
|
||||||
url = https://github.com/g-truc/glm.git
|
|
||||||
|
|||||||
Submodule extlibs/glm deleted from 33b4a621a6
@@ -1,14 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Orange on 12/4/2024.
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <omath/Vector3.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace omath::opengl
|
|
||||||
{
|
|
||||||
constexpr Vector3 kAbsUp = {0, 1, 0};
|
|
||||||
constexpr Vector3 kAbsRight = {1, 0, 0};
|
|
||||||
constexpr Vector3 kAbsForward = {0, 0, -1};
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Orange on 12/4/2024.
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Orange on 11/23/2024.
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "omath/Angle.hpp"
|
|
||||||
#include "omath/Mat.hpp"
|
|
||||||
#include "omath/Vector3.hpp"
|
|
||||||
|
|
||||||
namespace omath::opengl
|
|
||||||
{
|
|
||||||
constexpr Vector3 kAbsUp = {0, 1, 0};
|
|
||||||
constexpr Vector3 kAbsRight = {1, 0, 0};
|
|
||||||
constexpr Vector3 kAbsForward = {0, 0, -1};
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type = float>
|
|
||||||
requires std::is_arithmetic_v<Type>
|
|
||||||
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> ViewMatrix(const Vector3& forward, const Vector3& right,
|
|
||||||
const Vector3& up, const Vector3& cam_origin)
|
|
||||||
{
|
|
||||||
return Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR>
|
|
||||||
{
|
|
||||||
{right.x, right.y, right.z, 0},
|
|
||||||
{up.x, up.y, up.z, 0},
|
|
||||||
{-forward.x, -forward.y, -forward.z, 0},
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
} * MatTranslation<Type, MatStoreType::COLUMN_MAJOR>(-cam_origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
requires std::is_arithmetic_v<Type>
|
|
||||||
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR>
|
|
||||||
PerspectiveProjectionMatrix(const float fieldOfView, const Type& aspectRatio, const Type& near, const Type& far)
|
|
||||||
{
|
|
||||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2);
|
|
||||||
|
|
||||||
return {
|
|
||||||
{static_cast<Type>(1) / (aspectRatio * fovHalfTan), 0, 0, 0},
|
|
||||||
{0, static_cast<Type>(1) / (fovHalfTan), 0, 0},
|
|
||||||
{0, 0, -(far + near) / (far - near), -(static_cast<Type>(2) * far * near) / (far - near)},
|
|
||||||
{0, 0, -1, 0},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} // namespace omath::opengl
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
|
|
||||||
namespace omath::source
|
namespace omath::source
|
||||||
{
|
{
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Orange on 11/27/2024.
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <omath/Vector3.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace omath::unity
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -13,7 +13,7 @@ namespace omath::prediction
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Vector3 PredictPosition(float time, float gravity) const
|
constexpr Vector3 PredictPosition(const float time, const float gravity) const
|
||||||
{
|
{
|
||||||
auto predicted = m_origin + m_velocity * time;
|
auto predicted = m_origin + m_velocity * time;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace omath::prediction
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
root = std::sqrt(root);
|
root = std::sqrt(root);
|
||||||
const float angle = std::atan((std::pow(projectile.m_launchSpeed, 2.f) - root) / (bulletGravity * distance2d));
|
const float angle = std::atan((launchSpeedSqr - root) / (bulletGravity * distance2d));
|
||||||
|
|
||||||
return angles::RadiansToDegrees(angle);
|
return angles::RadiansToDegrees(angle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ namespace omath::prediction
|
|||||||
{
|
{
|
||||||
Vector3 Projectile::PredictPosition(const float pitch, const float yaw, const float time, const float gravity) const
|
Vector3 Projectile::PredictPosition(const float pitch, const float yaw, const float time, const float gravity) const
|
||||||
{
|
{
|
||||||
auto currentPos = m_origin + omath::source::ForwardVector({source::PitchAngle::FromDegrees(-pitch), source::YawAngle::FromDegrees(yaw), source::RollAngle::FromDegrees(0)}) * m_launchSpeed * time;
|
auto currentPos = m_origin + source::ForwardVector({source::PitchAngle::FromDegrees(-pitch),
|
||||||
currentPos.z -= (gravity * m_gravityScale) * std::pow(time, 2.f) * 0.5f;
|
source::YawAngle::FromDegrees(yaw),
|
||||||
|
source::RollAngle::FromDegrees(0)}) *
|
||||||
|
m_launchSpeed * time;
|
||||||
|
currentPos.z -= (gravity * m_gravityScale) * (time * time) * 0.5f;
|
||||||
|
|
||||||
return currentPos;
|
return currentPos;
|
||||||
}
|
}
|
||||||
}
|
} // namespace omath::prediction
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
TEST(UnitTestSourceEngine, ForwardVector)
|
TEST(UnitTestSourceEngine, ForwardVector)
|
||||||
{
|
{
|
||||||
const auto forward = omath::source::ForwardVector({{}, {}, {}});
|
const auto forward = omath::source::ForwardVector({});
|
||||||
|
|
||||||
EXPECT_EQ(forward, omath::source::kAbsForward);
|
EXPECT_EQ(forward, omath::source::kAbsForward);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
TEST(UnitTestPrediction, PredictionTest)
|
TEST(UnitTestPrediction, PredictionTest)
|
||||||
{
|
{
|
||||||
const omath::prediction::Target target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_isAirborne = false};
|
constexpr omath::prediction::Target target{
|
||||||
const omath::prediction::Projectile proj = {.m_origin = {3,2,1}, .m_launchSpeed = 5000, .m_gravityScale= 0.4};
|
.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_isAirborne = false};
|
||||||
|
constexpr omath::prediction::Projectile proj = {.m_origin = {3,2,1}, .m_launchSpeed = 5000, .m_gravityScale= 0.4};
|
||||||
const auto viewPoint = omath::prediction::Engine(400, 1.f / 1000.f, 50, 5.f).MaybeCalculateAimPoint(proj, target);
|
const auto viewPoint = omath::prediction::Engine(400, 1.f / 1000.f, 50, 5.f).MaybeCalculateAimPoint(proj, target);
|
||||||
|
|
||||||
const auto [pitch, yaw, _] = proj.m_origin.ViewAngleTo(viewPoint.value()).AsTuple();
|
const auto [pitch, yaw, _] = proj.m_origin.ViewAngleTo(viewPoint.value()).AsTuple();
|
||||||
|
|||||||
Reference in New Issue
Block a user