mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e861b8a85 | ||
|
|
55085604fd | ||
|
|
7b712ed960 | ||
| 138c996393 | |||
| 0f2a858306 | |||
| ea6c1cc929 | |||
| eeb6e40909 | |||
| d72ad663cd | |||
| 3e75d32f59 | |||
| a8ce5cbaa0 | |||
| 79f76a0755 | |||
| 5773cc7798 | |||
| b6b0184523 | |||
| a797dd134a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/cmake-build/
|
/cmake-build/
|
||||||
/.idea
|
/.idea
|
||||||
/out
|
/out
|
||||||
|
*.DS_Store
|
||||||
@@ -5,23 +5,40 @@ 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)
|
||||||
option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF)
|
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_BUILD_EXAMPLES "Build example projects with you can learn & play" 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)
|
||||||
target_compile_definitions(omath PUBLIC 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()
|
endif()
|
||||||
|
|
||||||
if (OMATH_USE_AVX2)
|
if (OMATH_USE_AVX2)
|
||||||
@@ -36,6 +53,12 @@ set_target_properties(omath PROPERTIES
|
|||||||
CXX_STANDARD 23
|
CXX_STANDARD 23
|
||||||
CXX_STANDARD_REQUIRED ON)
|
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")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
target_compile_options(omath PRIVATE -mavx2 -mfma)
|
target_compile_options(omath PRIVATE -mavx2 -mfma)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
17
README.md
17
README.md
@@ -20,6 +20,23 @@ Oranges's Math Library (omath) is a comprehensive, open-source library aimed at
|
|||||||
- **Collision Detection**: Production ready code to handle collision detection by using simple interfaces.
|
- **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
|
- **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!
|
||||||
|
|
||||||
|
## 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
|
## ⏬ Getting Started
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
- C++ Compiler
|
- C++ Compiler
|
||||||
|
|||||||
@@ -8,115 +8,166 @@
|
|||||||
#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
|
||||||
{
|
{
|
||||||
float m_hue{};
|
float hue{};
|
||||||
float m_saturation{};
|
float saturation{};
|
||||||
float m_value{};
|
float value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Color final : public Vector4<float>
|
class Color final : public Vector4<float>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
constexpr Color(const float r, const float g, const float b, const float a) : Vector4(r,g,b,a)
|
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)
|
||||||
{
|
{
|
||||||
Clamp(0.f, 1.f);
|
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};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr explicit Color() : Vector4()
|
return {r, g, b, 1.f};
|
||||||
{
|
}
|
||||||
|
|
||||||
}
|
[[nodiscard]]
|
||||||
[[nodiscard]]
|
constexpr static Color FromHSV(const HSV& hsv)
|
||||||
constexpr static Color FromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
{
|
||||||
{
|
return FromHSV(hsv.hue, hsv.saturation, hsv.value);
|
||||||
return Color{Vector4(r, g, b, a) / 255.f};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr static Color FromHSV(float hue, float saturation, float value)
|
constexpr HSV ToHSV() const
|
||||||
{
|
{
|
||||||
float r{}, g{}, b{};
|
HSV hsvData;
|
||||||
|
|
||||||
hue = std::clamp(hue, 0.f, 1.f);
|
const float& red = x;
|
||||||
|
const float& green = y;
|
||||||
|
const float& blue = z;
|
||||||
|
|
||||||
const int i = static_cast<int>(hue * 6.f);
|
const float max = std::max({red, green, blue});
|
||||||
const float f = hue * 6 - i;
|
const float min = std::min({red, green, blue});
|
||||||
const float p = value * (1 - saturation);
|
const float delta = max - min;
|
||||||
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)
|
if (delta == 0.f)
|
||||||
hsvData.m_hue = 0.f;
|
hsvData.hue = 0.f;
|
||||||
|
|
||||||
else if (max == red)
|
else if (max == red)
|
||||||
hsvData.m_hue = 60.f * (std::fmodf(((green - blue) / delta), 6.f));
|
hsvData.hue = 60.f * (std::fmodf(((green - blue) / delta), 6.f));
|
||||||
else if (max == green)
|
else if (max == green)
|
||||||
hsvData.m_hue = 60.f * (((blue - red) / delta) + 2.f);
|
hsvData.hue = 60.f * (((blue - red) / delta) + 2.f);
|
||||||
else if (max == blue)
|
else if (max == blue)
|
||||||
hsvData.m_hue = 60.f * (((red - green) / delta) + 4.f);
|
hsvData.hue = 60.f * (((red - green) / delta) + 4.f);
|
||||||
|
|
||||||
if (hsvData.m_hue < 0.f)
|
if (hsvData.hue < 0.f)
|
||||||
hsvData.m_hue += 360.f;
|
hsvData.hue += 360.f;
|
||||||
|
|
||||||
hsvData.m_hue /= 360.f;
|
hsvData.hue /= 360.f;
|
||||||
hsvData.m_saturation = max == 0.f ? 0.f : delta / max;
|
hsvData.saturation = max == 0.f ? 0.f : delta / max;
|
||||||
hsvData.m_value = max;
|
hsvData.value = max;
|
||||||
|
|
||||||
return hsvData;
|
return hsvData;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr explicit Color(const Vector4& vec) : Vector4(vec)
|
constexpr explicit Color(const Vector4& vec) : Vector4(vec)
|
||||||
{
|
{
|
||||||
Clamp(0.f, 1.f);
|
Clamp(0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
constexpr void SetHue(const float hue)
|
||||||
|
{
|
||||||
|
auto hsv = ToHSV();
|
||||||
|
hsv.hue = hue;
|
||||||
|
|
||||||
[[nodiscard]]
|
*this = FromHSV(hsv);
|
||||||
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};}
|
constexpr void SetSaturation(const float saturation)
|
||||||
[[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};}
|
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
|
||||||
[[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};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by vlad on 2/4/24.
|
// Created by vlad on 2/4/24.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "omath/Color.hpp"
|
#include "omath/color.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace omath::unity_engine
|
namespace omath::unity_engine
|
||||||
{
|
{
|
||||||
Vector3<float> unity_engine::ForwardVector(const ViewAngles& angles)
|
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "omath/Matrix.hpp"
|
#include "omath/matrix.hpp"
|
||||||
#include "omath/Angles.hpp"
|
#include "omath/angles.hpp"
|
||||||
#include "omath/Vector3.hpp"
|
#include "omath/vector3.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ TEST_F(UnitTestColor, FromHSV)
|
|||||||
TEST_F(UnitTestColor, ToHSV)
|
TEST_F(UnitTestColor, ToHSV)
|
||||||
{
|
{
|
||||||
HSV hsv = color1.ToHSV(); // Red color
|
HSV hsv = color1.ToHSV(); // Red color
|
||||||
EXPECT_FLOAT_EQ(hsv.m_hue, 0.0f);
|
EXPECT_FLOAT_EQ(hsv.hue, 0.0f);
|
||||||
EXPECT_FLOAT_EQ(hsv.m_saturation, 1.0f);
|
EXPECT_FLOAT_EQ(hsv.saturation, 1.0f);
|
||||||
EXPECT_FLOAT_EQ(hsv.m_value, 1.0f);
|
EXPECT_FLOAT_EQ(hsv.value, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test color blending
|
// 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 v1(1.0f, 0.0f, 0.0f, 1.f); // Red
|
||||||
constexpr Color v2(0.0f, 1.0f, 0.0f, 1.f); // Green
|
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.x, 0.5f);
|
||||||
EXPECT_FLOAT_EQ(blended.y, 0.5f);
|
EXPECT_FLOAT_EQ(blended.y, 0.5f);
|
||||||
EXPECT_FLOAT_EQ(blended.z, 0.0f);
|
EXPECT_FLOAT_EQ(blended.z, 0.0f);
|
||||||
|
|||||||
Reference in New Issue
Block a user