changed naming of engines section

This commit is contained in:
2025-03-17 05:27:00 +03:00
parent 064a31f527
commit f5c271cfa6
15 changed files with 47 additions and 47 deletions

View File

@@ -5,7 +5,7 @@
#include "Constants.hpp"
#include "omath/projection/Camera.hpp"
namespace omath::opengl
namespace omath::opengl_engine
{
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
{

View File

@@ -8,7 +8,7 @@
#include <omath/Angle.hpp>
#include <omath/ViewAngles.hpp>
namespace omath::opengl
namespace omath::opengl_engine
{
constexpr Vector3<float> kAbsUp = {0, 1, 0};
constexpr Vector3<float> kAbsRight = {1, 0, 0};

View File

@@ -5,7 +5,7 @@
#include "Constants.hpp"
namespace omath::opengl
namespace omath::opengl_engine
{
[[nodiscard]]
inline Vector3<float> ForwardVector(const ViewAngles& angles)

View File

@@ -5,7 +5,7 @@
#include "Constants.hpp"
#include "omath/projection/Camera.hpp"
namespace omath::source
namespace omath::source_engine
{
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
{

View File

@@ -7,7 +7,8 @@
#include <omath/Mat.hpp>
#include <omath/Angle.hpp>
#include <omath/ViewAngles.hpp>
namespace omath::source
namespace omath::source_engine
{
constexpr Vector3<float> kAbsUp = {0, 0, 1};
constexpr Vector3<float> kAbsRight = {0, -1, 0};

View File

@@ -4,7 +4,7 @@
#pragma once
#include "Constants.hpp"
namespace omath::source
namespace omath::source_engine
{
[[nodiscard]]
inline Vector3<float> ForwardVector(const ViewAngles& angles)

View File

@@ -1,2 +1,2 @@
add_subdirectory(Source)
add_subdirectory(OpenGL)
add_subdirectory(source_engine)
add_subdirectory(opengl_engine)

View File

@@ -1,11 +1,11 @@
//
// Created by Orange on 12/23/2024.
//
#include "omath/engines/OpenGL/Camera.hpp"
#include "omath/engines/OpenGL/Formulas.hpp"
#include "omath/engines/opengl_engine/Camera.hpp"
#include "omath/engines/opengl_engine/Formulas.hpp"
namespace omath::opengl
namespace omath::opengl_engine
{
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
@@ -25,7 +25,7 @@ namespace omath::opengl
}
Mat4x4 Camera::CalcViewMatrix() const
{
return opengl::CalcViewMatrix(m_viewAngles, m_origin);
return opengl_engine::CalcViewMatrix(m_viewAngles, m_origin);
}
Mat4x4 Camera::CalcProjectionMatrix() const
{

View File

@@ -1,11 +1,11 @@
//
// Created by Orange on 12/4/2024.
//
#include "omath/engines/Source/Camera.hpp"
#include "omath/engines/Source/Formulas.hpp"
#include "omath/engines/source_engine/Camera.hpp"
#include "omath/engines/source_engine/Formulas.hpp"
namespace omath::source
namespace omath::source_engine
{
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
@@ -26,7 +26,7 @@ namespace omath::source
Mat4x4 Camera::CalcViewMatrix() const
{
return source::CalcViewMatrix(m_viewAngles, m_origin);
return source_engine::CalcViewMatrix(m_viewAngles, m_origin);
}
Mat4x4 Camera::CalcProjectionMatrix() const

View File

@@ -4,15 +4,15 @@
#include "omath/projectile_prediction/Projectile.hpp"
#include <omath/engines/Source/Formulas.hpp>
#include <omath/engines/source_engine/Formulas.hpp>
namespace omath::projectile_prediction
{
Vector3<float> Projectile::PredictPosition(const float pitch, const float yaw, const float time, const float gravity) const
{
auto currentPos = m_origin + source::ForwardVector({source::PitchAngle::FromDegrees(-pitch),
source::YawAngle::FromDegrees(yaw),
source::RollAngle::FromDegrees(0)}) *
auto currentPos = m_origin + source_engine::ForwardVector({source_engine::PitchAngle::FromDegrees(-pitch),
source_engine::YawAngle::FromDegrees(yaw),
source_engine::RollAngle::FromDegrees(0)}) *
m_launchSpeed * time;
currentPos.z -= (gravity * m_gravityScale) * (time * time) * 0.5f;

View File

@@ -2,35 +2,35 @@
// Created by Orange on 11/23/2024.
//
#include <gtest/gtest.h>
#include <omath/engines/OpenGL/Camera.hpp>
#include <omath/engines/OpenGL/Constants.hpp>
#include <omath/engines/OpenGL/Formulas.hpp>
#include <omath/engines/opengl_engine//Camera.hpp>
#include <omath/engines/opengl_engine/Constants.hpp>
#include <omath/engines/opengl_engine/Formulas.hpp>
TEST(UnitTestOpenGL, ForwardVector)
{
const auto forward = omath::opengl::ForwardVector({});
const auto forward = omath::opengl_engine::ForwardVector({});
EXPECT_EQ(forward, omath::opengl::kAbsForward);
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
}
TEST(UnitTestOpenGL, RightVector)
{
const auto right = omath::opengl::RightVector({});
const auto right = omath::opengl_engine::RightVector({});
EXPECT_EQ(right, omath::opengl::kAbsRight);
EXPECT_EQ(right, omath::opengl_engine::kAbsRight);
}
TEST(UnitTestOpenGL, UpVector)
{
const auto up = omath::opengl::UpVector({});
EXPECT_EQ(up, omath::opengl::kAbsUp);
const auto up = omath::opengl_engine::UpVector({});
EXPECT_EQ(up, omath::opengl_engine::kAbsUp);
}
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
const auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
for (float distance = -10.f; distance > -1000.f; distance -= 0.01f)
@@ -50,7 +50,7 @@ TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
TEST(UnitTestOpenGL, CameraSetAndGetFov)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
@@ -60,7 +60,7 @@ TEST(UnitTestOpenGL, CameraSetAndGetFov)
TEST(UnitTestOpenGL, CameraSetAndGetOrigin)
{
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));

View File

@@ -2,35 +2,35 @@
// Created by Orange on 11/23/2024.
//
#include <gtest/gtest.h>
#include <omath/engines/Source/Camera.hpp>
#include <omath/engines/Source/Constants.hpp>
#include <omath/engines/Source/Formulas.hpp>
#include <omath/engines/source_engine/Camera.hpp>
#include <omath/engines/source_engine/Constants.hpp>
#include <omath/engines/source_engine/Formulas.hpp>
TEST(UnitTestSourceEngine, ForwardVector)
{
const auto forward = omath::source::ForwardVector({});
const auto forward = omath::source_engine::ForwardVector({});
EXPECT_EQ(forward, omath::source::kAbsForward);
EXPECT_EQ(forward, omath::source_engine::kAbsForward);
}
TEST(UnitTestSourceEngine, RightVector)
{
const auto right = omath::source::RightVector({});
const auto right = omath::source_engine::RightVector({});
EXPECT_EQ(right, omath::source::kAbsRight);
EXPECT_EQ(right, omath::source_engine::kAbsRight);
}
TEST(UnitTestSourceEngine, UpVector)
{
const auto up = omath::source::UpVector({});
EXPECT_EQ(up, omath::source::kAbsUp);
const auto up = omath::source_engine::UpVector({});
EXPECT_EQ(up, omath::source_engine::kAbsUp);
}
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
const auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
@@ -50,7 +50,7 @@ TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
TEST(UnitTestSourceEngine, CameraSetAndGetFov)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
@@ -60,7 +60,7 @@ TEST(UnitTestSourceEngine, CameraSetAndGetFov)
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
{
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));

View File

@@ -3,15 +3,14 @@
//
#include <complex>
#include <gtest/gtest.h>
#include <omath/Matrix.hpp>
#include <omath/engines/Source/Camera.hpp>
#include <omath/engines/source_engine/Camera.hpp>
#include <omath/projection/Camera.hpp>
#include <print>
TEST(UnitTestProjection, Projection)
{
const auto x = omath::Angle<float, 0.f, 180.f, omath::AngleFlags::Clamped>::FromDegrees(90.f);
auto cam = omath::source::Camera({0, 0, 0}, omath::source::ViewAngles{}, {1920.f, 1080.f}, x, 0.01f, 1000.f);
auto cam = omath::source_engine::Camera({0, 0, 0}, omath::source_engine::ViewAngles{}, {1920.f, 1080.f}, x, 0.01f, 1000.f);
const auto projected = cam.WorldToScreen({1000, 0, 50});
std::print("{} {} {}", projected->x, projected->y, projected->z);