MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ get_mesh_data()

std::optional< Kakshya::MeshData > MayaFlux::Nodes::Network::MeshNetwork::get_mesh_data ( ) const

Every slot's geometry merged into one MeshData, one submesh per slot.

Slots with no node or no geometry are skipped. Each submesh is named for its slot, or by its index when the slot is unnamed, and its indices are offset into the shared vertex array. Vertices are in each slot's local space: no slot or world transform is applied.

Returns
The merged mesh, or nullopt when no slot has geometry.

Definition at line 236 of file MeshNetwork.cpp.

237{
238 auto mesh_data = Kakshya::MeshData::empty();
239 Kakshya::MeshInsertion ins(mesh_data.vertex_variant, mesh_data.index_variant);
240
241 for (const auto& slot : m_slots) {
242 if (!slot.node) {
243 continue;
244 }
245
246 const auto packed = slot.node->get_mesh_data();
247 if (!packed) {
248 continue;
249 }
250
251 ins.insert_submesh(
252 std::get<std::vector<uint8_t>>(packed->vertex_variant),
253 std::get<std::vector<uint32_t>>(packed->index_variant),
254 slot.name.empty() ? std::to_string(slot.index) : slot.name,
255 {},
256 packed->layout);
257 }
258
259 const auto access = ins.build();
260 if (!access) {
261 return std::nullopt;
262 }
263 mesh_data.layout = access->layout;
264 mesh_data.submeshes = access->submeshes;
265
266 return mesh_data;
267}
std::string name
Definition VKDevice.cpp:123
static MeshData empty()
Construct an empty MeshData with the canonical 60-byte mesh layout.
Definition MeshData.hpp:49

References MayaFlux::Kakshya::MeshInsertion::build(), MayaFlux::Kakshya::MeshData::empty(), MayaFlux::Kakshya::MeshInsertion::insert_submesh(), and m_slots.

+ Here is the call graph for this function: