mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 23:13:26 +00:00
Compare commits
85 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| baf7ee8f88 | |||
| 9fde11733f | |||
| 0069b8bd96 | |||
| 127bae0b78 | |||
| bed204a663 | |||
| 3f6ea010dc | |||
| 592a98f38c | |||
| 7873047550 | |||
| 1601f3cbc8 | |||
| 2180f8ab97 | |||
| b613ff9ef1 | |||
| 145eadfffa | |||
| 14acebad5f | |||
| 4a7a631932 | |||
| e08c22f604 | |||
| 1b47f45af9 | |||
| 466d8f7bec | |||
| 3631c5d698 | |||
| b58956efe3 | |||
| fc1e0c62b8 | |||
|
|
8e861b8a85 | ||
|
|
55085604fd | ||
|
|
7b712ed960 | ||
| 138c996393 | |||
| 0f2a858306 | |||
| ea6c1cc929 | |||
| eeb6e40909 | |||
| d72ad663cd | |||
| 3e75d32f59 | |||
| a8ce5cbaa0 | |||
| 79f76a0755 | |||
| 5773cc7798 | |||
| b6b0184523 | |||
| a797dd134a | |||
| dc43411bd2 | |||
| 8959161904 | |||
| 5d5bd215b2 | |||
| a48a257648 | |||
| ffba4e256a | |||
| d9219cdddb | |||
| 5a1014a239 | |||
| 74f2241bcf | |||
| 8977557a61 | |||
| 481d7b85df | |||
| 2b59fb6aa2 | |||
| 4f037a1952 | |||
| ef11183c3f | |||
| 326d8baaae | |||
| e46067b0b9 | |||
| 68ac7f7b3d | |||
| 17de6d407c | |||
| 59d686e252 | |||
| 713af1b772 | |||
| a8922230b3 | |||
| b8d79eb8b4 | |||
| 5acd166d8f | |||
| c7dda0ff10 | |||
| 2688d977a9 | |||
|
|
b9ac44a901 | ||
| 35658b1f6d | |||
| 8f4b61319f | |||
| 832c2ea5ef | |||
| 50c336e044 | |||
|
|
e80e22bd5b | ||
| 27576ed761 | |||
| f85243e892 | |||
| 9b6d0beb03 | |||
| ee9829af22 | |||
| cd452b0397 | |||
| 2fa0c500a7 | |||
| 0740d0778c | |||
| f5c271cfa6 | |||
| 064a31f527 | |||
| e5d0adf247 | |||
| 8fc107ec0f | |||
| 6dd72d2448 | |||
| c76f6e91b0 | |||
| d1d06c24ca | |||
| 169011e238 | |||
| 934ca0da0a | |||
| 4200ef63a6 | |||
| 58e2c3b5b7 | |||
|
|
c3202a3bc3 | ||
|
|
39ab9d065d | ||
|
|
ed372a1c78 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/cmake-build/
|
||||
/.idea
|
||||
/out
|
||||
*.DS_Store
|
||||
@@ -5,15 +5,51 @@ project(omath VERSION 1.0.1 LANGUAGES CXX)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
|
||||
option(OMATH_BUILD_TESTS "Build unit tests" ON)
|
||||
option(OMATH_BUILD_TESTS "Build unit tests" OFF)
|
||||
option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON)
|
||||
option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF)
|
||||
option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ON)
|
||||
option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF)
|
||||
option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" OFF)
|
||||
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
|
||||
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
|
||||
|
||||
|
||||
if (OMATH_BUILD_AS_SHARED_LIBRARY)
|
||||
add_library(omath SHARED source/Vector3.cpp)
|
||||
add_library(omath SHARED source/matrix.cpp)
|
||||
else()
|
||||
add_library(omath STATIC source/Matrix.cpp)
|
||||
add_library(omath STATIC source/matrix.cpp
|
||||
source/matrix.cpp)
|
||||
endif()
|
||||
|
||||
message(STATUS "Building on ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
add_library(omath::omath ALIAS omath)
|
||||
|
||||
if (OMATH_IMGUI_INTEGRATION)
|
||||
target_compile_definitions(omath PUBLIC OMATH_IMGUI_INTEGRATION)
|
||||
|
||||
# IMGUI is being linked as submodule
|
||||
if(TARGET imgui)
|
||||
target_link_libraries(omath PUBLIC imgui)
|
||||
install(TARGETS imgui
|
||||
EXPORT omathTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
else()
|
||||
# Assume that IMGUI linked via VCPKG.
|
||||
find_package(imgui CONFIG REQUIRED)
|
||||
target_link_libraries(omath PUBLIC imgui::imgui)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if (OMATH_USE_AVX2)
|
||||
target_compile_definitions(omath PUBLIC OMATH_USE_AVX2)
|
||||
endif()
|
||||
|
||||
if (OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
target_compile_definitions(omath PUBLIC OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
endif()
|
||||
|
||||
set_target_properties(omath PROPERTIES
|
||||
@@ -24,6 +60,15 @@ set_target_properties(omath PROPERTIES
|
||||
CXX_STANDARD 23
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
||||
set_target_properties(omath PROPERTIES
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(omath PRIVATE -mavx2 -mfma)
|
||||
endif()
|
||||
|
||||
target_compile_features(omath PUBLIC cxx_std_23)
|
||||
|
||||
@@ -35,6 +80,10 @@ if(OMATH_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if (OMATH_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR)
|
||||
target_compile_options(omath PRIVATE /W4 /WX)
|
||||
elseif(OMATH_THREAT_WARNING_AS_ERROR)
|
||||
|
||||
@@ -64,6 +64,38 @@
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-base",
|
||||
"hidden": true,
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
|
||||
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-debug",
|
||||
"displayName": "Darwin Debug",
|
||||
"inherits": "darwin-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-release",
|
||||
"displayName": "Darwin Release",
|
||||
"inherits": "darwin-debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
30
README.md
30
README.md
@@ -1,6 +1,6 @@
|
||||
<div align = center>
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
@@ -12,13 +12,30 @@
|
||||
Oranges's Math Library (omath) is a comprehensive, open-source library aimed at providing efficient, reliable, and versatile mathematical functions and algorithms. Developed primarily in C++, this library is designed to cater to a wide range of mathematical operations essential in scientific computing, engineering, and academic research.
|
||||
|
||||
## 👁🗨 Features
|
||||
- **Efficiency**: Optimized for performance, ensuring quick computations.
|
||||
- **Efficiency**: Optimized for performance, ensuring quick computations using AVX2.
|
||||
- **Versatility**: Includes a wide array of mathematical functions and algorithms.
|
||||
- **Ease of Use**: Simplified interface for convenient integration into various projects.
|
||||
- **Projectile Prediction**: Projectile prediction engine with O(N) algo complexity, that can power you projectile aim-bot.
|
||||
- **3D Projection**: No need to find view-projection matrix anymore you can make your own projection pipeline.
|
||||
- **Collision Detection**: Production ready code to handle collision detection by using simple interfaces.
|
||||
- **No Additional Dependencies**: No additional dependencies need to use OMath except unit test execution
|
||||
- **Ready for meta-programming**: Omath use templates for common types like Vectors, Matrixes etc, to handle all types!
|
||||
|
||||
## Supported Render Pipelines
|
||||
| ENGINE | SUPPORT |
|
||||
|----------|---------|
|
||||
| Source | ✅YES |
|
||||
| Unity | ✅YES |
|
||||
| IWEngine | ✅YES |
|
||||
| Unreal | ❌NO |
|
||||
|
||||
## Supported Operating Systems
|
||||
|
||||
| OS | SUPPORT |
|
||||
|----------------|---------|
|
||||
| Windows 10/11 | ✅YES |
|
||||
| Linux | ✅YES |
|
||||
| Darwin (MacOS) | ✅YES |
|
||||
|
||||
## ⏬ Getting Started
|
||||
### Prerequisites
|
||||
@@ -65,15 +82,18 @@ TEST(UnitTestProjection, IsPointOnScreen)
|
||||
EXPECT_TRUE(proj.has_value());
|
||||
}
|
||||
```
|
||||
|
||||
## Showcase
|
||||
<details>
|
||||
<summary>OMATH for making cheats</summary>
|
||||
<summary>OMATH for making cheats (click to open)</summary>
|
||||
|
||||
With `omath/projection` module you can achieve simple ESP hack for powered by Source/Unreal/Unity engine games, like [Apex Legends](https://store.steampowered.com/app/1172470/Apex_Legends/).
|
||||
|
||||

|
||||

|
||||
Or for InfinityWard Engine based games. Like Call of Duty Black Ops 2!
|
||||

|
||||
|
||||
Or even advanced projectile aimbot
|
||||
[Watch Video](https://youtu.be/lM_NJ1yCunw?si=5E87OrQMeypxSJ3E)
|
||||
</details>
|
||||
|
||||
## 🫵🏻 Contributing
|
||||
|
||||
4
examples/CMakeLists.txt
Normal file
4
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
project(examples)
|
||||
|
||||
add_executable(ExampleProjectionMatrixBuilder example_proj_mat_builder.cpp)
|
||||
target_link_libraries(ExampleProjectionMatrixBuilder PRIVATE omath::omath)
|
||||
40
examples/example_proj_mat_builder.cpp
Normal file
40
examples/example_proj_mat_builder.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Created by Vlad on 3/19/2025.
|
||||
//
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <print>
|
||||
#include <omath/engines/opengl_engine/formulas.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::println("OMATH Projection Matrix Builder");
|
||||
|
||||
float fov = 0;
|
||||
float near = 0;
|
||||
float far = 0;
|
||||
float viewPortWidth = 0;
|
||||
float viewPortHeight = 0;
|
||||
|
||||
std::print("Enter camera fov: ");
|
||||
std::cin >> fov;
|
||||
|
||||
std::print("Enter camera z near: ");
|
||||
std::cin >> near;
|
||||
|
||||
std::print("Enter camera z far: ");
|
||||
std::cin >> far;
|
||||
|
||||
std::print("Enter camera screen width: ");
|
||||
std::cin >> viewPortWidth;
|
||||
|
||||
std::print("Enter camera screen height: ");
|
||||
std::cin >> viewPortHeight;
|
||||
|
||||
const auto mat =
|
||||
omath::opengl_engine::CalcPerspectiveProjectionMatrix(fov, viewPortWidth / viewPortHeight, near, far);
|
||||
|
||||
std::print("{}", mat.ToString());
|
||||
};
|
||||
@@ -1,122 +0,0 @@
|
||||
//
|
||||
// Created by vlad on 2/4/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "omath/Vector3.hpp"
|
||||
#include <cstdint>
|
||||
#include "omath/Vector4.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
struct HSV
|
||||
{
|
||||
float m_hue{};
|
||||
float m_saturation{};
|
||||
float m_value{};
|
||||
};
|
||||
|
||||
|
||||
class Color final : public Vector4<float>
|
||||
{
|
||||
public:
|
||||
constexpr Color(const float r, const float g, const float b, const float a) : Vector4(r,g,b,a)
|
||||
{
|
||||
Clamp(0.f, 1.f);
|
||||
}
|
||||
|
||||
constexpr explicit Color() : Vector4()
|
||||
{
|
||||
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr static Color FromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
{
|
||||
return Color{Vector4(r, g, b, a) / 255.f};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr static Color FromHSV(float hue, float saturation, float value)
|
||||
{
|
||||
float r{}, g{}, b{};
|
||||
|
||||
hue = std::clamp(hue, 0.f, 1.f);
|
||||
|
||||
const int i = static_cast<int>(hue * 6.f);
|
||||
const float f = hue * 6 - i;
|
||||
const float p = value * (1 - saturation);
|
||||
const float q = value * (1 - f * saturation);
|
||||
const float t = value * (1 - (1 - f) * saturation);
|
||||
|
||||
switch (i % 6)
|
||||
{
|
||||
case 0: r = value, g = t, b = p; break;
|
||||
case 1: r = q, g = value, b = p; break;
|
||||
case 2: r = p, g = value, b = t; break;
|
||||
case 3: r = p, g = q, b = value; break;
|
||||
case 4: r = t, g = p, b = value; break;
|
||||
case 5: r = value, g = p, b = q; break;
|
||||
|
||||
default: return {0.f, 0.f, 0.f, 0.f};
|
||||
}
|
||||
|
||||
return {r, g, b, 1.f};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr HSV ToHSV() const
|
||||
{
|
||||
HSV hsvData;
|
||||
|
||||
const float& red = x;
|
||||
const float& green = y;
|
||||
const float& blue = z;
|
||||
|
||||
const float max = std::max({red, green, blue});
|
||||
const float min = std::min({red, green, blue});
|
||||
const float delta = max - min;
|
||||
|
||||
|
||||
if (delta == 0.f)
|
||||
hsvData.m_hue = 0.f;
|
||||
|
||||
else if (max == red)
|
||||
hsvData.m_hue = 60.f * (std::fmodf(((green - blue) / delta), 6.f));
|
||||
else if (max == green)
|
||||
hsvData.m_hue = 60.f * (((blue - red) / delta) + 2.f);
|
||||
else if (max == blue)
|
||||
hsvData.m_hue = 60.f * (((red - green) / delta) + 4.f);
|
||||
|
||||
if (hsvData.m_hue < 0.f)
|
||||
hsvData.m_hue += 360.f;
|
||||
|
||||
hsvData.m_hue /= 360.f;
|
||||
hsvData.m_saturation = max == 0.f ? 0.f : delta / max;
|
||||
hsvData.m_value = max;
|
||||
|
||||
return hsvData;
|
||||
}
|
||||
|
||||
constexpr explicit Color(const Vector4& vec) : Vector4(vec)
|
||||
{
|
||||
Clamp(0.f, 1.f);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Color Blend(const Color& other, float ratio) const
|
||||
{
|
||||
return Color( (*this * (1.f - ratio)) + (other * ratio) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr Color Red() {return {1.f, 0.f, 0.f, 1.f};}
|
||||
[[nodiscard]] static constexpr Color Green() {return {0.f, 1.f, 0.f, 1.f};}
|
||||
[[nodiscard]] static constexpr Color Blue() {return {0.f, 0.f, 1.f, 1.f};}
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Color Blend(const Color& first, const Color& second, float ratio)
|
||||
{
|
||||
return Color{first * (1.f - std::clamp(ratio, 0.f, 1.f)) + second * ratio};
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/Angles.hpp"
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include "omath/angles.hpp"
|
||||
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -15,11 +17,11 @@ namespace omath
|
||||
};
|
||||
|
||||
template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized>
|
||||
requires std::is_arithmetic_v<Type>
|
||||
requires std::is_arithmetic_v<Type>
|
||||
class Angle
|
||||
{
|
||||
Type m_angle;
|
||||
constexpr Angle(const Type& degrees)
|
||||
constexpr explicit Angle(const Type& degrees)
|
||||
{
|
||||
if constexpr (flags == AngleFlags::Normalized)
|
||||
m_angle = angles::WrapAngle(degrees, min, max);
|
||||
@@ -32,20 +34,20 @@ namespace omath
|
||||
std::unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
constexpr static Angle FromDegrees(const Type& degrees)
|
||||
{
|
||||
return {degrees};
|
||||
return Angle{degrees};
|
||||
}
|
||||
constexpr Angle() : m_angle(0)
|
||||
{
|
||||
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr static Angle FromRadians(const Type& degrees)
|
||||
{
|
||||
return {angles::RadiansToDegrees<Type>(degrees)};
|
||||
return Angle{angles::RadiansToDegrees<Type>(degrees)};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -96,7 +98,6 @@ namespace omath
|
||||
return Cos() / Sin();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Angle& operator+=(const Angle& other)
|
||||
{
|
||||
if constexpr (flags == AngleFlags::Normalized)
|
||||
@@ -116,7 +117,6 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
constexpr std::partial_ordering operator<=>(const Angle& other) const = default;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Angle& operator-=(const Angle& other)
|
||||
{
|
||||
return operator+=(-other);
|
||||
@@ -146,7 +146,7 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
constexpr Angle operator-() const
|
||||
{
|
||||
return {-m_angle};
|
||||
return Angle{-m_angle};
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace omath
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <numbers>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
namespace omath::angles
|
||||
{
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/Triangle.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
173
include/omath/color.hpp
Normal file
173
include/omath/color.hpp
Normal file
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// Created by vlad on 2/4/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "omath/vector3.hpp"
|
||||
#include "omath/vector4.hpp"
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
namespace omath
|
||||
{
|
||||
struct HSV
|
||||
{
|
||||
float hue{};
|
||||
float saturation{};
|
||||
float value{};
|
||||
};
|
||||
|
||||
|
||||
class Color final : public Vector4<float>
|
||||
{
|
||||
public:
|
||||
constexpr Color(const float r, const float g, const float b, const float a) : Vector4(r, g, b, a)
|
||||
{
|
||||
Clamp(0.f, 1.f);
|
||||
}
|
||||
|
||||
constexpr explicit Color() = default;
|
||||
[[nodiscard]]
|
||||
constexpr static Color FromRGBA(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a)
|
||||
{
|
||||
return Color{Vector4(r, g, b, a) / 255.f};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr static Color FromHSV(float hue, const float saturation, const float value)
|
||||
{
|
||||
float r{}, g{}, b{};
|
||||
|
||||
hue = std::clamp(hue, 0.f, 1.f);
|
||||
|
||||
const int i = static_cast<int>(hue * 6.f);
|
||||
const float f = hue * 6 - i;
|
||||
const float p = value * (1 - saturation);
|
||||
const float q = value * (1 - f * saturation);
|
||||
const float t = value * (1 - (1 - f) * saturation);
|
||||
|
||||
switch (i % 6)
|
||||
{
|
||||
case 0:
|
||||
r = value, g = t, b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q, g = value, b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p, g = value, b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p, g = q, b = value;
|
||||
break;
|
||||
case 4:
|
||||
r = t, g = p, b = value;
|
||||
break;
|
||||
case 5:
|
||||
r = value, g = p, b = q;
|
||||
break;
|
||||
|
||||
default:
|
||||
return {0.f, 0.f, 0.f, 0.f};
|
||||
}
|
||||
|
||||
return {r, g, b, 1.f};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr static Color FromHSV(const HSV& hsv)
|
||||
{
|
||||
return FromHSV(hsv.hue, hsv.saturation, hsv.value);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr HSV ToHSV() const
|
||||
{
|
||||
HSV hsvData;
|
||||
|
||||
const float& red = x;
|
||||
const float& green = y;
|
||||
const float& blue = z;
|
||||
|
||||
const float max = std::max({red, green, blue});
|
||||
const float min = std::min({red, green, blue});
|
||||
const float delta = max - min;
|
||||
|
||||
|
||||
if (delta == 0.f)
|
||||
hsvData.hue = 0.f;
|
||||
|
||||
else if (max == red)
|
||||
hsvData.hue = 60.f * (std::fmodf(((green - blue) / delta), 6.f));
|
||||
else if (max == green)
|
||||
hsvData.hue = 60.f * (((blue - red) / delta) + 2.f);
|
||||
else if (max == blue)
|
||||
hsvData.hue = 60.f * (((red - green) / delta) + 4.f);
|
||||
|
||||
if (hsvData.hue < 0.f)
|
||||
hsvData.hue += 360.f;
|
||||
|
||||
hsvData.hue /= 360.f;
|
||||
hsvData.saturation = max == 0.f ? 0.f : delta / max;
|
||||
hsvData.value = max;
|
||||
|
||||
return hsvData;
|
||||
}
|
||||
|
||||
constexpr explicit Color(const Vector4& vec) : Vector4(vec)
|
||||
{
|
||||
Clamp(0.f, 1.f);
|
||||
}
|
||||
constexpr void SetHue(const float hue)
|
||||
{
|
||||
auto hsv = ToHSV();
|
||||
hsv.hue = hue;
|
||||
|
||||
*this = FromHSV(hsv);
|
||||
}
|
||||
|
||||
constexpr void SetSaturation(const float saturation)
|
||||
{
|
||||
auto hsv = ToHSV();
|
||||
hsv.saturation = saturation;
|
||||
|
||||
*this = FromHSV(hsv);
|
||||
}
|
||||
|
||||
constexpr void SetValue(const float value)
|
||||
{
|
||||
auto hsv = ToHSV();
|
||||
hsv.value = value;
|
||||
|
||||
*this = FromHSV(hsv);
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr Color Blend(const Color& other, float ratio) const
|
||||
{
|
||||
ratio = std::clamp(ratio, 0.f, 1.f);
|
||||
return Color(*this * (1.f - ratio) + other * ratio);
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr Color Red()
|
||||
{
|
||||
return {1.f, 0.f, 0.f, 1.f};
|
||||
}
|
||||
[[nodiscard]] static constexpr Color Green()
|
||||
{
|
||||
return {0.f, 1.f, 0.f, 1.f};
|
||||
}
|
||||
[[nodiscard]] static constexpr Color Blue()
|
||||
{
|
||||
return {0.f, 0.f, 1.f, 1.f};
|
||||
}
|
||||
};
|
||||
} // namespace omath
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// Created by Orange on 12/23/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "Constants.hpp"
|
||||
|
||||
|
||||
namespace omath::opengl
|
||||
{
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView<float, MatStoreType::COLUMN_MAJOR>(-ForwardVector(angles), RightVector(angles), UpVector(angles), cam_origin);
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
inline Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f);
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, -(far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, -1, 0},
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
//
|
||||
// Created by Orange on 12/4/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "Constants.hpp"
|
||||
|
||||
namespace omath::source
|
||||
{
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView(ForwardVector(angles), RightVector(angles), UpVector(angles), cam_origin);
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
inline Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
// NOTE: Needed tp make thing draw normal, since source is wierd
|
||||
// and use tricky projection matrix formula.
|
||||
constexpr auto kMultiplyFactor = 0.75f;
|
||||
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f) * kMultiplyFactor;
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, (far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, 1, 0},
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace omath::source
|
||||
21
include/omath/engines/iw_engine/camera.hpp
Normal file
21
include/omath/engines/iw_engine/camera.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by Vlad on 3/17/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/engines/iw_engine/constants.hpp"
|
||||
#include "omath/projection/camera.hpp"
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||
{
|
||||
public:
|
||||
Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
|
||||
void LookAt(const Vector3<float>& target) override;
|
||||
protected:
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix() const override;
|
||||
[[nodiscard]] Mat4x4 CalcProjectionMatrix() const override;
|
||||
};
|
||||
}
|
||||
25
include/omath/engines/iw_engine/constants.hpp
Normal file
25
include/omath/engines/iw_engine/constants.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Vlad on 3/17/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <omath/vector3.hpp>
|
||||
#include <omath/mat.hpp>
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
constexpr Vector3<float> kAbsUp = {0, 0, 1};
|
||||
constexpr Vector3<float> kAbsRight = {0, -1, 0};
|
||||
constexpr Vector3<float> kAbsForward = {1, 0, 0};
|
||||
|
||||
using Mat4x4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||
using Mat3x3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||
using Mat1x3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>;
|
||||
using PitchAngle = Angle<float, -89.f, 89.f, AngleFlags::Clamped>;
|
||||
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
|
||||
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
||||
}
|
||||
26
include/omath/engines/iw_engine/formulas.hpp
Normal file
26
include/omath/engines/iw_engine/formulas.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Vlad on 3/17/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/engines/iw_engine/constants.hpp"
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
[[nodiscard]]
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> RightVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> UpVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||
} // namespace omath::iw_engine
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Orange on 12/23/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "Constants.hpp"
|
||||
#include "omath/projection/Camera.hpp"
|
||||
#include "omath/engines/opengl_engine/constants.hpp"
|
||||
#include "omath/projection/camera.hpp"
|
||||
|
||||
namespace omath::opengl
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||
{
|
||||
@@ -3,12 +3,12 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <omath/Vector3.hpp>
|
||||
#include <omath/Mat.hpp>
|
||||
#include <omath/Angle.hpp>
|
||||
#include <omath/ViewAngles.hpp>
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/mat.hpp>
|
||||
#include <omath/vector3.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
|
||||
namespace omath::opengl
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
constexpr Vector3<float> kAbsUp = {0, 1, 0};
|
||||
constexpr Vector3<float> kAbsRight = {1, 0, 0};
|
||||
@@ -17,9 +17,10 @@ namespace omath::opengl
|
||||
using Mat4x4 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
||||
using Mat3x3 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
||||
using Mat1x3 = Mat<1, 3, float, MatStoreType::COLUMN_MAJOR>;
|
||||
using PitchAngle = Angle<float, 0.f, 180.f, AngleFlags::Clamped>;
|
||||
using YawAngle = Angle<float, 0.f, 360.f, AngleFlags::Normalized>;
|
||||
using RollAngle = Angle<float, 0.f, 360.f, AngleFlags::Normalized>;
|
||||
using PitchAngle = Angle<float, -90.f, 90.f, AngleFlags::Clamped>;
|
||||
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
|
||||
|
||||
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
||||
}
|
||||
26
include/omath/engines/opengl_engine/formulas.hpp
Normal file
26
include/omath/engines/opengl_engine/formulas.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Orange on 12/23/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "omath/engines/opengl_engine/constants.hpp"
|
||||
|
||||
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
[[nodiscard]]
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> RightVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> UpVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||
} // namespace omath::opengl_engine
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Orange on 12/4/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "Constants.hpp"
|
||||
#include "omath/projection/Camera.hpp"
|
||||
#include "omath/engines/source_engine/constants.hpp"
|
||||
#include "omath/projection/camera.hpp"
|
||||
|
||||
namespace omath::source
|
||||
namespace omath::source_engine
|
||||
{
|
||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||
{
|
||||
@@ -13,6 +13,7 @@ namespace omath::source
|
||||
Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
|
||||
void LookAt(const Vector3<float>& target) override;
|
||||
protected:
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix() const override;
|
||||
[[nodiscard]] Mat4x4 CalcProjectionMatrix() const override;
|
||||
};
|
||||
@@ -3,11 +3,12 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <omath/Vector3.hpp>
|
||||
#include <omath/Mat.hpp>
|
||||
#include <omath/Angle.hpp>
|
||||
#include <omath/ViewAngles.hpp>
|
||||
namespace omath::source
|
||||
#include <omath/vector3.hpp>
|
||||
#include <omath/mat.hpp>
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
|
||||
namespace omath::source_engine
|
||||
{
|
||||
constexpr Vector3<float> kAbsUp = {0, 0, 1};
|
||||
constexpr Vector3<float> kAbsRight = {0, -1, 0};
|
||||
25
include/omath/engines/source_engine/formulas.hpp
Normal file
25
include/omath/engines/source_engine/formulas.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Orange on 12/4/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "omath/engines/source_engine/constants.hpp"
|
||||
|
||||
namespace omath::source_engine
|
||||
{
|
||||
[[nodiscard]]
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> RightVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> UpVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||
} // namespace omath::source
|
||||
21
include/omath/engines/unity_engine/camera.hpp
Normal file
21
include/omath/engines/unity_engine/camera.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by Vlad on 3/22/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/engines/unity_engine/constants.hpp"
|
||||
#include "omath/projection/camera.hpp"
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||
{
|
||||
public:
|
||||
Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
|
||||
void LookAt(const Vector3<float>& target) override;
|
||||
protected:
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix() const override;
|
||||
[[nodiscard]] Mat4x4 CalcProjectionMatrix() const override;
|
||||
};
|
||||
}
|
||||
26
include/omath/engines/unity_engine/constants.hpp
Normal file
26
include/omath/engines/unity_engine/constants.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Vlad on 3/22/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <omath/vector3.hpp>
|
||||
#include <omath/mat.hpp>
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
constexpr Vector3<float> kAbsUp = {0, 1, 0};
|
||||
constexpr Vector3<float> kAbsRight = {1, 0, 0};
|
||||
constexpr Vector3<float> kAbsForward = {0, 0, 1};
|
||||
|
||||
using Mat4x4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||
using Mat3x3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||
using Mat1x3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>;
|
||||
using PitchAngle = Angle<float, -90.f, 90.f, AngleFlags::Clamped>;
|
||||
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||
|
||||
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
||||
} // namespace omath::source
|
||||
26
include/omath/engines/unity_engine/formulas.hpp
Normal file
26
include/omath/engines/unity_engine/formulas.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Vlad on 3/22/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/engines/unity_engine/constants.hpp"
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
[[nodiscard]]
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> RightVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> UpVector(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||
} // namespace omath::source
|
||||
@@ -4,10 +4,22 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include "Vector3.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
#include <numeric>
|
||||
|
||||
|
||||
#ifdef near
|
||||
#undef near
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef far
|
||||
#undef far
|
||||
#endif
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -34,11 +46,13 @@ namespace omath
|
||||
class Mat final
|
||||
{
|
||||
public:
|
||||
constexpr Mat()
|
||||
constexpr Mat() noexcept
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
constexpr static MatStoreType GetStoreOrdering()
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr static MatStoreType GetStoreOrdering() noexcept
|
||||
{
|
||||
return StoreType;
|
||||
}
|
||||
@@ -72,11 +86,18 @@ namespace omath
|
||||
m_data = other.m_data;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Type& operator[](const size_t row, const size_t col)
|
||||
{
|
||||
return At(row, col);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Type& operator[](const size_t row, const size_t col) const
|
||||
{
|
||||
return At(row, col);
|
||||
}
|
||||
|
||||
constexpr Mat(Mat&& other) noexcept
|
||||
{
|
||||
m_data = std::move(other.m_data);
|
||||
@@ -100,11 +121,13 @@ namespace omath
|
||||
return {Rows, Columns};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const
|
||||
[[nodiscard]]
|
||||
constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const
|
||||
{
|
||||
#if !defined(NDEBUG) && defined(OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
if (rowIndex >= Rows || columnIndex >= Columns)
|
||||
throw std::out_of_range("Index out of range");
|
||||
|
||||
#endif
|
||||
if constexpr (StoreType == MatStoreType::ROW_MAJOR)
|
||||
return m_data[rowIndex * Columns + columnIndex];
|
||||
|
||||
@@ -126,12 +149,7 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
constexpr Type Sum() const noexcept
|
||||
{
|
||||
Type sum = 0;
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
sum += At(i, j);
|
||||
|
||||
return sum;
|
||||
return std::accumulate(m_data.begin(), m_data.end(), Type(0));
|
||||
}
|
||||
|
||||
constexpr void Clear() noexcept
|
||||
@@ -146,6 +164,7 @@ namespace omath
|
||||
|
||||
// Operator overloading for multiplication with another Mat
|
||||
template<size_t OtherColumns>
|
||||
[[nodiscard]]
|
||||
constexpr Mat<Rows, OtherColumns, Type, StoreType>
|
||||
operator*(const Mat<Columns, OtherColumns, Type, StoreType>& other) const
|
||||
{
|
||||
@@ -164,9 +183,7 @@ namespace omath
|
||||
|
||||
constexpr Mat& operator*=(const Type& f) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
At(i, j) *= f;
|
||||
std::ranges::for_each(m_data, [&f](auto& val) {val *= f;});
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -177,46 +194,40 @@ namespace omath
|
||||
return *this = *this * other;
|
||||
}
|
||||
|
||||
constexpr Mat operator*(const Type& f) const noexcept
|
||||
[[nodiscard]]
|
||||
constexpr Mat operator*(const Type& value) const noexcept
|
||||
{
|
||||
Mat result(*this);
|
||||
result *= f;
|
||||
result *= value;
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr Mat& operator/=(const Type& f) noexcept
|
||||
constexpr Mat& operator/=(const Type& value) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
At(i, j) /= f;
|
||||
std::ranges::for_each(m_data, [&value](auto& val) {val /= value;});
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Mat operator/(const Type& f) const noexcept
|
||||
[[nodiscard]]
|
||||
constexpr Mat operator/(const Type& value) const noexcept
|
||||
{
|
||||
Mat result(*this);
|
||||
result /= f;
|
||||
result /= value;
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr Mat& operator=(const Mat& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
At(i, j) = other.At(i, j);
|
||||
if (this != &other)
|
||||
m_data = other.m_data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Mat& operator=(Mat&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
At(i, j) = other.At(i, j);
|
||||
if (this != &other)
|
||||
m_data = std::move(other.m_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -240,7 +251,7 @@ namespace omath
|
||||
if constexpr (Rows == 1)
|
||||
return At(0, 0);
|
||||
|
||||
else if constexpr (Rows == 2)
|
||||
if constexpr (Rows == 2)
|
||||
return At(0, 0) * At(1, 1) - At(0, 1) * At(1, 0);
|
||||
else
|
||||
{
|
||||
@@ -290,15 +301,20 @@ namespace omath
|
||||
std::string ToString() const noexcept
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[[";
|
||||
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
oss << " [";
|
||||
|
||||
for (size_t j = 0; j < Columns; ++j)
|
||||
{
|
||||
oss << At(i, j);
|
||||
oss << std::setw(9) << std::fixed << std::setprecision(3) << At(i, j);
|
||||
if (j != Columns - 1)
|
||||
oss << ' ';
|
||||
oss << ", ";
|
||||
}
|
||||
oss << '\n';
|
||||
oss << (i == Rows - 1 ? "]]" : "]\n");
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
@@ -412,10 +428,29 @@ namespace omath
|
||||
} * MatTranslation<Type, St>(-cameraOrigin);
|
||||
}
|
||||
|
||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class ViewAngles>
|
||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
||||
[[nodiscard]]
|
||||
Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept
|
||||
Mat<4, 4, Type, St> MatPerspectiveLeftHanded(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far) noexcept
|
||||
{
|
||||
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f);
|
||||
|
||||
return {{1.f / (aspectRatio * fovHalfTan), 0.f, 0.f, 0.f},
|
||||
{0.f, 1.f / fovHalfTan, 0.f, 0.f},
|
||||
{0.f, 0.f, (far + near) / (far - near), -(2.f * near * far) / (far - near)},
|
||||
{0.f, 0.f, 1.f, 0.f}};
|
||||
}
|
||||
|
||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
||||
[[nodiscard]]
|
||||
Mat<4, 4, Type, St> MatPerspectiveRightHanded(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far) noexcept
|
||||
{
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f);
|
||||
|
||||
return {{1.f / (aspectRatio * fovHalfTan), 0.f, 0.f, 0.f},
|
||||
{0.f, 1.f / fovHalfTan, 0.f, 0.f},
|
||||
{0.f, 0.f, -(far + near) / (far - near), -(2.f * near * far) / (far - near)},
|
||||
{0.f, 0.f, -1.f, 0.f}};
|
||||
}
|
||||
} // namespace omath
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Vector3.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "NavigationMesh.hpp"
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/pathfinding/navigation_mesh.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
@@ -4,35 +4,35 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "omath/Vector3.hpp"
|
||||
#include <expected>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
|
||||
enum Error
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
|
||||
class NavigationMesh final
|
||||
{
|
||||
public:
|
||||
|
||||
[[nodiscard]]
|
||||
std::expected<Vector3<float>, std::string> GetClosestVertex(const Vector3<float>& point) const;
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
const std::vector<Vector3<float>>& GetNeighbors(const Vector3<float>& vertex) const;
|
||||
|
||||
[[nodiscard]]
|
||||
bool Empty() const;
|
||||
|
||||
[[nodiscard]] std::vector<uint8_t> Serialize() const;
|
||||
|
||||
void Deserialize(const std::vector<uint8_t>& raw);
|
||||
|
||||
std::unordered_map<Vector3<float>, std::vector<Vector3<float>>> m_verTextMap;
|
||||
};
|
||||
}
|
||||
} // namespace omath::pathfinding
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Vlad on 2/23/2025.
|
||||
//
|
||||
#pragma once
|
||||
#include "Projectile.hpp"
|
||||
#include "Target.hpp"
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/projectile_prediction/projectile.hpp"
|
||||
#include "omath/projectile_prediction/target.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Vlad on 2/23/2025.
|
||||
//
|
||||
#pragma once
|
||||
#include "ProjPredEngine.hpp"
|
||||
#include "omath/projectile_prediction/proj_pred_engine.hpp"
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
@@ -5,10 +5,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/projectile_prediction/ProjPredEngine.hpp"
|
||||
#include "omath/projectile_prediction/Projectile.hpp"
|
||||
#include "omath/projectile_prediction/Target.hpp"
|
||||
#include "omath/projectile_prediction/proj_pred_engine.hpp"
|
||||
#include "omath/projectile_prediction/projectile.hpp"
|
||||
#include "omath/projectile_prediction/target.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
@@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <expected>
|
||||
#include <omath/Mat.hpp>
|
||||
#include <omath/Vector3.hpp>
|
||||
#include "ErrorCodes.hpp"
|
||||
#include <omath/Angle.hpp>
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/mat.hpp>
|
||||
#include <omath/vector3.hpp>
|
||||
#include <type_traits>
|
||||
#include "omath/projection/error_codes.hpp"
|
||||
|
||||
namespace omath::projection
|
||||
{
|
||||
@@ -36,9 +36,9 @@ namespace omath::projection
|
||||
m_viewPort(viewPort), m_fieldOfView(fov), m_farPlaneDistance(far), m_nearPlaneDistance(near),
|
||||
m_viewAngles(viewAngles), m_origin(position)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void LookAt(const Vector3<float>& target) = 0;
|
||||
|
||||
[[nodiscard]] virtual Mat4x4Type CalcViewMatrix() const = 0;
|
||||
@@ -50,40 +50,43 @@ namespace omath::projection
|
||||
return CalcProjectionMatrix() * CalcViewMatrix();
|
||||
}
|
||||
|
||||
public:
|
||||
[[nodiscard]] const Mat4x4Type& GetViewProjectionMatrix() const
|
||||
{
|
||||
if (!m_viewProjectionMatrix.has_value())
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
|
||||
return m_viewProjectionMatrix.value();
|
||||
}
|
||||
|
||||
void SetFieldOfView(const FieldOfView& fov)
|
||||
{
|
||||
m_fieldOfView = fov;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
void SetNearPlane(const float near)
|
||||
{
|
||||
m_nearPlaneDistance = near;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
void SetFarPlane(const float far)
|
||||
{
|
||||
m_farPlaneDistance = far;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
void SetViewAngles(const ViewAnglesType& viewAngles)
|
||||
{
|
||||
m_viewAngles = viewAngles;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
void SetOrigin(const Vector3<float>& origin)
|
||||
{
|
||||
m_origin = origin;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
void SetViewPort(const ViewPort& viewPort)
|
||||
{
|
||||
m_viewPort = viewPort;
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
}
|
||||
|
||||
[[nodiscard]] const FieldOfView& GetFieldOfView() const
|
||||
@@ -113,10 +116,19 @@ namespace omath::projection
|
||||
|
||||
[[nodiscard]] std::expected<Vector3<float>, Error> WorldToScreen(const Vector3<float>& worldPosition) const
|
||||
{
|
||||
if (!m_viewProjectionMatrix.has_value())
|
||||
m_viewProjectionMatrix = CalcViewProjectionMatrix();
|
||||
auto normalizedCords = WorldToViewPort(worldPosition);
|
||||
|
||||
auto projected = m_viewProjectionMatrix.value() * MatColumnFromVector<float, Mat4x4Type::GetStoreOrdering()>(worldPosition);
|
||||
if (!normalizedCords.has_value())
|
||||
return std::unexpected{normalizedCords.error()};
|
||||
|
||||
|
||||
return NdcToScreenPosition(*normalizedCords);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::expected<Vector3<float>, Error> WorldToViewPort(const Vector3<float>& worldPosition) const
|
||||
{
|
||||
auto projected = GetViewProjectionMatrix() *
|
||||
MatColumnFromVector<float, Mat4x4Type::GetStoreOrdering()>(worldPosition);
|
||||
|
||||
if (projected.At(3, 0) == 0.0f)
|
||||
return std::unexpected(Error::WORLD_POSITION_IS_OUT_OF_SCREEN_BOUNDS);
|
||||
@@ -126,10 +138,7 @@ namespace omath::projection
|
||||
if (IsNdcOutOfBounds(projected))
|
||||
return std::unexpected(Error::WORLD_POSITION_IS_OUT_OF_SCREEN_BOUNDS);
|
||||
|
||||
const auto screenPositionX = (projected.At(0,0)+1.f) / 2.f * m_viewPort.m_width;
|
||||
const auto screenPositionY = (-projected.At(1,0)+1) / 2.f * m_viewPort.m_height;
|
||||
|
||||
return Vector3{screenPositionX, screenPositionY, projected.At(2,0)};
|
||||
return Vector3<float>{projected.At(0, 0), projected.At(1, 0), projected.At(2, 0)};
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -150,7 +159,17 @@ namespace omath::projection
|
||||
[[nodiscard]]
|
||||
constexpr static bool IsNdcOutOfBounds(const Type& ndc)
|
||||
{
|
||||
return std::ranges::any_of( ndc.RawArray(), [](const auto& val) { return val < -1 || val > 1; });
|
||||
return std::ranges::any_of(ndc.RawArray(), [](const auto& val) { return val < -1 || val > 1; });
|
||||
}
|
||||
|
||||
[[nodiscard]] Vector3<float> NdcToScreenPosition(const Vector3<float>& ndc) const
|
||||
{
|
||||
return
|
||||
{
|
||||
(ndc.x + 1.f) / 2.f * m_viewPort.m_width,
|
||||
(1.f - ndc.y) / 2.f * m_viewPort.m_height,
|
||||
ndc.z
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace omath::projection
|
||||
@@ -2,10 +2,20 @@
|
||||
// Created by Orange on 11/13/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
/*
|
||||
|\
|
||||
| \
|
||||
a | \ hypot
|
||||
| \
|
||||
-----
|
||||
b
|
||||
*/
|
||||
|
||||
|
||||
template<class Vector>
|
||||
class Triangle final
|
||||
{
|
||||
@@ -3,13 +3,19 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <tuple>
|
||||
#include <cmath>
|
||||
#include <tuple>
|
||||
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
#include <imgui.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace omath
|
||||
{
|
||||
|
||||
template<class Type> requires std::is_arithmetic_v<Type>
|
||||
template<class Type>
|
||||
requires std::is_arithmetic_v<Type>
|
||||
class Vector2
|
||||
{
|
||||
public:
|
||||
@@ -19,7 +25,9 @@ namespace omath
|
||||
// Constructors
|
||||
constexpr Vector2() = default;
|
||||
|
||||
constexpr Vector2(const Type& x, const Type& y) : x(x), y(y) {}
|
||||
constexpr Vector2(const Type& x, const Type& y) : x(x), y(y)
|
||||
{
|
||||
}
|
||||
|
||||
// Equality operators
|
||||
[[nodiscard]]
|
||||
@@ -116,9 +124,9 @@ namespace omath
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
[[nodiscard]] constexpr Type& Length() const
|
||||
[[nodiscard]] constexpr Type Length() const
|
||||
{
|
||||
return std::hypot(x, y);
|
||||
return std::hypot(this->x, this->y);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Vector2 Normalized() const
|
||||
@@ -145,23 +153,12 @@ namespace omath
|
||||
|
||||
constexpr Vector2& Abs()
|
||||
{
|
||||
//FIXME: Replace with std::abs, if it will become constexprable
|
||||
// FIXME: Replace with std::abs, if it will become constexprable
|
||||
x = x < 0 ? -x : x;
|
||||
y = y < 0 ? -y : y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class type>
|
||||
[[nodiscard]] constexpr const type& As() const
|
||||
{
|
||||
return *reinterpret_cast<const type*>(this);
|
||||
}
|
||||
template<class type>
|
||||
[[nodiscard]] constexpr type& As()
|
||||
{
|
||||
return *reinterpret_cast<type*>(this);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Vector2 operator-() const
|
||||
{
|
||||
return {-x, -y};
|
||||
@@ -188,7 +185,7 @@ namespace omath
|
||||
return {x / fl, y / fl};
|
||||
}
|
||||
|
||||
// Sum of elements
|
||||
// Sum of elements
|
||||
[[nodiscard]] constexpr Type Sum() const
|
||||
{
|
||||
return x + y;
|
||||
@@ -199,5 +196,13 @@ namespace omath
|
||||
{
|
||||
return std::make_tuple(x, y);
|
||||
}
|
||||
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
[[nodiscard]]
|
||||
ImVec2 ToImVec2() const
|
||||
{
|
||||
return {static_cast<float>(this->x), static_cast<float>(this->y)};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
} // namespace omath
|
||||
@@ -5,12 +5,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "omath/Vector2.hpp"
|
||||
#include "omath/Angle.hpp"
|
||||
#include <expected>
|
||||
#include <immintrin.h>
|
||||
|
||||
#include <functional>
|
||||
#include "omath/angle.hpp"
|
||||
#include "omath/vector2.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -110,45 +108,45 @@ namespace omath
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float DistToSqr(const Vector3& vOther) const
|
||||
[[nodiscard]] constexpr Type DistToSqr(const Vector3& vOther) const
|
||||
{
|
||||
return (*this - vOther).LengthSqr();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float Dot(const Vector3& vOther) const
|
||||
[[nodiscard]] constexpr Type Dot(const Vector3& vOther) const
|
||||
{
|
||||
return Vector2<Type>::Dot(vOther) + z * vOther.z;
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
[[nodiscard]] constexpr float Length() const
|
||||
[[nodiscard]] constexpr Type Length() const
|
||||
{
|
||||
return std::hypot(x, y, z);
|
||||
return std::hypot(this->x, this->y, z);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float Length2D() const
|
||||
[[nodiscard]] constexpr Type Length2D() const
|
||||
{
|
||||
return Vector2::Length();
|
||||
return Vector2<Type>::Length();
|
||||
}
|
||||
[[nodiscard]] float DistTo(const Vector3& vOther) const
|
||||
[[nodiscard]] Type DistTo(const Vector3& vOther) const
|
||||
{
|
||||
return (*this - vOther).Length();
|
||||
}
|
||||
[[nodiscard]] constexpr Vector3 Normalized() const
|
||||
{
|
||||
const float length = this->Length();
|
||||
const Type length = this->Length();
|
||||
|
||||
return length != 0 ? *this / length : *this;
|
||||
}
|
||||
#else
|
||||
[[nodiscard]] float Length() const
|
||||
[[nodiscard]] Type Length() const
|
||||
{
|
||||
return std::hypot(this->x, this->y, z);
|
||||
}
|
||||
|
||||
[[nodiscard]] Vector3 Normalized() const
|
||||
{
|
||||
const float length = this->Length();
|
||||
const Type length = this->Length();
|
||||
|
||||
return length != 0 ? *this / length : *this;
|
||||
}
|
||||
@@ -158,14 +156,14 @@ namespace omath
|
||||
return Vector2<Type>::Length();
|
||||
}
|
||||
|
||||
[[nodiscard]] float DistTo(const Vector3& vOther) const
|
||||
[[nodiscard]] Type DistTo(const Vector3& vOther) const
|
||||
{
|
||||
return (*this - vOther).Length();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
[[nodiscard]] constexpr float LengthSqr() const
|
||||
[[nodiscard]] constexpr Type LengthSqr() const
|
||||
{
|
||||
return Vector2<Type>::LengthSqr() + z * z;
|
||||
}
|
||||
@@ -214,7 +212,7 @@ namespace omath
|
||||
this->x * v.y - this->y * v.x
|
||||
};
|
||||
}
|
||||
[[nodiscard]] constexpr float Sum() const
|
||||
[[nodiscard]] constexpr Type Sum() const
|
||||
{
|
||||
return Sum2D() + z;
|
||||
}
|
||||
@@ -238,12 +236,12 @@ namespace omath
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float Sum2D() const
|
||||
[[nodiscard]] constexpr Type Sum2D() const
|
||||
{
|
||||
return Vector2<Type>::Sum();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::tuple<float, float, float> AsTuple() const
|
||||
[[nodiscard]] constexpr std::tuple<Type, Type, Type> AsTuple() const
|
||||
{
|
||||
return std::make_tuple(this->x, this->y, z);
|
||||
}
|
||||
@@ -3,8 +3,9 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <omath/Vector3.hpp>
|
||||
#include <algorithm>
|
||||
#include <omath/vector3.hpp>
|
||||
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -81,7 +82,7 @@ namespace omath
|
||||
return Vector3<Type>::LengthSqr() + w * w;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float Dot(const Vector4& vOther) const
|
||||
[[nodiscard]] constexpr Type Dot(const Vector4& vOther) const
|
||||
{
|
||||
return Vector3<Type>::Dot(vOther) + w * vOther.w;
|
||||
}
|
||||
@@ -98,7 +99,7 @@ namespace omath
|
||||
|
||||
return *this;
|
||||
}
|
||||
constexpr Vector4& Clamp(const float min, const float max)
|
||||
constexpr Vector4& Clamp(const Type& min, const Type& max)
|
||||
{
|
||||
this->x = std::clamp(this->x, min, max);
|
||||
this->y = std::clamp(this->y, min, max);
|
||||
@@ -126,7 +127,7 @@ namespace omath
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Vector4 operator*(const float scalar) const
|
||||
constexpr Vector4 operator*(const Type& scalar) const
|
||||
{
|
||||
return {this->x * scalar, this->y * scalar, this->z * scalar, w * scalar};
|
||||
}
|
||||
@@ -138,7 +139,7 @@ namespace omath
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Vector4 operator/(const float scalar) const
|
||||
constexpr Vector4 operator/(const Type& scalar) const
|
||||
{
|
||||
return {this->x / scalar, this->y / scalar, this->z / scalar, w / scalar};
|
||||
}
|
||||
@@ -154,5 +155,19 @@ namespace omath
|
||||
{
|
||||
return Vector3<Type>::Sum() + w;
|
||||
}
|
||||
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
[[nodiscard]]
|
||||
ImVec4 ToImVec4() const
|
||||
{
|
||||
return
|
||||
{
|
||||
static_cast<float>(this->x),
|
||||
static_cast<float>(this->y),
|
||||
static_cast<float>(this->z),
|
||||
static_cast<float>(w),
|
||||
};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
target_sources(omath PRIVATE
|
||||
Matrix.cpp
|
||||
matrix.cpp
|
||||
color.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
target_sources(omath PRIVATE
|
||||
LineTracer.cpp
|
||||
line_tracer.cpp
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by Orange on 11/13/2024.
|
||||
//
|
||||
#include "omath/collision/LineTracer.hpp"
|
||||
#include "omath/collision/line_tracer.hpp"
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by vlad on 2/4/24.
|
||||
//
|
||||
|
||||
#include "omath/Color.hpp"
|
||||
#include "omath/color.hpp"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
add_subdirectory(Source)
|
||||
add_subdirectory(OpenGL)
|
||||
add_subdirectory(source_engine)
|
||||
add_subdirectory(opengl_engine)
|
||||
add_subdirectory(iw_engine)
|
||||
add_subdirectory(unity_engine)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE Camera.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE Camera.cpp)
|
||||
1
source/engines/iw_engine/CMakeLists.txt
Normal file
1
source/engines/iw_engine/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
34
source/engines/iw_engine/camera.cpp
Normal file
34
source/engines/iw_engine/camera.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Created by Vlad on 3/17/2025.
|
||||
//
|
||||
#include "omath/engines/iw_engine/camera.hpp"
|
||||
#include "omath/engines/iw_engine/formulas.hpp"
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
|
||||
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, const float near, const float far) :
|
||||
projection::Camera<Mat4x4, ViewAngles>(position, viewAngles, viewPort, fov, near, far)
|
||||
{
|
||||
}
|
||||
void Camera::LookAt([[maybe_unused]] const Vector3<float>& target)
|
||||
{
|
||||
const float distance = m_origin.DistTo(target);
|
||||
const auto delta = target - m_origin;
|
||||
|
||||
|
||||
m_viewAngles.pitch = PitchAngle::FromRadians(std::asin(delta.z / distance));
|
||||
m_viewAngles.yaw = -YawAngle::FromRadians(std::atan2(delta.y, delta.x));
|
||||
m_viewAngles.roll = RollAngle::FromRadians(0.f);
|
||||
}
|
||||
Mat4x4 Camera::CalcViewMatrix() const
|
||||
{
|
||||
return iw_engine::CalcViewMatrix(m_viewAngles, m_origin);
|
||||
}
|
||||
Mat4x4 Camera::CalcProjectionMatrix() const
|
||||
{
|
||||
return CalcPerspectiveProjectionMatrix(m_fieldOfView.AsDegrees(), m_viewPort.AspectRatio(), m_nearPlaneDistance,
|
||||
m_farPlaneDistance);
|
||||
}
|
||||
} // namespace omath::openg
|
||||
54
source/engines/iw_engine/formulas.cpp
Normal file
54
source/engines/iw_engine/formulas.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Created by Vlad on 3/19/2025.
|
||||
//
|
||||
#include "omath/engines/iw_engine/formulas.hpp"
|
||||
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||
{
|
||||
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
||||
}
|
||||
|
||||
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView(ForwardVector(angles), RightVector(angles), UpVector(angles), cam_origin);
|
||||
}
|
||||
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
// NOTE: Need magic number to fix fov calculation, since IW engine inherit Quake proj matrix calculation
|
||||
constexpr auto kMultiplyFactor = 0.75f;
|
||||
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f) * kMultiplyFactor;
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, (far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, 1, 0},
|
||||
};
|
||||
};
|
||||
} // namespace omath::iw_engine
|
||||
1
source/engines/opengl_engine/CMakeLists.txt
Normal file
1
source/engines/opengl_engine/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
@@ -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
|
||||
{
|
||||
51
source/engines/opengl_engine/formulas.cpp
Normal file
51
source/engines/opengl_engine/formulas.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by Vlad on 3/19/2025.
|
||||
//
|
||||
#include "omath/engines/opengl_engine/formulas.hpp"
|
||||
|
||||
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView<float, MatStoreType::COLUMN_MAJOR>(-ForwardVector(angles), RightVector(angles),
|
||||
UpVector(angles), cam_origin);
|
||||
}
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||
{
|
||||
return MatRotationAxisZ<float, MatStoreType::COLUMN_MAJOR>(angles.roll) *
|
||||
MatRotationAxisY<float, MatStoreType::COLUMN_MAJOR>(-angles.yaw) *
|
||||
MatRotationAxisX<float, MatStoreType::COLUMN_MAJOR>(-angles.pitch);
|
||||
}
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f);
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, -(far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, -1, 0},
|
||||
};
|
||||
}
|
||||
} // namespace omath::opengl_engine
|
||||
1
source/engines/source_engine/CMakeLists.txt
Normal file
1
source/engines/source_engine/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
@@ -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
|
||||
54
source/engines/source_engine/formulas.cpp
Normal file
54
source/engines/source_engine/formulas.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Created by Vlad on 3/19/2025.
|
||||
//
|
||||
#include <omath/engines/source_engine/formulas.hpp>
|
||||
|
||||
|
||||
namespace omath::source_engine
|
||||
{
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||
{
|
||||
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
||||
}
|
||||
|
||||
Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
|
||||
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView(ForwardVector(angles), RightVector(angles), UpVector(angles), cam_origin);
|
||||
}
|
||||
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
// NOTE: Need magic number to fix fov calculation, since source inherit Quake proj matrix calculation
|
||||
constexpr auto kMultiplyFactor = 0.75f;
|
||||
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f) * kMultiplyFactor;
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, (far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, 1, 0},
|
||||
};
|
||||
}
|
||||
} // namespace omath::source_engine
|
||||
1
source/engines/unity_engine/CMakeLists.txt
Normal file
1
source/engines/unity_engine/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
target_sources(omath PRIVATE formulas.cpp camera.cpp)
|
||||
28
source/engines/unity_engine/camera.cpp
Normal file
28
source/engines/unity_engine/camera.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Vlad on 3/22/2025.
|
||||
//
|
||||
#include <omath/engines/unity_engine/camera.hpp>
|
||||
#include <omath/engines/unity_engine/formulas.hpp>
|
||||
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||
const projection::FieldOfView& fov, const float near, const float far) :
|
||||
projection::Camera<Mat4x4, ViewAngles>(position, viewAngles, viewPort, fov, near, far)
|
||||
{
|
||||
}
|
||||
void Camera::LookAt([[maybe_unused]] const Vector3<float>& target)
|
||||
{
|
||||
throw std::runtime_error("Not implemented");
|
||||
}
|
||||
Mat4x4 Camera::CalcViewMatrix() const
|
||||
{
|
||||
return unity_engine::CalcViewMatrix(m_viewAngles, m_origin);
|
||||
}
|
||||
Mat4x4 Camera::CalcProjectionMatrix() const
|
||||
{
|
||||
return CalcPerspectiveProjectionMatrix(m_fieldOfView.AsDegrees(), m_viewPort.AspectRatio(), m_nearPlaneDistance,
|
||||
m_farPlaneDistance);
|
||||
}
|
||||
} // namespace omath::unity_engine
|
||||
51
source/engines/unity_engine/formulas.cpp
Normal file
51
source/engines/unity_engine/formulas.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by Vlad on 3/22/2025.
|
||||
//
|
||||
#include "omath/engines/unity_engine/formulas.hpp"
|
||||
|
||||
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> RightVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Vector3<float> UpVector(const ViewAngles& angles)
|
||||
{
|
||||
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||
|
||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||
}
|
||||
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||
{
|
||||
return MatCameraView<float, MatStoreType::ROW_MAJOR>(ForwardVector(angles), -RightVector(angles),
|
||||
UpVector(angles), cam_origin);
|
||||
}
|
||||
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||
{
|
||||
return MatRotationAxisZ(angles.roll) *
|
||||
MatRotationAxisY(angles.yaw) *
|
||||
MatRotationAxisX(angles.pitch);
|
||||
}
|
||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||
const float far)
|
||||
{
|
||||
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2.f);
|
||||
|
||||
return {
|
||||
{1.f / (aspectRatio * fovHalfTan), 0, 0, 0},
|
||||
{0, 1.f / (fovHalfTan), 0, 0},
|
||||
{0, 0, (far + near) / (far - near), -(2.f * far * near) / (far - near)},
|
||||
{0, 0, -1.f, 0},
|
||||
};
|
||||
}
|
||||
} // namespace omath::unity_engine
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "omath/Matrix.hpp"
|
||||
#include "omath/Angles.hpp"
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/matrix.hpp"
|
||||
#include "omath/angles.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
|
||||
#include <complex>
|
||||
@@ -1 +1 @@
|
||||
target_sources(omath PRIVATE NavigationMesh.cpp Astar.cpp)
|
||||
target_sources(omath PRIVATE navigation_mesh.cpp a_star.cpp)
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by Vlad on 28.07.2024.
|
||||
//
|
||||
#include "omath/pathfinding/Astar.hpp"
|
||||
#include "omath/pathfinding/a_star.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// Created by Vlad on 28.07.2024.
|
||||
//
|
||||
#include "omath/pathfinding/NavigationMesh.hpp"
|
||||
#include "omath/pathfinding/navigation_mesh.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
std::expected<Vector3<float>, std::string> NavigationMesh::GetClosestVertex(const Vector3<float> &point) const
|
||||
@@ -1 +1 @@
|
||||
target_sources(omath PRIVATE ProjPredEngineLegacy.cpp Projectile.cpp Target.cpp ProjPredEngineAVX2.cpp ProjPredEngine.cpp)
|
||||
target_sources(omath PRIVATE proj_pred_engine_legacy.cpp projectile.cpp target.cpp proj_pred_engine_avx2.cpp proj_pred_engine.cpp)
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by Vlad on 2/23/2025.
|
||||
//
|
||||
#include "omath/projectile_prediction/ProjPredEngine.hpp"
|
||||
#include "omath/projectile_prediction/proj_pred_engine.hpp"
|
||||
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
@@ -1,14 +1,23 @@
|
||||
//
|
||||
// Created by Vlad on 2/23/2025.
|
||||
//
|
||||
#include "omath/projectile_prediction/ProjPredEngineAVX2.hpp"
|
||||
#include "omath/projectile_prediction/proj_pred_engine_avx2.hpp"
|
||||
#include <source_location>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
|
||||
#include <immintrin.h>
|
||||
#else
|
||||
#include <format>
|
||||
#endif
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
std::optional<Vector3<float>> ProjPredEngineAVX2::MaybeCalculateAimPoint(const Projectile& projectile,
|
||||
const Target& target) const
|
||||
std::optional<Vector3<float>>
|
||||
ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile,
|
||||
[[maybe_unused]] const Target& target) const
|
||||
{
|
||||
#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
|
||||
const float bulletGravity = m_gravityConstant * projectile.m_gravityScale;
|
||||
const float v0 = projectile.m_launchSpeed;
|
||||
const float v0Sqr = v0 * v0;
|
||||
@@ -31,8 +40,8 @@ namespace omath::projectile_prediction
|
||||
_mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.y), times, _mm256_set1_ps(target.m_origin.y));
|
||||
const __m256 timesSq = _mm256_mul_ps(times, times);
|
||||
const __m256 targetZ = _mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.z), times,
|
||||
_mm256_fnmadd_ps(_mm256_set1_ps(0.5f * m_gravityConstant), timesSq,
|
||||
_mm256_set1_ps(target.m_origin.z)));
|
||||
_mm256_fnmadd_ps(_mm256_set1_ps(0.5f * m_gravityConstant), timesSq,
|
||||
_mm256_set1_ps(target.m_origin.z)));
|
||||
|
||||
const __m256 deltaX = _mm256_sub_ps(targetX, _mm256_set1_ps(projOrigin.x));
|
||||
const __m256 deltaY = _mm256_sub_ps(targetY, _mm256_set1_ps(projOrigin.y));
|
||||
@@ -106,12 +115,13 @@ namespace omath::projectile_prediction
|
||||
}
|
||||
ProjPredEngineAVX2::ProjPredEngineAVX2(const float gravityConstant, const float simulationTimeStep,
|
||||
const float maximumSimulationTime) :
|
||||
m_gravityConstant(gravityConstant), m_simulationTimeStep(maximumSimulationTime),
|
||||
m_maximumSimulationTime(simulationTimeStep)
|
||||
m_gravityConstant(gravityConstant), m_simulationTimeStep(simulationTimeStep),
|
||||
m_maximumSimulationTime(maximumSimulationTime)
|
||||
{
|
||||
}
|
||||
std::optional<float> ProjPredEngineAVX2::CalculatePitch(const Vector3<float>& projOrigin, const Vector3<float>& targetPos,
|
||||
const float bulletGravity, const float v0, const float time)
|
||||
std::optional<float> ProjPredEngineAVX2::CalculatePitch(const Vector3<float>& projOrigin,
|
||||
const Vector3<float>& targetPos, const float bulletGravity,
|
||||
const float v0, const float time)
|
||||
{
|
||||
if (time <= 0.0f)
|
||||
return std::nullopt;
|
||||
@@ -134,5 +144,9 @@ namespace omath::projectile_prediction
|
||||
const float d = std::sqrt(dSqr);
|
||||
const float tanTheta = term / d;
|
||||
return angles::RadiansToDegrees(std::atan(tanTheta));
|
||||
#else
|
||||
throw std::runtime_error(
|
||||
std::format("{} AVX2 feature is not enabled!", std::source_location::current().function_name()));
|
||||
#endif
|
||||
}
|
||||
} // namespace omath::projectile_prediction
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "omath/projectile_prediction/ProjPredEngineLegacy.hpp"
|
||||
#include "omath/projectile_prediction/proj_pred_engine_legacy.hpp"
|
||||
#include <cmath>
|
||||
#include <omath/Angles.hpp>
|
||||
#include <omath/angles.hpp>
|
||||
|
||||
namespace omath::projectile_prediction
|
||||
{
|
||||
@@ -2,17 +2,17 @@
|
||||
// Created by Vlad on 6/9/2024.
|
||||
//
|
||||
|
||||
#include "omath/projectile_prediction/Projectile.hpp"
|
||||
#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;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Vlad on 6/9/2024.
|
||||
//
|
||||
|
||||
#include "omath/projectile_prediction/Projectile.hpp"
|
||||
#include "omath/projectile_prediction/projectile.hpp"
|
||||
|
||||
|
||||
namespace omath::prediction
|
||||
@@ -1 +1 @@
|
||||
target_sources(omath PRIVATE Camera.cpp)
|
||||
target_sources(omath PRIVATE camera.cpp)
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by Vlad on 27.08.2024.
|
||||
//
|
||||
#include "omath/projection/Camera.hpp"
|
||||
#include "omath/projection/camera.hpp"
|
||||
|
||||
|
||||
namespace omath::projection
|
||||
@@ -4,24 +4,25 @@ project(unit-tests)
|
||||
|
||||
include(GoogleTest)
|
||||
add_executable(unit-tests
|
||||
general/UnitTestPrediction.cpp
|
||||
general/UnitTestMatrix.cpp
|
||||
general/UnitTestMat.cpp
|
||||
general/UnitTestAstar.cpp
|
||||
general/UnitTestProjection.cpp
|
||||
general/UnitTestVector3.cpp
|
||||
general/UnitTestVector2.cpp
|
||||
general/UnitTestColor.cpp
|
||||
general/UnitTestVector4.cpp
|
||||
general/UnitTestLineTrace.cpp
|
||||
general/UnitTestAngles.cpp
|
||||
general/UnitTestViewAngles.cpp
|
||||
general/UnitTestAngle.cpp
|
||||
general/UnitTestTriangle.cpp
|
||||
general/unit_test_prediction.cpp
|
||||
general/unit_test_matrix.cpp
|
||||
general/unit_test_mat.cpp
|
||||
general/unit_test_a_star.cpp
|
||||
general/unit_test_projection.cpp
|
||||
general/unit_test_vector3.cpp
|
||||
general/unit_test_vector2.cpp
|
||||
general/unit_test_color.cpp
|
||||
general/unit_test_vector4.cpp
|
||||
general/unit_test_line_trace.cpp
|
||||
general/unit_test_angles.cpp
|
||||
general/unit_test_view_angles.cpp
|
||||
general/unit_test_angle.cpp
|
||||
general/unit_test_triangle.cpp
|
||||
|
||||
engines/UnitTestOpenGL.cpp
|
||||
engines/UnitTestUnityEngine.cpp
|
||||
engines/UnitTestSourceEngine.cpp
|
||||
engines/unit_test_open_gl.cpp
|
||||
engines/unit_test_unity_engine.cpp
|
||||
engines/unit_test_source_engine.cpp
|
||||
engines/unit_test_iw_engine.cpp
|
||||
|
||||
)
|
||||
|
||||
@@ -34,6 +35,6 @@ set_target_properties(unit-tests PROPERTIES
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath)
|
||||
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath::omath)
|
||||
|
||||
gtest_discover_tests(unit-tests)
|
||||
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// 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>
|
||||
|
||||
|
||||
TEST(UnitTestOpenGL, ForwardVector)
|
||||
{
|
||||
const auto forward = omath::opengl::ForwardVector({});
|
||||
|
||||
EXPECT_EQ(forward, omath::opengl::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, RightVector)
|
||||
{
|
||||
const auto right = omath::opengl::RightVector({});
|
||||
|
||||
EXPECT_EQ(right, omath::opengl::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, UpVector)
|
||||
{
|
||||
const auto up = omath::opengl::UpVector({});
|
||||
EXPECT_EQ(up, omath::opengl::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);
|
||||
|
||||
|
||||
for (float distance = -10.f; distance > -1000.f; distance -= 0.01f)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({0, 0, distance});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::opengl::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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// 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>
|
||||
|
||||
|
||||
TEST(UnitTestSourceEngine, ForwardVector)
|
||||
{
|
||||
const auto forward = omath::source::ForwardVector({});
|
||||
|
||||
EXPECT_EQ(forward, omath::source::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, RightVector)
|
||||
{
|
||||
const auto right = omath::source::RightVector({});
|
||||
|
||||
EXPECT_EQ(right, omath::source::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, UpVector)
|
||||
{
|
||||
const auto up = omath::source::UpVector({});
|
||||
EXPECT_EQ(up, omath::source::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);
|
||||
|
||||
|
||||
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({distance, 0, 0});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::source::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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
//
|
||||
// Created by Orange on 11/27/2024.
|
||||
//
|
||||
105
tests/engines/unit_test_iw_engine.cpp
Normal file
105
tests/engines/unit_test_iw_engine.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// Created by Vlad on 3/17/2025.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/engines/iw_engine/camera.hpp>
|
||||
#include <omath/engines/iw_engine/constants.hpp>
|
||||
#include <omath/engines/iw_engine/formulas.hpp>
|
||||
|
||||
|
||||
TEST(UnitTestIwEngine, ForwardVector)
|
||||
{
|
||||
const auto forward = omath::iw_engine::ForwardVector({});
|
||||
|
||||
EXPECT_EQ(forward, omath::iw_engine::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, RightVector)
|
||||
{
|
||||
const auto right = omath::iw_engine::RightVector({});
|
||||
|
||||
EXPECT_EQ(right, omath::iw_engine::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, UpVector)
|
||||
{
|
||||
const auto up = omath::iw_engine::UpVector({});
|
||||
EXPECT_EQ(up, omath::iw_engine::kAbsUp);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, ForwardVectorRotationYaw)
|
||||
{
|
||||
omath::iw_engine::ViewAngles angles;
|
||||
|
||||
angles.yaw = omath::iw_engine::YawAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::iw_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, ForwardVectorRotationPitch)
|
||||
{
|
||||
omath::iw_engine::ViewAngles angles;
|
||||
|
||||
angles.pitch = omath::iw_engine::PitchAngle::FromDegrees(-89.f);
|
||||
|
||||
const auto forward = omath::iw_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsUp.x, 0.02f);
|
||||
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsUp.y, 0.01f);
|
||||
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsUp.z, 0.01f);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, ForwardVectorRotationRoll)
|
||||
{
|
||||
omath::iw_engine::ViewAngles angles;
|
||||
|
||||
angles.roll = omath::iw_engine::RollAngle::FromDegrees(90.f);
|
||||
|
||||
const auto forward = omath::iw_engine::UpVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, ProjectTargetMovedFromCamera)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
const auto cam = omath::iw_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)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({distance, 0, 0});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, CameraSetAndGetFov)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
auto cam = omath::iw_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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestIwEngine, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::iw_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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
105
tests/engines/unit_test_open_gl.cpp
Normal file
105
tests/engines/unit_test_open_gl.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// Created by Orange on 11/23/2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#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_engine::ForwardVector({});
|
||||
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, RightVector)
|
||||
{
|
||||
const auto right = omath::opengl_engine::RightVector({});
|
||||
EXPECT_EQ(right, omath::opengl_engine::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, UpVector)
|
||||
{
|
||||
const auto up = omath::opengl_engine::UpVector({});
|
||||
EXPECT_EQ(up, omath::opengl_engine::kAbsUp);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, ForwardVectorRotationYaw)
|
||||
{
|
||||
omath::opengl_engine::ViewAngles angles;
|
||||
|
||||
angles.yaw = omath::opengl_engine::YawAngle::FromDegrees(90.f);
|
||||
|
||||
const auto forward = omath::opengl_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(UnitTestOpenGL, ForwardVectorRotationPitch)
|
||||
{
|
||||
omath::opengl_engine::ViewAngles angles;
|
||||
|
||||
angles.pitch = omath::opengl_engine::PitchAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::opengl_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsUp.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsUp.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsUp.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, ForwardVectorRotationRoll)
|
||||
{
|
||||
omath::opengl_engine::ViewAngles angles;
|
||||
|
||||
angles.roll = omath::opengl_engine::RollAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::opengl_engine::UpVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.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)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({0, 0, distance});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, CameraSetAndGetFov)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestOpenGL, CameraSetAndGetOrigin)
|
||||
{
|
||||
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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
125
tests/engines/unit_test_source_engine.cpp
Normal file
125
tests/engines/unit_test_source_engine.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// Created by Orange on 11/23/2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#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_engine::ForwardVector({});
|
||||
|
||||
EXPECT_EQ(forward, omath::source_engine::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, RightVector)
|
||||
{
|
||||
const auto right = omath::source_engine::RightVector({});
|
||||
|
||||
EXPECT_EQ(right, omath::source_engine::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, UpVector)
|
||||
{
|
||||
const auto up = omath::source_engine::UpVector({});
|
||||
EXPECT_EQ(up, omath::source_engine::kAbsUp);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, ForwardVectorRotationYaw)
|
||||
{
|
||||
omath::source_engine::ViewAngles angles;
|
||||
|
||||
angles.yaw = omath::source_engine::YawAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::source_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::source_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::source_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::source_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, ForwardVectorRotationPitch)
|
||||
{
|
||||
omath::source_engine::ViewAngles angles;
|
||||
|
||||
angles.pitch = omath::source_engine::PitchAngle::FromDegrees(-89.f);
|
||||
|
||||
const auto forward = omath::source_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::source_engine::kAbsUp.x, 0.02f);
|
||||
EXPECT_NEAR(forward.y, omath::source_engine::kAbsUp.y, 0.01f);
|
||||
EXPECT_NEAR(forward.z, omath::source_engine::kAbsUp.z, 0.01f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, ForwardVectorRotationRoll)
|
||||
{
|
||||
omath::source_engine::ViewAngles angles;
|
||||
|
||||
angles.roll = omath::source_engine::RollAngle::FromDegrees(90.f);
|
||||
|
||||
const auto forward = omath::source_engine::UpVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::source_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::source_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::source_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.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)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({distance, 0, 0});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, ProjectTargetMovedUp)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
const auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||
|
||||
auto prev = 1080.f;
|
||||
for (float distance = 0.0f; distance < 10.f; distance += 1.f)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({100.f, 0, distance});
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_TRUE(projected->y < prev);
|
||||
|
||||
prev = projected->y;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, CameraSetAndGetFov)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
|
||||
{
|
||||
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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
113
tests/engines/unit_test_unity_engine.cpp
Normal file
113
tests/engines/unit_test_unity_engine.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// Created by Orange on 11/27/2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/engines/unity_engine/camera.hpp>
|
||||
#include <omath/engines/unity_engine/constants.hpp>
|
||||
#include <omath/engines/unity_engine/formulas.hpp>
|
||||
|
||||
|
||||
TEST(UnitTestUnityEngine, ForwardVector)
|
||||
{
|
||||
const auto forward = omath::unity_engine::ForwardVector({});
|
||||
|
||||
EXPECT_EQ(forward, omath::unity_engine::kAbsForward);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, ForwardVectorRotationYaw)
|
||||
{
|
||||
omath::unity_engine::ViewAngles angles;
|
||||
|
||||
angles.yaw = omath::unity_engine::YawAngle::FromDegrees(90.f);
|
||||
|
||||
const auto forward = omath::unity_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, ForwardVectorRotationPitch)
|
||||
{
|
||||
omath::unity_engine::ViewAngles angles;
|
||||
|
||||
angles.pitch = omath::unity_engine::PitchAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::unity_engine::ForwardVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsUp.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsUp.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsUp.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, ForwardVectorRotationRoll)
|
||||
{
|
||||
omath::unity_engine::ViewAngles angles;
|
||||
|
||||
angles.roll = omath::unity_engine::RollAngle::FromDegrees(-90.f);
|
||||
|
||||
const auto forward = omath::unity_engine::UpVector(angles);
|
||||
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
|
||||
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
|
||||
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, RightVector)
|
||||
{
|
||||
const auto right = omath::unity_engine::RightVector({});
|
||||
|
||||
EXPECT_EQ(right, omath::unity_engine::kAbsRight);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, UpVector)
|
||||
{
|
||||
const auto up = omath::unity_engine::UpVector({});
|
||||
EXPECT_EQ(up, omath::unity_engine::kAbsUp);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, ProjectTargetMovedFromCamera)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(60.f);
|
||||
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
|
||||
|
||||
|
||||
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen({0, 0, distance});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
if (!projected.has_value())
|
||||
continue;
|
||||
|
||||
EXPECT_NEAR(projected->x, 640, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 360, 0.00001f);
|
||||
}
|
||||
}
|
||||
TEST(UnitTestUnityEngine, Project)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(60.f);
|
||||
|
||||
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.03f, 1000.f);
|
||||
const auto proj = cam.WorldToScreen({5.f, 3, 10.f});
|
||||
std::println("{} {}", proj->x, proj->y);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, CameraSetAndGetFov)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
auto cam = omath::unity_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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestUnityEngine, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::unity_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));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Vlad on 18.08.2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/pathfinding/Astar.hpp>
|
||||
#include <omath/pathfinding/a_star.hpp>
|
||||
|
||||
|
||||
TEST(UnitTestAstar, FindingRightPath)
|
||||
@@ -2,8 +2,7 @@
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Angles.hpp>
|
||||
#include <omath/Angle.hpp>
|
||||
#include <omath/angles.hpp>
|
||||
|
||||
TEST(UnitTestAngles, RadiansToDeg)
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Vlad on 01.09.2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Color.hpp>
|
||||
#include <omath/color.hpp>
|
||||
|
||||
|
||||
using namespace omath;
|
||||
@@ -63,9 +63,9 @@ TEST_F(UnitTestColor, FromHSV)
|
||||
TEST_F(UnitTestColor, ToHSV)
|
||||
{
|
||||
HSV hsv = color1.ToHSV(); // Red color
|
||||
EXPECT_FLOAT_EQ(hsv.m_hue, 0.0f);
|
||||
EXPECT_FLOAT_EQ(hsv.m_saturation, 1.0f);
|
||||
EXPECT_FLOAT_EQ(hsv.m_value, 1.0f);
|
||||
EXPECT_FLOAT_EQ(hsv.hue, 0.0f);
|
||||
EXPECT_FLOAT_EQ(hsv.saturation, 1.0f);
|
||||
EXPECT_FLOAT_EQ(hsv.value, 1.0f);
|
||||
}
|
||||
|
||||
// Test color blending
|
||||
@@ -106,7 +106,7 @@ TEST_F(UnitTestColor, BlendVector3)
|
||||
{
|
||||
constexpr Color v1(1.0f, 0.0f, 0.0f, 1.f); // Red
|
||||
constexpr Color v2(0.0f, 1.0f, 0.0f, 1.f); // Green
|
||||
constexpr Color blended = Blend(v1, v2, 0.5f);
|
||||
constexpr Color blended = v1.Blend(v2, 0.5f);
|
||||
EXPECT_FLOAT_EQ(blended.x, 0.5f);
|
||||
EXPECT_FLOAT_EQ(blended.y, 0.5f);
|
||||
EXPECT_FLOAT_EQ(blended.z, 0.0f);
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "omath/collision/LineTracer.hpp"
|
||||
#include "omath/Triangle.hpp"
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/collision/line_tracer.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
using namespace omath;
|
||||
using namespace omath::collision;
|
||||
@@ -1,7 +1,7 @@
|
||||
// UnitTestMat.cpp
|
||||
#include <gtest/gtest.h>
|
||||
#include "omath/Mat.hpp"
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/mat.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -127,7 +127,7 @@ TEST_F(UnitTestMat, ToString)
|
||||
{
|
||||
const std::string str = m2.ToString();
|
||||
EXPECT_FALSE(str.empty());
|
||||
EXPECT_EQ(str, "1 2\n3 4\n");
|
||||
EXPECT_EQ(str, "[[ 1.000, 2.000]\n [ 3.000, 4.000]]");
|
||||
}
|
||||
|
||||
// Test assignment operators
|
||||
@@ -166,8 +166,10 @@ TEST_F(UnitTestMat, StaticMethod_ToScreenMat)
|
||||
// Test exception handling in At() method
|
||||
TEST_F(UnitTestMat, Method_At_OutOfRange)
|
||||
{
|
||||
#if !defined(NDEBUG) && defined(OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
EXPECT_THROW(std::ignore = m2.At(2, 0), std::out_of_range);
|
||||
EXPECT_THROW(std::ignore = m2.At(0, 2), std::out_of_range);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Test Determinant for 3x3 matrix
|
||||
@@ -2,8 +2,8 @@
|
||||
// Created by vlad on 5/18/2024.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Matrix.hpp>
|
||||
#include "omath/Vector3.hpp"
|
||||
#include <omath/matrix.hpp>
|
||||
#include "omath/vector3.hpp"
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/projectile_prediction/ProjPredEngineLegacy.hpp>
|
||||
#include <omath/projectile_prediction/proj_pred_engine_legacy.hpp>
|
||||
|
||||
TEST(UnitTestPrediction, PredictionTest)
|
||||
{
|
||||
@@ -3,15 +3,14 @@
|
||||
//
|
||||
#include <complex>
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Matrix.hpp>
|
||||
#include <omath/engines/Source/Camera.hpp>
|
||||
#include <omath/projection/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);
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// Created by Orange on 1/6/2025.
|
||||
//
|
||||
#include "omath/Triangle.hpp"
|
||||
#include <cmath> // For std::sqrt, std::isinf, std::isnan
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Vector3.hpp>
|
||||
#include <cmath> // For std::sqrt, std::isinf, std::isnan
|
||||
#include <omath/vector3.hpp>
|
||||
#include "omath/triangle.hpp"
|
||||
|
||||
|
||||
using namespace omath;
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Vlad on 02.09.2024.
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Vector2.hpp>
|
||||
#include <cmath> // For std::isinf and std::isnan
|
||||
#include <cfloat> // For FLT_MAX and FLT_MIN
|
||||
#include <cmath> // For std::isinf and std::isnan
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/vector2.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Created by Vlad on 01.09.2024.
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Vector3.hpp>
|
||||
#include <cmath>
|
||||
#include <cfloat> // For FLT_MAX, FLT_MIN
|
||||
#include <cmath>
|
||||
#include <gtest/gtest.h>
|
||||
#include <limits> // For std::numeric_limits
|
||||
#include <omath/vector3.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Vector4.hpp>
|
||||
#include <limits> // For std::numeric_limits
|
||||
#include <omath/vector4.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
#include <omath/ViewAngles.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
Reference in New Issue
Block a user