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
{
struct Vertex
template<class T = Vector3<float>>
struct Vertex final
{
using VectorType = Vector3<float>;
Vector3<float> position;
Vector3<float> normal;
Vector3<float> uv;
using VectorType = T;
VectorType position;
VectorType normal;
VectorType uv;
};
template<typename T> concept HasPosition = requires(T vertex) { vertex.position; };
template<typename T> concept HasNormal = requires(T vertex) { vertex.normal; };
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
{
public:
using NumericType = float;
using VertexType = Vertex;
using VertexType = VertType;
private:
using Vbo = std::vector<VertexType>;
using Vao = std::vector<Vector3<std::size_t>>;

View File

@@ -8,7 +8,7 @@
TEST(UnitTestColider, CheckToWorld)
{
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 }, {}, {} }
},

View File

@@ -14,7 +14,7 @@ using EPA = omath::collision::Epa<Collider>;
TEST(UnitTestEpa, TestCollisionTrue)
{
// 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}, {}, {} },
@@ -88,7 +88,7 @@ TEST(UnitTestEpa, TestCollisionTrue)
}
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 }, {}, {} },