2#include <QOpenGLFunctions_4_5_Core>
37 size_t h1 = hash<float>()(v.
pos.x) ^ (hash<float>()(v.
pos.y) << 1) ^ (hash<float>()(v.
pos.z) << 2);
38 size_t h2 = hash<float>()(v.
normal.x) ^ (hash<float>()(v.
normal.y) << 1) ^ (hash<float>()(v.
normal.z) << 2);
39 return h1 ^ (h2 << 1);
75 Mesh(
const std::vector<Vertex>& verts,
const std::vector<unsigned int>& idx, QOpenGLFunctions_4_5_Core* funcs);
110 void drawInstanced(
const std::vector<Rendering::InstanceData>& instances);
150 std::span<const unsigned int>
getIndices()
const;
165 QOpenGLFunctions_4_5_Core* funcs;
166 std::vector<Vertex> vertices;
167 std::vector<unsigned int> indices;
172 unsigned int instanceVBO;
174 unsigned int indexCount;
189 void setupInstanceAttributes();
199 void createLocalAABB();
GPU mesh representation with support for instanced rendering.
~Mesh()
Destroys the mesh and releases GPU resources.
void draw() const
Draws a single instance of this mesh.
std::span< const Vertex > getVertices() const
Provides read-only view of vertex data without copying.
const Physics::Bounding::AABB & getLocalAABB() const
Gets the local-space axis-aligned bounding box.
std::span< const unsigned int > getIndices() const
Provides read-only view of index data without copying.
void drawInstanced(const std::vector< Rendering::InstanceData > &instances)
Draws multiple instances of this mesh in a single draw call.
Hash specialization for Vertex to enable use in unordered containers.
Vertex data for a single vertex in a mesh.
glm::vec3 normal
Surface normal.
bool operator==(const Vertex &other) const
Equality comparison for vertex deduplication.
glm::vec3 pos
Position in local/model space.
size_t operator()(const Vertex &v) const