From ce9da764137ef6c3c44ea76b483a4678f407e366 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 16 Dec 2024 12:31:56 +0300 Subject: [PATCH] removed useless stuff --- .gitmodules | 5 +-- extlibs/glm | 1 - include/omath/engines/OpenGL/Constants.hpp | 14 ------- include/omath/engines/OpenGL/Formulas.hpp | 4 -- include/omath/engines/OpenGL/OpenGL.hpp | 45 ---------------------- include/omath/engines/Source/Formulas.hpp | 1 - include/omath/engines/Unity/Unity.hpp | 12 ------ include/omath/prediction/Target.hpp | 2 +- source/prediction/Engine.cpp | 2 +- source/prediction/Projectile.cpp | 9 +++-- tests/engines/UnitTestSourceEngine.cpp | 2 +- tests/general/UnitTestPrediction.cpp | 5 ++- 12 files changed, 13 insertions(+), 89 deletions(-) delete mode 160000 extlibs/glm delete mode 100644 include/omath/engines/OpenGL/Constants.hpp delete mode 100644 include/omath/engines/OpenGL/Formulas.hpp delete mode 100644 include/omath/engines/OpenGL/OpenGL.hpp delete mode 100644 include/omath/engines/Unity/Unity.hpp diff --git a/.gitmodules b/.gitmodules index b6c1697..c158edf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 + url = https://github.com/google/googletest.git \ No newline at end of file diff --git a/extlibs/glm b/extlibs/glm deleted file mode 160000 index 33b4a62..0000000 --- a/extlibs/glm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 33b4a621a697a305bc3a7610d290677b96beb181 diff --git a/include/omath/engines/OpenGL/Constants.hpp b/include/omath/engines/OpenGL/Constants.hpp deleted file mode 100644 index aec3520..0000000 --- a/include/omath/engines/OpenGL/Constants.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by Orange on 12/4/2024. -// -#pragma once - -#include - - -namespace omath::opengl -{ - constexpr Vector3 kAbsUp = {0, 1, 0}; - constexpr Vector3 kAbsRight = {1, 0, 0}; - constexpr Vector3 kAbsForward = {0, 0, -1}; -} \ No newline at end of file diff --git a/include/omath/engines/OpenGL/Formulas.hpp b/include/omath/engines/OpenGL/Formulas.hpp deleted file mode 100644 index 2a50756..0000000 --- a/include/omath/engines/OpenGL/Formulas.hpp +++ /dev/null @@ -1,4 +0,0 @@ -// -// Created by Orange on 12/4/2024. -// -#pragma once \ No newline at end of file diff --git a/include/omath/engines/OpenGL/OpenGL.hpp b/include/omath/engines/OpenGL/OpenGL.hpp deleted file mode 100644 index 68edf9d..0000000 --- a/include/omath/engines/OpenGL/OpenGL.hpp +++ /dev/null @@ -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 - requires std::is_arithmetic_v - [[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(-cam_origin); - } - - template - requires std::is_arithmetic_v - [[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(1) / (aspectRatio * fovHalfTan), 0, 0, 0}, - {0, static_cast(1) / (fovHalfTan), 0, 0}, - {0, 0, -(far + near) / (far - near), -(static_cast(2) * far * near) / (far - near)}, - {0, 0, -1, 0}, - }; - } -} // namespace omath::opengl diff --git a/include/omath/engines/Source/Formulas.hpp b/include/omath/engines/Source/Formulas.hpp index 652f263..3c8a6d7 100644 --- a/include/omath/engines/Source/Formulas.hpp +++ b/include/omath/engines/Source/Formulas.hpp @@ -4,7 +4,6 @@ #pragma once #include "Constants.h" - namespace omath::source { [[nodiscard]] diff --git a/include/omath/engines/Unity/Unity.hpp b/include/omath/engines/Unity/Unity.hpp deleted file mode 100644 index ff43bb2..0000000 --- a/include/omath/engines/Unity/Unity.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// -// Created by Orange on 11/27/2024. -// - -#pragma once -#include - - -namespace omath::unity -{ - -}; diff --git a/include/omath/prediction/Target.hpp b/include/omath/prediction/Target.hpp index e44b868..a2b37ce 100644 --- a/include/omath/prediction/Target.hpp +++ b/include/omath/prediction/Target.hpp @@ -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; diff --git a/source/prediction/Engine.cpp b/source/prediction/Engine.cpp index 2bc1b1c..4452a52 100644 --- a/source/prediction/Engine.cpp +++ b/source/prediction/Engine.cpp @@ -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); } diff --git a/source/prediction/Projectile.cpp b/source/prediction/Projectile.cpp index 3c58d29..281b327 100644 --- a/source/prediction/Projectile.cpp +++ b/source/prediction/Projectile.cpp @@ -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 diff --git a/tests/engines/UnitTestSourceEngine.cpp b/tests/engines/UnitTestSourceEngine.cpp index 9ec3ae5..4d641a1 100644 --- a/tests/engines/UnitTestSourceEngine.cpp +++ b/tests/engines/UnitTestSourceEngine.cpp @@ -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); } diff --git a/tests/general/UnitTestPrediction.cpp b/tests/general/UnitTestPrediction.cpp index 64fe578..5002d39 100644 --- a/tests/general/UnitTestPrediction.cpp +++ b/tests/general/UnitTestPrediction.cpp @@ -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();