refactor shared
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <stdexcept>
|
||||
#include <array> // Include array for std::array::at
|
||||
|
||||
namespace Basalt::Shared::Math {
|
||||
|
||||
@@ -7,19 +8,26 @@ namespace Basalt::Shared::Math {
|
||||
|
||||
struct Vector3 {
|
||||
FloatPoint x, y, z;
|
||||
};
|
||||
struct Vector4 {
|
||||
FloatPoint x, y, z, w;
|
||||
};
|
||||
struct Matrix4x4 {
|
||||
Vector4 data[4];
|
||||
|
||||
FloatPoint& operator[](size_t index);
|
||||
const FloatPoint& operator[](size_t index) const;
|
||||
};
|
||||
|
||||
//template<typename TEle, size_t VCnt>
|
||||
// requires(std::integral<TEle> || std::floating_point<TEle>)
|
||||
//struct Vector {
|
||||
// TEle factor[VCnt];
|
||||
//};
|
||||
struct Vector4 {
|
||||
FloatPoint x, y, z, w;
|
||||
|
||||
FloatPoint& operator[](size_t index);
|
||||
const FloatPoint& operator[](size_t index) const;
|
||||
};
|
||||
|
||||
struct Matrix4x4 {
|
||||
private:
|
||||
std::array<Vector4, 4> data; // Use std::array instead of raw array for .at() method
|
||||
|
||||
public:
|
||||
Vector4& operator[](size_t index);
|
||||
const Vector4& operator[](size_t index) const;
|
||||
};
|
||||
|
||||
#define NOT_IMPLEMENTED throw std::logic_error("not implemented function");
|
||||
|
||||
@@ -31,4 +39,4 @@ namespace Basalt::Shared::Math {
|
||||
|
||||
#undef NOT_IMPLEMENTED
|
||||
|
||||
} // namespace Basalt::Shared::Math
|
||||
} // namespace Basalt::Shared::Math
|
||||
Reference in New Issue
Block a user