Compare commits

...

6 Commits

Author SHA1 Message Date
221fd54f5a fixed warning related with clang 2024-12-17 12:30:05 +03:00
5f8fc4058c Merge pull request #17 from luadebug/export
Create Export for DLL (shared MSVC build)
2024-12-17 12:24:11 +03:00
さくらみこ
fc164b339b fix 2024-12-17 12:08:18 +03:00
さくらみこ
58fb6a0304 clean 2024-12-17 08:40:48 +03:00
さくらみこ
193e87847a fixup 2024-12-17 07:24:44 +03:00
Saikari
075c553521 Export 2024-12-17 04:55:13 +03:00
20 changed files with 145 additions and 111 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.26)
project(omath VERSION 1.0.0) project(omath VERSION 1.0.0)
include(CMakePackageConfigHelpers)
set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD 26)
@@ -19,10 +19,16 @@ else()
add_library(omath STATIC source/Vector3.cpp) add_library(omath STATIC source/Vector3.cpp)
endif() endif()
target_compile_definitions(omath PUBLIC OMATH_EXPORT)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(omath PRIVATE /Zc:static_assert-)
endif()
add_subdirectory(source) add_subdirectory(source)
add_subdirectory(extlibs)
if(OMATH_BUILD_TESTS) if(OMATH_BUILD_TESTS)
add_subdirectory(extlibs)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
@@ -79,4 +85,4 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
DESTINATION lib/cmake/omath DESTINATION lib/cmake/omath
) )

View File

@@ -6,7 +6,7 @@
#include "omath/Angles.hpp" #include "omath/Angles.hpp"
#include <algorithm> #include <algorithm>
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
@@ -18,7 +18,7 @@ namespace omath
template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized> 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 class OMATH_API Angle
{ {
Type m_angle; Type m_angle;
constexpr Angle(const Type& degrees) constexpr Angle(const Type& degrees)

View File

@@ -6,7 +6,6 @@
#include <numbers> #include <numbers>
#include <cmath> #include <cmath>
namespace omath::angles namespace omath::angles
{ {
template<class Type> template<class Type>

View File

@@ -7,11 +7,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include <cstdint> #include <cstdint>
#include "omath/Vector4.hpp" #include "omath/Vector4.hpp"
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
struct HSV struct OMATH_API HSV
{ {
float m_hue{}; float m_hue{};
float m_saturation{}; float m_saturation{};
@@ -19,7 +19,7 @@ namespace omath
}; };
class Color final : public Vector4 class OMATH_API Color final : public Vector4
{ {
public: public:
constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a) constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a)

View File

@@ -8,11 +8,11 @@
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include "Vector3.hpp" #include "Vector3.hpp"
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
struct MatSize struct OMATH_API MatSize
{ {
size_t rows, columns; size_t rows, columns;
}; };
@@ -28,15 +28,15 @@ namespace omath
class Mat final class Mat final
{ {
public: public:
constexpr Mat() OMATH_API constexpr Mat()
{ {
Clear(); Clear();
} }
constexpr static MatStoreType GetStoreOrdering() OMATH_API constexpr static MatStoreType GetStoreOrdering()
{ {
return StoreType; return StoreType;
} }
constexpr Mat(const std::initializer_list<std::initializer_list<Type>>& rows) OMATH_API constexpr Mat(const std::initializer_list<std::initializer_list<Type>>& rows)
{ {
if (rows.size() != Rows) if (rows.size() != Rows)
throw std::invalid_argument("Initializer list rows size does not match template parameter Rows"); throw std::invalid_argument("Initializer list rows size does not match template parameter Rows");
@@ -56,40 +56,40 @@ namespace omath
} }
} }
constexpr explicit Mat(const Type* rawData) OMATH_API constexpr explicit Mat(const Type* rawData)
{ {
std::copy_n(rawData, Rows * Columns, m_data.begin()); std::copy_n(rawData, Rows * Columns, m_data.begin());
} }
constexpr Mat(const Mat& other) noexcept OMATH_API constexpr Mat(const Mat& other) noexcept
{ {
m_data = other.m_data; m_data = other.m_data;
} }
constexpr Mat(Mat&& other) noexcept OMATH_API constexpr Mat(Mat&& other) noexcept
{ {
m_data = std::move(other.m_data); m_data = std::move(other.m_data);
} }
[[nodiscard]] [[nodiscard]]
static constexpr size_t RowCount() noexcept OMATH_API static constexpr size_t RowCount() noexcept
{ {
return Rows; return Rows;
} }
[[nodiscard]] [[nodiscard]]
static constexpr size_t ColumnsCount() noexcept OMATH_API static constexpr size_t ColumnsCount() noexcept
{ {
return Columns; return Columns;
} }
[[nodiscard]] [[nodiscard]]
static consteval MatSize Size() noexcept OMATH_API static consteval MatSize Size() noexcept
{ {
return {Rows, Columns}; return {Rows, Columns};
} }
[[nodiscard]] constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const [[nodiscard]] OMATH_API constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const
{ {
if (rowIndex >= Rows || columnIndex >= Columns) if (rowIndex >= Rows || columnIndex >= Columns)
throw std::out_of_range("Index out of range"); throw std::out_of_range("Index out of range");
@@ -107,13 +107,13 @@ namespace omath
} }
} }
[[nodiscard]] constexpr Type& At(const size_t rowIndex, const size_t columnIndex) [[nodiscard]] OMATH_API constexpr Type& At(const size_t rowIndex, const size_t columnIndex)
{ {
return const_cast<Type&>(std::as_const(*this).At(rowIndex, columnIndex)); return const_cast<Type&>(std::as_const(*this).At(rowIndex, columnIndex));
} }
[[nodiscard]] [[nodiscard]]
constexpr Type Sum() const noexcept OMATH_API constexpr Type Sum() const noexcept
{ {
Type sum = 0; Type sum = 0;
for (size_t i = 0; i < Rows; ++i) for (size_t i = 0; i < Rows; ++i)
@@ -123,12 +123,12 @@ namespace omath
return sum; return sum;
} }
constexpr void Clear() noexcept OMATH_API constexpr void Clear() noexcept
{ {
Set(0); Set(0);
} }
constexpr void Set(const Type& value) noexcept OMATH_API constexpr void Set(const Type& value) noexcept
{ {
std::ranges::fill(m_data, value); std::ranges::fill(m_data, value);
} }
@@ -136,7 +136,7 @@ namespace omath
// Operator overloading for multiplication with another Mat // Operator overloading for multiplication with another Mat
template<size_t OtherColumns> template<size_t OtherColumns>
constexpr Mat<Rows, OtherColumns, Type, StoreType> constexpr Mat<Rows, OtherColumns, Type, StoreType>
operator*(const Mat<Columns, OtherColumns, Type, StoreType>& other) const OMATH_API operator*(const Mat<Columns, OtherColumns, Type, StoreType>& other) const
{ {
Mat<Rows, OtherColumns, Type, StoreType> result; Mat<Rows, OtherColumns, Type, StoreType> result;
@@ -151,7 +151,7 @@ namespace omath
return result; return result;
} }
constexpr Mat& operator*=(const Type& f) noexcept OMATH_API constexpr Mat& operator*=(const Type& f) noexcept
{ {
for (size_t i = 0; i < Rows; ++i) for (size_t i = 0; i < Rows; ++i)
for (size_t j = 0; j < Columns; ++j) for (size_t j = 0; j < Columns; ++j)
@@ -161,19 +161,19 @@ namespace omath
template<size_t OtherColumns> template<size_t OtherColumns>
constexpr Mat<Rows, OtherColumns, Type, StoreType> constexpr Mat<Rows, OtherColumns, Type, StoreType>
operator*=(const Mat<Columns, OtherColumns, Type, StoreType>& other) OMATH_API operator*=(const Mat<Columns, OtherColumns, Type, StoreType>& other)
{ {
return *this = *this * other; return *this = *this * other;
} }
constexpr Mat operator*(const Type& f) const noexcept OMATH_API constexpr Mat operator*(const Type& f) const noexcept
{ {
Mat result(*this); Mat result(*this);
result *= f; result *= f;
return result; return result;
} }
constexpr Mat& operator/=(const Type& f) noexcept OMATH_API constexpr Mat& operator/=(const Type& f) noexcept
{ {
for (size_t i = 0; i < Rows; ++i) for (size_t i = 0; i < Rows; ++i)
for (size_t j = 0; j < Columns; ++j) for (size_t j = 0; j < Columns; ++j)
@@ -181,14 +181,14 @@ namespace omath
return *this; return *this;
} }
constexpr Mat operator/(const Type& f) const noexcept OMATH_API constexpr Mat operator/(const Type& f) const noexcept
{ {
Mat result(*this); Mat result(*this);
result /= f; result /= f;
return result; return result;
} }
constexpr Mat& operator=(const Mat& other) noexcept OMATH_API constexpr Mat& operator=(const Mat& other) noexcept
{ {
if (this == &other) if (this == &other)
return *this; return *this;
@@ -198,7 +198,7 @@ namespace omath
return *this; return *this;
} }
constexpr Mat& operator=(Mat&& other) noexcept OMATH_API constexpr Mat& operator=(Mat&& other) noexcept
{ {
if (this == &other) if (this == &other)
return *this; return *this;
@@ -211,7 +211,7 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr Mat<Columns, Rows, Type, StoreType> Transposed() const noexcept OMATH_API constexpr Mat<Columns, Rows, Type, StoreType> Transposed() const noexcept
{ {
Mat<Columns, Rows, Type, StoreType> transposed; Mat<Columns, Rows, Type, StoreType> transposed;
for (size_t i = 0; i < Rows; ++i) for (size_t i = 0; i < Rows; ++i)
@@ -222,7 +222,7 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr Type Determinant() const OMATH_API constexpr Type Determinant() const
{ {
static_assert(Rows == Columns, "Determinant is only defined for square matrices."); static_assert(Rows == Columns, "Determinant is only defined for square matrices.");
@@ -244,7 +244,7 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr Mat<Rows - 1, Columns - 1, Type, StoreType> Minor(const size_t row, const size_t column) const OMATH_API constexpr Mat<Rows - 1, Columns - 1, Type, StoreType> Minor(const size_t row, const size_t column) const
{ {
Mat<Rows - 1, Columns - 1, Type, StoreType> result; Mat<Rows - 1, Columns - 1, Type, StoreType> result;
for (size_t i = 0, m = 0; i < Rows; ++i) for (size_t i = 0, m = 0; i < Rows; ++i)
@@ -264,19 +264,19 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr const std::array<Type, Rows * Columns>& RawArray() const OMATH_API constexpr const std::array<Type, Rows * Columns>& RawArray() const
{ {
return m_data; return m_data;
} }
[[nodiscard]] [[nodiscard]]
constexpr std::array<Type, Rows * Columns>& RawArray() OMATH_API constexpr std::array<Type, Rows * Columns>& RawArray()
{ {
return const_cast<std::array<Type, Rows * Columns>>(std::as_const(*this).RawArray()); return const_cast<std::array<Type, Rows * Columns>>(std::as_const(*this).RawArray());
} }
[[nodiscard]] [[nodiscard]]
std::string ToString() const noexcept OMATH_API std::string ToString() const noexcept
{ {
std::ostringstream oss; std::ostringstream oss;
for (size_t i = 0; i < Rows; ++i) for (size_t i = 0; i < Rows; ++i)
@@ -293,20 +293,20 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
bool operator==(const Mat& mat) const OMATH_API bool operator==(const Mat& mat) const
{ {
return m_data == mat.m_data; return m_data == mat.m_data;
} }
[[nodiscard]] [[nodiscard]]
bool operator!=(const Mat& mat) const OMATH_API bool operator!=(const Mat& mat) const
{ {
return !operator==(mat); return !operator==(mat);
} }
// Static methods that return fixed-size matrices // Static methods that return fixed-size matrices
[[nodiscard]] [[nodiscard]]
constexpr static Mat<4, 4> ToScreenMat(const Type& screenWidth, const Type& screenHeight) noexcept OMATH_API constexpr static Mat<4, 4> ToScreenMat(const Type& screenWidth, const Type& screenHeight) noexcept
{ {
return { return {
{screenWidth / 2, 0, 0, 0}, {screenWidth / 2, 0, 0, 0},
@@ -336,7 +336,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR> template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
[[nodiscard]] [[nodiscard]]
constexpr Mat<4, 4, Type, St> MatTranslation(const Vector3& diff) noexcept OMATH_API constexpr Mat<4, 4, Type, St> MatTranslation(const Vector3& diff) noexcept
{ {
return return
{ {
@@ -349,7 +349,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle> template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]] [[nodiscard]]
Mat<4, 4, Type, St> MatRotationAxisX(const Angle& angle) noexcept OMATH_API Mat<4, 4, Type, St> MatRotationAxisX(const Angle& angle) noexcept
{ {
return return
{ {
@@ -362,7 +362,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle> template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]] [[nodiscard]]
Mat<4, 4, Type, St> MatRotationAxisY(const Angle& angle) noexcept OMATH_API Mat<4, 4, Type, St> MatRotationAxisY(const Angle& angle) noexcept
{ {
return return
{ {
@@ -375,7 +375,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle> template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]] [[nodiscard]]
Mat<4, 4, Type, St> MatRotationAxisZ(const Angle& angle) noexcept OMATH_API Mat<4, 4, Type, St> MatRotationAxisZ(const Angle& angle) noexcept
{ {
return return
{ {
@@ -403,7 +403,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class ViewAngles> template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class ViewAngles>
[[nodiscard]] [[nodiscard]]
Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept OMATH_API Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept
{ {
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll); return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
} }

View File

@@ -2,6 +2,7 @@
#include <initializer_list> #include <initializer_list>
#include <memory> #include <memory>
#include <string> #include <string>
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
@@ -10,91 +11,91 @@ namespace omath
class Matrix final class Matrix final
{ {
public: public:
Matrix(); OMATH_API Matrix();
Matrix(size_t rows, size_t columns); OMATH_API Matrix(size_t rows, size_t columns);
Matrix(const std::initializer_list<std::initializer_list<float>>& rows); OMATH_API Matrix(const std::initializer_list<std::initializer_list<float>>& rows);
[[nodiscard]] [[nodiscard]]
static Matrix ToScreenMatrix(float screenWidth, float screenHeight); OMATH_API static Matrix ToScreenMatrix(float screenWidth, float screenHeight);
[[nodiscard]] [[nodiscard]]
static Matrix TranslationMatrix(const Vector3& diff); OMATH_API static Matrix TranslationMatrix(const Vector3& diff);
[[nodiscard]] [[nodiscard]]
static Matrix OrientationMatrix(const Vector3& forward, const Vector3& right, const Vector3& up); OMATH_API static Matrix OrientationMatrix(const Vector3& forward, const Vector3& right, const Vector3& up);
[[nodiscard]] [[nodiscard]]
static Matrix ProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far); OMATH_API static Matrix ProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
Matrix(const Matrix& other); OMATH_API Matrix(const Matrix& other);
Matrix(size_t rows, size_t columns, const float* pRaw); OMATH_API Matrix(size_t rows, size_t columns, const float* pRaw);
Matrix(Matrix&& other) noexcept; OMATH_API Matrix(Matrix&& other) noexcept;
[[nodiscard]] [[nodiscard]]
size_t RowCount() const noexcept; OMATH_API size_t RowCount() const noexcept;
[[nodiscard]] [[nodiscard]]
size_t ColumnsCount() const noexcept; OMATH_API size_t ColumnsCount() const noexcept;
[[nodiscard]] [[nodiscard]]
std::pair<size_t, size_t> Size() const noexcept; OMATH_API std::pair<size_t, size_t> Size() const noexcept;
[[nodiscard]] [[nodiscard]]
float& At(size_t iRow, size_t iCol); OMATH_API float& At(size_t iRow, size_t iCol);
[[nodiscard]] [[nodiscard]]
float Sum(); OMATH_API float Sum();
void SetDataFromRaw(const float* pRawMatrix); OMATH_API void SetDataFromRaw(const float* pRawMatrix);
[[nodiscard]] [[nodiscard]]
Matrix Transpose() const; OMATH_API Matrix Transpose() const;
void Set(float val); OMATH_API void Set(float val);
[[nodiscard]] [[nodiscard]]
const float& At(size_t iRow, size_t iCol) const; OMATH_API const float& At(size_t iRow, size_t iCol) const;
Matrix operator*(const Matrix& other) const; OMATH_API Matrix operator*(const Matrix& other) const;
Matrix& operator*=(const Matrix& other); OMATH_API Matrix& operator*=(const Matrix& other);
Matrix operator*(float f) const; OMATH_API Matrix operator*(float f) const;
Matrix& operator*=(float f); OMATH_API Matrix& operator*=(float f);
Matrix& operator/=(float f); OMATH_API Matrix& operator/=(float f);
void Clear(); OMATH_API void Clear();
[[nodiscard]] [[nodiscard]]
Matrix Strip(size_t row, size_t column) const; OMATH_API Matrix Strip(size_t row, size_t column) const;
[[nodiscard]] [[nodiscard]]
float Minor(size_t i, size_t j) const; OMATH_API float Minor(size_t i, size_t j) const;
[[nodiscard]] [[nodiscard]]
float AlgComplement(size_t i, size_t j) const; OMATH_API float AlgComplement(size_t i, size_t j) const;
[[nodiscard]] [[nodiscard]]
float Determinant() const; OMATH_API float Determinant() const;
[[nodiscard]] [[nodiscard]]
const float* Raw() const; OMATH_API const float* Raw() const;
Matrix& operator=(const Matrix& other); OMATH_API Matrix& operator=(const Matrix& other);
Matrix& operator=(Matrix&& other) noexcept; OMATH_API Matrix& operator=(Matrix&& other) noexcept;
Matrix operator/(float f) const; OMATH_API Matrix operator/(float f) const;
[[nodiscard]] [[nodiscard]]
std::string ToString() const; OMATH_API std::string ToString() const;
~Matrix(); OMATH_API ~Matrix();
private: private:
size_t m_rows; size_t m_rows;

View File

@@ -3,10 +3,11 @@
// //
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
class Triangle3d final class OMATH_API Triangle3d final
{ {
public: public:
Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3); Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3);

View File

@@ -5,11 +5,11 @@
#pragma once #pragma once
#include <tuple> #include <tuple>
#include <cmath> #include <cmath>
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
class Vector2 class OMATH_API Vector2
{ {
public: public:
float x = 0.f; float x = 0.f;

View File

@@ -7,11 +7,11 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include "omath/Vector2.hpp" #include "omath/Vector2.hpp"
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
class Vector3 : public Vector2 class OMATH_API Vector3 : public Vector2
{ {
public: public:
float z = 0.f; float z = 0.f;

View File

@@ -5,11 +5,11 @@
#include <omath/Vector3.hpp> #include <omath/Vector3.hpp>
#include <algorithm> #include <algorithm>
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
class Vector4 : public Vector3 class OMATH_API Vector4 : public Vector3
{ {
public: public:
float w; float w;

View File

@@ -3,10 +3,12 @@
// //
#pragma once #pragma once
#include "omath/omath_export.hpp"
namespace omath namespace omath
{ {
template<class PitchType, class YawType, class RollType> template<class PitchType, class YawType, class RollType>
struct ViewAngles struct OMATH_API ViewAngles
{ {
PitchType pitch; PitchType pitch;
YawType yaw; YawType yaw;

View File

@@ -5,11 +5,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/Triangle3d.hpp" #include "omath/Triangle3d.hpp"
#include "omath/omath_export.hpp"
namespace omath::collision namespace omath::collision
{ {
class Ray class OMATH_API Ray
{ {
public: public:
Vector3 start; Vector3 start;
@@ -21,7 +21,7 @@ namespace omath::collision
[[nodiscard]] [[nodiscard]]
Vector3 DirectionVectorNormalized() const; Vector3 DirectionVectorNormalized() const;
}; };
class LineTracer class OMATH_API LineTracer
{ {
public: public:
LineTracer() = delete; LineTracer() = delete;

View File

@@ -4,14 +4,15 @@
#pragma once #pragma once
#include "Constants.h" #include "Constants.h"
#include "omath/projection/Camera.hpp" #include "omath/projection/Camera.hpp"
#include "omath/omath_export.hpp"
namespace omath::source namespace omath::source
{ {
class Camera final : public projection::Camera<Mat4x4, ViewAngles> class OMATH_API Camera final : public projection::Camera<Mat4x4, ViewAngles>
{ {
public: public:
Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort, Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
const Angle<float, 0, 180, AngleFlags::Clamped>& fov, float near, float far); const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
void LookAt(const Vector3& target) override; void LookAt(const Vector3& target) override;
[[nodiscard]] Mat4x4 GetViewMatrix() const override; [[nodiscard]] Mat4x4 GetViewMatrix() const override;
[[nodiscard]] Mat4x4 GetProjectionMatrix() const override; [[nodiscard]] Mat4x4 GetProjectionMatrix() const override;

View File

@@ -0,0 +1,24 @@
#pragma once
/* Export prefix for functions */
#ifdef _MSC_VER
/* MSVC */
# define OMATH_API_EXPORT __declspec(dllexport)
#else
/* GCC/Clang */
# define OMATH_API_EXPORT __attribute__((visibility("default")))
#endif
/* Import prefix for functions */
#ifdef _MSC_VER
# define OMATH_API_IMPORT __declspec(dllimport)
#else
# define OMATH_API_IMPORT extern
#endif
/* Resolve import/export */
#ifdef OMATH_EXPORT
# define OMATH_API OMATH_API_EXPORT
#else
# define OMATH_API OMATH_API_IMPORT
#endif

View File

@@ -6,11 +6,11 @@
#include <vector> #include <vector>
#include "NavigationMesh.hpp" #include "NavigationMesh.hpp"
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/omath_export.hpp"
namespace omath::pathfinding namespace omath::pathfinding
{ {
class Astar final class OMATH_API Astar final
{ {
public: public:
[[nodiscard]] [[nodiscard]]

View File

@@ -8,7 +8,7 @@
#include <expected> #include <expected>
#include <vector> #include <vector>
#include <string> #include <string>
#include "omath/omath_export.hpp"
namespace omath::pathfinding namespace omath::pathfinding
{ {
@@ -23,16 +23,16 @@ namespace omath::pathfinding
public: public:
[[nodiscard]] [[nodiscard]]
std::expected<Vector3, std::string> GetClosestVertex(const Vector3& point) const; OMATH_API std::expected<Vector3, std::string> GetClosestVertex(const Vector3& point) const;
[[nodiscard]] [[nodiscard]]
const std::vector<Vector3>& GetNeighbors(const Vector3& vertex) const; OMATH_API const std::vector<Vector3>& GetNeighbors(const Vector3& vertex) const;
[[nodiscard]] [[nodiscard]]
bool Empty() const; OMATH_API bool Empty() const;
[[nodiscard]] std::vector<uint8_t> Serialize() const; [[nodiscard]] std::vector<uint8_t> Serialize() const;
void Deserialize(const std::vector<uint8_t>& raw); OMATH_API void Deserialize(const std::vector<uint8_t>& raw);
std::unordered_map<Vector3, std::vector<Vector3>> m_verTextMap; std::unordered_map<Vector3, std::vector<Vector3>> m_verTextMap;
}; };

View File

@@ -8,11 +8,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/prediction/Projectile.hpp" #include "omath/prediction/Projectile.hpp"
#include "omath/prediction/Target.hpp" #include "omath/prediction/Target.hpp"
#include "omath/omath_export.hpp"
namespace omath::prediction namespace omath::prediction
{ {
class Engine final class OMATH_API Engine final
{ {
public: public:
explicit Engine(float gravityConstant, float simulationTimeStep, explicit Engine(float gravityConstant, float simulationTimeStep,

View File

@@ -4,11 +4,11 @@
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/omath_export.hpp"
namespace omath::prediction namespace omath::prediction
{ {
class Projectile final class OMATH_API Projectile final
{ {
public: public:

View File

@@ -4,11 +4,11 @@
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/omath_export.hpp"
namespace omath::prediction namespace omath::prediction
{ {
class Target final class OMATH_API Target final
{ {
public: public:

View File

@@ -10,11 +10,11 @@
#include "ErrorCodes.hpp" #include "ErrorCodes.hpp"
#include <omath/Angle.hpp> #include <omath/Angle.hpp>
#include <type_traits> #include <type_traits>
#include "omath/omath_export.hpp"
namespace omath::projection namespace omath::projection
{ {
class ViewPort final class OMATH_API ViewPort final
{ {
public: public:
float m_width; float m_width;
@@ -28,7 +28,7 @@ namespace omath::projection
using FieldOfView = const Angle<float, 0.f, 180.f, AngleFlags::Clamped>; using FieldOfView = const Angle<float, 0.f, 180.f, AngleFlags::Clamped>;
template<class Mat4x4Type, class ViewAnglesType> template<class Mat4x4Type, class ViewAnglesType>
class Camera class OMATH_API Camera
{ {
public: public: