9#ifndef AVARA3D_MESH_MESHELEMENT_H
10#define AVARA3D_MESH_MESHELEMENT_H
18#include "a3d/Assert.h"
20#include "a3d/mesh/AABB.h"
21#include "a3d/mesh/IndexFormats.h"
22#include "a3d/mesh/PrimitiveTopology.h"
23#include "a3d/mesh/VertexLayout.h"
24#include "a3d/util/Bitmask.h"
66 std::span<const std::byte> vertexBytes,
68 uint16_t vertexStride,
69 PrimitiveTopology topology,
70 IndexFormat indexFormat,
71 std::span<const std::byte> indexBytes,
77 enum class DirtyMask : uint32_t {
87 PrimitiveTopology topology()
const;
89 VertexLayout vertexLayout()
const;
90 uint32_t vertexCount()
const;
91 std::span<const std::byte> vertexBytes()
const;
92 uint16_t vertexStride()
const;
94 IndexFormat indexFormat()
const;
95 uint32_t indexCount()
const;
96 std::span<const std::byte> indexBytes()
const;
98 const AABB& localAABB()
const;
103 void beginBuild(VertexLayout layout,
104 uint16_t vertexStride,
105 PrimitiveTopology topology,
106 IndexFormat indexFormat,
107 uint32_t reserveVerts = 0,
108 uint32_t reserveIndices = 0);
109 void appendVertexBytes(
const void* vertexBytes);
110 void appendIndex(uint32_t idx);
111 void appendTriangle(uint32_t a, uint32_t b, uint32_t c);
112 void endBuild(
bool recomputeAABB =
true);
114 void burnTransform(
const math::mat4& transform,
bool normals);
116 DirtyMask dirtyMask()
const;
117 void dirtyMask(DirtyMask mask);
130 PrimitiveTopology _topology;
131 VertexLayout _vertexLayout;
132 std::vector<std::byte> _vertexData;
133 uint32_t _vertexCount;
134 uint16_t _vertexStride;
135 IndexFormat _indexFormat;
136 std::vector<std::byte> _indexData;
137 uint32_t _indexCount;
139 DirtyMask _dirtyMask;
142 namespace util::bitmask {
145 struct enable_ops<MeshElement::DirtyMask> : std::true_type {};
Owns the vertex and optional index data for one mesh primitive.
MeshElement(VertexLayout layout, std::span< const std::byte > vertexBytes, uint32_t vertexCount, uint16_t vertexStride, PrimitiveTopology topology, IndexFormat indexFormat, std::span< const std::byte > indexBytes, uint32_t indexCount)
Creates a MeshElement by copying the supplied vertex and index data.
Axis-aligned bounding box defined by minimum and maximum corners.