using Engine.Graphics.Buffer.Vertex;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;

namespace Engine.Asset.Mesh;

public class Mesh
{
  public IReadOnlyList<Vertex> Vertices => _vertices;
  public IReadOnlyList<uint> Indices => _indices;

  internal IList<Vertex> VerticesInternal => _vertices;
  internal IList<uint> IndicesInternal => _indices;

  private readonly List<Vertex> _vertices = [];
  private readonly List<uint> _indices = [];

  public override int GetHashCode()
  {
    return HashCode.Combine(Indices, Vertices);
  }

  public record struct Vertex : IVertex
  {
    [Vertex(VertexAttribType.Float, 3)] public Vector3 _position;

    [Vertex(VertexAttribType.Float, 3)] public Vector3 _normal;

    [Vertex(VertexAttribType.Float, 2)] public Vector2 _uv;
  }
}