|
Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
|
GPU mesh representation with support for instanced rendering. More...
#include <Mesh.h>
Public Member Functions | |
| Mesh (const std::vector< Vertex > &verts, const std::vector< unsigned int > &idx, QOpenGLFunctions_4_5_Core *funcs) | |
| Constructs a mesh from vertex and index data. | |
| ~Mesh () | |
| Destroys the mesh and releases GPU resources. | |
| void | draw () const |
| Draws a single instance of this mesh. | |
| void | drawInstanced (const std::vector< Rendering::InstanceData > &instances) |
| Draws multiple instances of this mesh in a single draw call. | |
| std::span< const Vertex > | getVertices () const |
| Provides read-only view of vertex data without copying. | |
| std::span< const unsigned int > | getIndices () const |
| Provides read-only view of index data without copying. | |
| const Physics::Bounding::AABB & | getLocalAABB () const |
| Gets the local-space axis-aligned bounding box. | |
GPU mesh representation with support for instanced rendering.
Manages vertex data, indices, and GPU buffers for a single mesh. Supports both standard and instanced rendering. Meshes are immutable after construction - vertex and index data cannot be modified.
| Mesh::Mesh | ( | const std::vector< Vertex > & | verts, |
| const std::vector< unsigned int > & | idx, | ||
| QOpenGLFunctions_4_5_Core * | funcs | ||
| ) |
Constructs a mesh from vertex and index data.
Uploads data to GPU and sets up vertex attributes for rendering. Automatically computes a local-space AABB for the mesh.
| verts | Vertex data (positions, normals) |
| idx | Index buffer for indexed drawing |
| funcs | OpenGL function pointers for the current context |
| Mesh::~Mesh | ( | ) |
| void Mesh::draw | ( | ) | const |
| void Mesh::drawInstanced | ( | const std::vector< Rendering::InstanceData > & | instances | ) |
Draws multiple instances of this mesh in a single draw call.
More efficient than multiple draw() calls for rendering many copies of the same mesh with different transforms/properties.
| instances | Per-instance data (transforms, IDs, colors, etc.) |
Definition at line 78 of file Mesh.cpp.
| std::span< const unsigned int > Mesh::getIndices | ( | ) | const |
Provides read-only view of index data without copying.
Returns a non-owning view over the mesh's index array.
Definition at line 95 of file Mesh.cpp.
|
inline |
Gets the local-space axis-aligned bounding box.
The AABB is computed during construction and represents the tightest axis-aligned box that contains all vertices.
Definition at line 163 of file Mesh.h.
| std::span< const Vertex > Mesh::getVertices | ( | ) | const |
Provides read-only view of vertex data without copying.
Returns a non-owning view over the mesh's vertex array.
for (const auto& v : span) Definition at line 91 of file Mesh.cpp.