added template arg to Vertex struct

This commit is contained in:
2025-11-29 16:31:24 +03:00
parent ba267cbcb8
commit 99ebdeb188
3 changed files with 11 additions and 10 deletions

View File

@@ -11,24 +11,25 @@
namespace omath::primitives namespace omath::primitives
{ {
struct Vertex template<class T = Vector3<float>>
struct Vertex final
{ {
using VectorType = Vector3<float>; using VectorType = T;
Vector3<float> position; VectorType position;
Vector3<float> normal; VectorType normal;
Vector3<float> uv; VectorType uv;
}; };
template<typename T> concept HasPosition = requires(T vertex) { vertex.position; }; template<typename T> concept HasPosition = requires(T vertex) { vertex.position; };
template<typename T> concept HasNormal = requires(T vertex) { vertex.normal; }; template<typename T> concept HasNormal = requires(T vertex) { vertex.normal; };
template<typename T> concept HasUv = requires(T vertex) { vertex.uv; }; template<typename T> concept HasUv = requires(T vertex) { vertex.uv; };
template<class Mat4X4, class RotationAngles, class MeshTypeTrait, class VertType = Vertex> template<class Mat4X4, class RotationAngles, class MeshTypeTrait, class VertType = Vertex<>>
class Mesh final class Mesh final
{ {
public: public:
using NumericType = float; using NumericType = float;
using VertexType = Vertex; using VertexType = VertType;
private: private:
using Vbo = std::vector<VertexType>; using Vbo = std::vector<VertexType>;
using Vao = std::vector<Vector3<std::size_t>>; using Vao = std::vector<Vector3<std::size_t>>;

View File

@@ -8,7 +8,7 @@
TEST(UnitTestColider, CheckToWorld) TEST(UnitTestColider, CheckToWorld)
{ {
omath::source_engine::Mesh mesh = { omath::source_engine::Mesh mesh = {
std::vector<omath::primitives::Vertex>{ std::vector<omath::primitives::Vertex<>>{
{ { 1.f, 1.f, 1.f }, {}, {} }, { { 1.f, 1.f, 1.f }, {}, {} },
{ {-1.f, -1.f, -1.f }, {}, {} } { {-1.f, -1.f, -1.f }, {}, {} }
}, },

View File

@@ -14,7 +14,7 @@ using EPA = omath::collision::Epa<Collider>;
TEST(UnitTestEpa, TestCollisionTrue) TEST(UnitTestEpa, TestCollisionTrue)
{ {
// Unit cube [-1,1]^3 // Unit cube [-1,1]^3
std::vector<omath::primitives::Vertex> vbo = { std::vector<omath::primitives::Vertex<>> vbo = {
{ {-1.f, -1.f, -1.f}, {}, {} }, { {-1.f, -1.f, -1.f}, {}, {} },
{ {-1.f, -1.f, 1.f}, {}, {} }, { {-1.f, -1.f, 1.f}, {}, {} },
{ {-1.f, 1.f, -1.f}, {}, {} }, { {-1.f, 1.f, -1.f}, {}, {} },
@@ -88,7 +88,7 @@ TEST(UnitTestEpa, TestCollisionTrue)
} }
TEST(UnitTestEpa, TestCollisionTrue2) TEST(UnitTestEpa, TestCollisionTrue2)
{ {
std::vector<omath::primitives::Vertex> vbo = { std::vector<omath::primitives::Vertex<>> vbo = {
{ { -1.f, -1.f, -1.f }, {}, {} }, { { -1.f, -1.f, -1.f }, {}, {} },
{ { -1.f, -1.f, 1.f }, {}, {} }, { { -1.f, -1.f, 1.f }, {}, {} },
{ { -1.f, 1.f, -1.f }, {}, {} }, { { -1.f, 1.f, -1.f }, {}, {} },