149 {
150 if (!has_target(config.render)) {
151 return nullptr;
152 }
153
155 ? config.network
156 : std::make_shared<Nodes::Network::MeshNetwork>();
157 const auto first_component_slot =
static_cast<uint32_t
>(
network->slot_count());
158
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",
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",
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",
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);
208 bind_mesh_textures(
buffer, render, config.textures);
210 buffer->setup_rendering(render);
212 }
#define MF_ERROR(comp, ctx,...)
Core::GlobalNetworkConfig network
std::vector< uint32_t > parent
std::shared_ptr< NetworkGeometryBuffer > buffer
@ 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.
Buffers::VKBuffer::RenderConfig RenderConfig
Render target and pipeline overrides.