removed useless stuff

This commit is contained in:
2024-12-16 12:31:56 +03:00
parent 2488388aa4
commit ce9da76413
12 changed files with 13 additions and 89 deletions

3
.gitmodules vendored
View File

@@ -1,6 +1,3 @@
[submodule "extlibs/googletest"]
path = extlibs/googletest
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

View File

@@ -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};
}

View File

@@ -1,4 +0,0 @@
//
// Created by Orange on 12/4/2024.
//
#pragma once

View File

@@ -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

View File

@@ -4,7 +4,6 @@
#pragma once
#include "Constants.h"
namespace omath::source
{
[[nodiscard]]

View File

@@ -1,12 +0,0 @@
//
// Created by Orange on 11/27/2024.
//
#pragma once
#include <omath/Vector3.hpp>
namespace omath::unity
{
};

View File

@@ -13,7 +13,7 @@ namespace omath::prediction
public:
[[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;

View File

@@ -58,7 +58,7 @@ namespace omath::prediction
return std::nullopt;
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);
}

View File

@@ -10,9 +10,12 @@ namespace omath::prediction
{
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;
currentPos.z -= (gravity * m_gravityScale) * std::pow(time, 2.f) * 0.5f;
auto currentPos = m_origin + source::ForwardVector({source::PitchAngle::FromDegrees(-pitch),
source::YawAngle::FromDegrees(yaw),
source::RollAngle::FromDegrees(0)}) *
m_launchSpeed * time;
currentPos.z -= (gravity * m_gravityScale) * (time * time) * 0.5f;
return currentPos;
}
}
} // namespace omath::prediction

View File

@@ -9,7 +9,7 @@
TEST(UnitTestSourceEngine, ForwardVector)
{
const auto forward = omath::source::ForwardVector({{}, {}, {}});
const auto forward = omath::source::ForwardVector({});
EXPECT_EQ(forward, omath::source::kAbsForward);
}

View File

@@ -3,8 +3,9 @@
TEST(UnitTestPrediction, PredictionTest)
{
const omath::prediction::Target target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_isAirborne = false};
const omath::prediction::Projectile proj = {.m_origin = {3,2,1}, .m_launchSpeed = 5000, .m_gravityScale= 0.4};
constexpr omath::prediction::Target target{
.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 [pitch, yaw, _] = proj.m_origin.ViewAngleTo(viewPoint.value()).AsTuple();