|
| | IndexBuffer () |
| | Default constructor.
|
| |
| | IndexBuffer (const size_t size, IndexType type=IndexType::UInt16, Topology topology=Topology::Triangles) |
| | Constructs an index buffer with pre-allocated capacity.
|
| |
| | IndexBuffer (const Containers::Array< uint16_t > &indices, Topology topology=Topology::Triangles) |
| | Constructs an index buffer from a 16-bit index array.
|
| |
| | IndexBuffer (const Containers::Array< uint32_t > &indices, Topology topology=Topology::Triangles) |
| | Constructs an index buffer from a 32-bit index array.
|
| |
| virtual | ~IndexBuffer () |
| | Destructor.
|
| |
| std::unique_ptr< Core::Base > | clone () const override |
| |
| void | reserve (size_t capacity) |
| | Pre-allocates storage for a specified number of indices.
|
| |
| void | clear () |
| | Removes all indices from the buffer.
|
| |
| uint32_t | operator[] (size_t index) const |
| | Accesses an index value (unchecked).
|
| |
| uint32_t | at (size_t index) const |
| | Accesses an index value (checked).
|
| |
| void | setIndex (size_t index, uint32_t value) |
| | Sets the value of an existing index.
|
| |
| void | pushIndex (uint16_t index) |
| | Appends a single 16-bit index.
|
| |
| void | pushIndex (uint32_t index) |
| | Appends a single 32-bit index.
|
| |
| void | pushTriangle (uint16_t v0, uint16_t v1, uint16_t v2) |
| | Appends three 16-bit indices forming a triangle.
|
| |
| void | pushTriangle (uint32_t v0, uint32_t v1, uint32_t v2) |
| | Appends three 32-bit indices forming a triangle.
|
| |
| void | pushQuad (uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3) |
| | Appends indices for a quad (as two triangles).
|
| |
| void | pushQuad (uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3) |
| | Appends indices for a quad (as two triangles).
|
| |
| void | pushLine (uint16_t v0, uint16_t v1) |
| | Appends two 16-bit indices forming a line segment.
|
| |
| void | pushLine (uint32_t v0, uint32_t v1) |
| | Appends two 32-bit indices forming a line segment.
|
| |
| void | pushIndices (const Containers::Array< uint16_t > &indices) |
| | Appends multiple 16-bit indices from an array.
|
| |
| void | pushIndices (const Containers::Array< uint32_t > &indices) |
| | Appends multiple 32-bit indices from an array.
|
| |
| Core::span< const uint16_t > | asUInt16Buffer () const |
| | Gets a const span view of the data as 16-bit indices.
|
| |
| Core::span< uint16_t > | asUInt16Buffer () |
| | Gets a mutable span view of the data as 16-bit indices.
|
| |
| Core::span< const uint32_t > | asUInt32Buffer () const |
| | Gets a const span view of the data as 32-bit indices.
|
| |
| Core::span< uint32_t > | asUInt32Buffer () |
| | Gets a mutable span view of the data as 32-bit indices.
|
| |
| size_t | count () const |
| | Gets the number of indices in the buffer.
|
| |
| const Infinity::Types::TypeID & | typeId () const override |
| | Gets the TypeID for IndexBuffer.
|
| |
| | Data () |
| |
| | Data (const Data &other) |
| |
| | Data (Data &&other) |
| |
| Data & | operator= (const Data &other) |
| |
| Data & | operator= (Data &&other) |
| |
| virtual | ~Data () |
| | Virtual destructor.
|
| |
| bool | hasProperty (const std::string &key) const |
| |
| template<typename T > |
| void | setProperty (const std::string &key, T &&value) |
| | Sets a typed property value.
|
| |
| template<typename T > |
| void | setProperty (const std::string &key, const T &value) |
| | Sets a typed property value.
|
| |
| void | setProperty (const std::string &key, PropertyValue &&value) |
| | Sets a typed property value.
|
| |
| const PropertyValue & | getProperty (const std::string &key) const |
| | Gets a property value without type checking.
|
| |
| template<typename T > |
| const T & | getProperty (const std::string &key) const |
| | Gets a typed property value.
|
| |
| void | removeProperty (const std::string &key) |
| |
| virtual | ~Base () |
| | Virtual destructor.
|
| |
| virtual std::istream & | legibleDataRead (std::istream &in) override |
| | Deserializes the object from a single-line text representation.
|
| |
| virtual std::ostream & | legibleDataWrite (std::ostream &out) const override |
| | Serializes the object to a single-line text representation.
|
| |
Container for mesh index data defining vertex connectivity and topology.
IndexBuffer stores indices that define how vertices from a VertexBuffer are connected to form geometric primitives (triangles, lines, etc.). It provides efficient mesh representation by allowing vertices to be reused across multiple primitives, reducing memory usage and improving rendering performance.
The index buffer supports:
- Two index formats: 16-bit (up to 65,535 vertices) or 32-bit (billions of vertices)
- Multiple topologies: Triangles, Lines, TriangleStrip, Quads
- Convenient primitive methods: pushTriangle(), pushQuad(), pushLine()
- Dynamic construction: Build indices incrementally during mesh generation
- Type-safe access: Automatic handling of 16-bit vs 32-bit indices
Index ordering determines face winding and visibility. Counter-clockwise (CCW) winding is the default front-facing convention in most rendering systems.
Common use cases:
- Procedural mesh generation (terrain, shapes, buildings)
- Mesh optimization and vertex sharing
- LOD (Level of Detail) mesh construction
- Dynamic mesh modification
- Wireframe and debug visualization
- Note
- Use UInt16 for meshes with < 65,536 vertices (more memory efficient).
-
Use UInt32 for large meshes exceeding 65,535 vertices.
-
Triangle topology is most common for solid geometry rendering.
-
All index values must be valid vertex indices in the associated VertexBuffer.
Example usage:
for (uint32_t z = 0; z < height - 1; ++z) {
for (uint32_t x = 0; x < width - 1; ++x) {
uint32_t topLeft = z * width + x;
uint32_t topRight = topLeft + 1;
uint32_t bottomLeft = (z + 1) * width + x;
uint32_t bottomRight = bottomLeft + 1;
terrainIndices.pushTriangle(topLeft, bottomLeft, topRight);
terrainIndices.pushTriangle(topRight, bottomLeft, bottomRight);
}
}
for (size_t i = 0; i < triangleCount; ++i) {
uint16_t v0 = triangles[i * 3 + 0];
uint16_t v1 = triangles[i * 3 + 1];
uint16_t v2 = triangles[i * 3 + 2];
wireframe.pushLine(v0, v1);
wireframe.pushLine(v1, v2);
wireframe.pushLine(v2, v0);
}
size_t triangleCount = 1000;
optimized.reserve(triangleCount * 3);
system->setIn("mesh_indices", std::move(indices));
Container for mesh index data defining vertex connectivity and topology.
Definition IndexBuffer.hpp:89
@ Lines
Each 2 indices form an independent line segment.
IndexBuffer()
Default constructor.
void pushTriangle(uint16_t v0, uint16_t v1, uint16_t v2)
Appends three 16-bit indices forming a triangle.
void pushQuad(uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3)
Appends indices for a quad (as two triangles).
@ UInt16
16-bit indices (0-65,535 vertices, more memory efficient)
@ UInt32
32-bit indices (0-4,294,967,295 vertices, for large meshes)