Compare commits

...

6 Commits

Author SHA1 Message Date
Orange
8e861b8a85 updated read me 2025-04-05 13:28:28 +03:00
Orange
55085604fd added include 2025-04-05 13:20:18 +03:00
Orange
7b712ed960 fixed for clang 2025-04-05 13:00:00 +03:00
138c996393 oops 2025-03-29 22:03:30 +03:00
0f2a858306 fixed in some cases confilcting with win api 2025-03-29 21:57:35 +03:00
ea6c1cc929 fix 2025-03-29 18:20:17 +03:00
9 changed files with 86 additions and 18 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/cmake-build/ /cmake-build/
/.idea /.idea
/out /out
*.DS_Store

View File

@@ -5,7 +5,7 @@ project(omath VERSION 1.0.1 LANGUAGES CXX)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
option(OMATH_BUILD_TESTS "Build unit tests" OFF) option(OMATH_BUILD_TESTS "Build unit tests" ON)
option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON) 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_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_USE_AVX2 "Omath will use AVX2 to boost performance" ON)
@@ -14,11 +14,12 @@ option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" O
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF) option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
if (OMATH_BUILD_AS_SHARED_LIBRARY) if (OMATH_BUILD_AS_SHARED_LIBRARY)
add_library(omath SHARED source/Matrix.cpp) add_library(omath SHARED source/matrix.cpp)
else() else()
add_library(omath STATIC source/Matrix.cpp) add_library(omath STATIC source/matrix.cpp
source/matrix.cpp)
endif() endif()
message(STATUS "Building on ${CMAKE_HOST_SYSTEM_NAME}")
add_library(omath::omath ALIAS omath) add_library(omath::omath ALIAS omath)
if (OMATH_IMGUI_INTEGRATION) if (OMATH_IMGUI_INTEGRATION)

View File

@@ -64,6 +64,38 @@
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Release" "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"
}
} }
] ]
} }

View File

@@ -21,12 +21,21 @@ Oranges's Math Library (omath) is a comprehensive, open-source library aimed at
- **No Additional Dependencies**: No additional dependencies need to use OMath except unit test execution - **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! - **Ready for meta-programming**: Omath use templates for common types like Vectors, Matrixes etc, to handle all types!
|ENGINE |SUPPORT| ## Supported Render Pipelines
|--------|-------| | ENGINE | SUPPORT |
|Source |✅YES | |----------|---------|
|Unity |✅YES | | Source | ✅YES |
|IWEngine|✅YES | | Unity | ✅YES |
|Unreal |❌NO | | IWEngine | ✅YES |
| Unreal | ❌NO |
## Supported Operating Systems
| OS | SUPPORT |
|----------------|---------|
| Windows 10/11 | ✅YES |
| Linux | ✅YES |
| Darwin (MacOS) | ✅YES |
## ⏬ Getting Started ## ⏬ Getting Started
### Prerequisites ### Prerequisites

View File

@@ -8,6 +8,15 @@
#include "omath/vector3.hpp" #include "omath/vector3.hpp"
#include "omath/vector4.hpp" #include "omath/vector4.hpp"
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
namespace omath namespace omath
{ {
struct HSV struct HSV
@@ -118,7 +127,7 @@ namespace omath
{ {
Clamp(0.f, 1.f); Clamp(0.f, 1.f);
} }
consteval void SetHue(const float hue) constexpr void SetHue(const float hue)
{ {
auto hsv = ToHSV(); auto hsv = ToHSV();
hsv.hue = hue; hsv.hue = hue;
@@ -126,7 +135,7 @@ namespace omath
*this = FromHSV(hsv); *this = FromHSV(hsv);
} }
consteval void SetSaturation(const float saturation) constexpr void SetSaturation(const float saturation)
{ {
auto hsv = ToHSV(); auto hsv = ToHSV();
hsv.saturation = saturation; hsv.saturation = saturation;
@@ -134,7 +143,7 @@ namespace omath
*this = FromHSV(hsv); *this = FromHSV(hsv);
} }
consteval void SetValue(const float value) constexpr void SetValue(const float value)
{ {
auto hsv = ToHSV(); auto hsv = ToHSV();
hsv.value = value; hsv.value = value;

View File

@@ -10,6 +10,16 @@
#include <utility> #include <utility>
#include "omath/vector3.hpp" #include "omath/vector3.hpp"
#ifdef near
#undef near
#endif
#ifdef far
#undef far
#endif
namespace omath namespace omath
{ {
struct MatSize struct MatSize

View File

@@ -124,9 +124,9 @@ namespace omath
} }
#ifndef _MSC_VER #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 [[nodiscard]] constexpr Vector2 Normalized() const

View File

@@ -121,12 +121,12 @@ namespace omath
#ifndef _MSC_VER #ifndef _MSC_VER
[[nodiscard]] constexpr Type Length() const [[nodiscard]] constexpr Type Length() const
{ {
return std::hypot(x, y, z); return std::hypot(this->x, this->y, z);
} }
[[nodiscard]] constexpr Type Length2D() const [[nodiscard]] constexpr Type Length2D() const
{ {
return Vector2::Length(); return Vector2<Type>::Length();
} }
[[nodiscard]] Type DistTo(const Vector3& vOther) const [[nodiscard]] Type DistTo(const Vector3& vOther) const
{ {

View File

@@ -4,13 +4,19 @@
#include "omath/projectile_prediction/proj_pred_engine_avx2.hpp" #include "omath/projectile_prediction/proj_pred_engine_avx2.hpp"
#include "source_location" #include "source_location"
#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
#include <immintrin.h>
#include <format>
#endif
namespace omath::projectile_prediction namespace omath::projectile_prediction
{ {
std::optional<Vector3<float>> std::optional<Vector3<float>>
ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile, ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile,
[[maybe_unused]] const Target& target) const [[maybe_unused]] const Target& target) const
{ {
#ifdef OMATH_USE_AVX2 #if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
const float bulletGravity = m_gravityConstant * projectile.m_gravityScale; const float bulletGravity = m_gravityConstant * projectile.m_gravityScale;
const float v0 = projectile.m_launchSpeed; const float v0 = projectile.m_launchSpeed;
const float v0Sqr = v0 * v0; const float v0Sqr = v0 * v0;