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

◆ build() [4/5]

std::shared_ptr< Buffers::MeshNetworkBuffer > MayaFlux::Mint::Impl::build ( const StructureConfig::Model &  config) const
inline

Definition at line 147 of file Mint.cpp.

149 {
150 if (!has_target(config.render)) {
151 return nullptr;
152 }
153
154 auto network = config.network
155 ? config.network
156 : std::make_shared<Nodes::Network::MeshNetwork>();
157 const auto first_component_slot = static_cast<uint32_t>(network->slot_count());
158
159 for (size_t index = 0; index < config.components.size(); ++index) {
160 const auto& component = config.components[index];
161 auto writer = resolve_writer(
162 component.mesh, component.expression, component.writer, "Model component");
163 if (!writer) {
164 return nullptr;
165 }
166
167 if (component.parent_component && component.parent_slot) {
169 "mint: Model component {} cannot name both a component and slot parent",
170 index);
171 return nullptr;
172 }
173
174 std::optional<uint32_t> parent;
175 if (component.parent_component) {
176 if (*component.parent_component >= index) {
178 "mint: Model component {} must name an earlier component as parent",
179 index);
180 return nullptr;
181 }
182 parent = first_component_slot + *component.parent_component;
183 } else if (component.parent_slot) {
184 if (*component.parent_slot >= first_component_slot) {
186 "mint: Model component {} parent slot is not in the supplied network",
187 index);
188 return nullptr;
189 }
190 parent = component.parent_slot;
191 }
192
193 const uint32_t slot_index = network->add_slot(
194 "component_" + std::to_string(index), writer, parent);
195 network->get_slot(slot_index).local_transform = component.local_transform;
196 }
197
198 if (network->slot_count() == 0) {
200 "mint: Model requires at least one mesh component");
201 return nullptr;
202 }
203
204 register_network_if_needed(network);
205 auto buffer = std::make_shared<Buffers::MeshNetworkBuffer>(
206 network, config.over_allocate_factor);
207 StructureConfig::RenderConfig render = config.render;
208 bind_mesh_textures(buffer, render, config.textures);
210 buffer->setup_rendering(render);
211 return buffer;
212 }
#define MF_ERROR(comp, ctx,...)
Core::GlobalNetworkConfig network
Definition Config.cpp:43
std::vector< uint32_t > parent
std::shared_ptr< NetworkGeometryBuffer > buffer
uint32_t index
Definition VKDevice.cpp:122
@ Init
Engine/subsystem initialization.
@ API
MayaFlux/API Wrapper and convenience functions.
void register_graphics_buffer(const std::shared_ptr< Buffers::VKBuffer > &buffer, Buffers::ProcessingToken token)
Registers a VKBuffer with the default engine's buffer manager.
Definition Graph.cpp:250
Buffers::VKBuffer::RenderConfig RenderConfig
Render target and pipeline overrides.

References MayaFlux::Journal::API, buffer, MayaFlux::StructureConfig::Model::components, index, MayaFlux::Journal::Init, MF_ERROR, network, MayaFlux::StructureConfig::Model::network, MayaFlux::StructureConfig::Model::over_allocate_factor, parent, MayaFlux::register_graphics_buffer(), MayaFlux::StructureConfig::Model::render, and MayaFlux::StructureConfig::Model::textures.

+ Here is the call graph for this function: