MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::MeshNetwork Class Reference

NodeNetwork subclass whose nodes are named, hierarchically transformable mesh slots. More...

#include <MeshNetwork.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::MeshNetwork:
+ Collaboration diagram for MayaFlux::Nodes::Network::MeshNetwork:

Public Member Functions

uint32_t add_slot (std::string name, std::shared_ptr< GpuSync::MeshWriterNode > node, std::optional< uint32_t > parent=std::nullopt)
 Add a slot to the network.
 
template<typename OpType , typename... Args>
std::shared_ptr< OpType > create_operator (Args &&... args)
 Construct and set the primary operator in one call.
 
void ensure_sorted ()
 Ensure the slot processing order is up to date.
 
MeshSlotfind_slot (std::string_view name)
 Find a slot by name.
 
const MeshSlotfind_slot (std::string_view name) const
 
std::optional< uint32_t > find_slot_index (std::string_view name) const
 Find the index of a slot by name.
 
std::unordered_map< std::string, std::string > get_metadata () const override
 Get network metadata for debugging/visualization.
 
size_t get_node_count () const override
 Get the number of nodes in the network.
 
std::optional< double > get_node_output (size_t index) const override
 Get output of specific internal node (for ONE_TO_ONE mapping)
 
const NetworkOperatorget_operator () const override
 
NetworkOperatorget_operator () override
 
MeshSlotget_slot (uint32_t index)
 Return the slot at the given index.
 
const MeshSlotget_slot (uint32_t index) const
 
bool has_operator () const override
 
 MeshNetwork ()
 
void process_batch (unsigned int num_samples) override
 Process the network for the given number of samples.
 
void reset () override
 Reset network to initial state.
 
void set_operator (std::shared_ptr< NetworkOperator > op)
 Replace the primary operator.
 
size_t slot_count () const
 Number of slots in the network.
 
std::vector< MeshSlot > & slots ()
 
const std::vector< MeshSlot > & slots () const
 Read-only access to the full slot list.
 
const std::vector< uint32_t > & sorted_indices () const
 Get the processing order of slots as indices into m_slots.
 
 ~MeshNetwork () override=default
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void add_channel_usage (uint32_t channel_id)
 Register network usage on a specific channel.
 
virtual std::optional< std::vector< double > > get_audio_buffer () const
 Get cached audio buffer from last process_batch()
 
uint32_t get_block_size () const
 
uint32_t get_channel_mask () const
 Get channel mask (bitfield of registered channels)
 
virtual std::optional< std::span< const double > > get_node_audio_buffer (size_t) const
 Get output of specific internal node as audio buffer (for ONE_TO_ONE mapping)
 
std::shared_ptr< OperatorChainget_operator_chain () const
 Access the secondary operator chain.
 
OutputMode get_output_mode () const
 Get the current output routing mode.
 
double get_output_scale () const
 Get the current output scale factor.
 
std::vector< uint32_t > get_registered_channels () const
 Get all channels this network is registered on.
 
RoutingStateget_routing_state ()
 Retrieves the current routing state of the network (non-const)
 
const RoutingStateget_routing_state () const
 Retrieves the current routing state of the network.
 
uint32_t get_sample_rate () const
 
Topology get_topology () const
 Get the current topology.
 
virtual void initialize ()
 Called once before first process_batch()
 
bool is_enabled () const
 Check if network is enabled.
 
bool is_processed_this_cycle () const
 Check if network has been processed this cycle (lock-free)
 
bool is_processing () const
 Check if network is currently processing (lock-free)
 
bool is_registered_on_channel (uint32_t channel_id) const
 Check if network is registered on a channel.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< Node > &source, MappingMode mode=MappingMode::BROADCAST)
 Map external node output to network parameter.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< NodeNetwork > &source_network)
 Map external node network to network parameters (ONE_TO_ONE)
 
void mark_processed (bool processed)
 Mark network as processed this cycle (lock-free)
 
void mark_processing (bool processing)
 Mark network as processing or not (lock-free)
 
bool needs_channel_routing () const
 Checks if the network is currently in a routing transition phase.
 
void remove_channel_usage (uint32_t channel_id)
 Unregister network from a specific channel.
 
void request_reset_from_channel (uint32_t channel_id)
 Request a reset from a specific channel.
 
void set_block_size (uint32_t block_size)
 
void set_channel_mask (uint32_t mask)
 Set channel mask directly.
 
void set_enabled (bool enabled)
 Enable/disable the network.
 
void set_output_mode (OutputMode mode)
 Set the network's output routing mode.
 
void set_output_scale (double scale)
 Set the scalar multiplier applied to the network's output buffer after processing.
 
void set_sample_rate (uint32_t sample_rate)
 
virtual void set_topology (Topology topology)
 Set the network's topology.
 
virtual void unmap_parameter (const std::string &param_name)
 Remove parameter mapping.
 
virtual ~NodeNetwork ()=default
 

Private Member Functions

void propagate_world_transforms ()
 
void rebuild_sort ()
 

Private Attributes

std::shared_ptr< NetworkOperatorm_operator
 
std::vector< MeshSlotm_slots
 
bool m_sort_dirty { true }
 Set when add_slot() changes the DAG and a re-sort is needed.
 
std::vector< uint32_t > m_sorted_indices
 Processing order: indices into m_slots, parents before children.
 

Additional Inherited Members

- Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void apply_output_scale ()
 Apply m_output_scale to m_last_audio_buffer.
 
void ensure_initialized ()
 Ensure initialize() is called exactly once.
 
- Static Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
static std::unordered_map< size_t, std::vector< size_t > > build_chain_neighbors (size_t count)
 Build neighbor map for CHAIN topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_2d_neighbors (size_t width, size_t height)
 Build neighbor map for GRID_2D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_3d_neighbors (size_t width, size_t height, size_t depth)
 Build neighbor map for GRID_3D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_ring_neighbors (size_t count)
 Build neighbor map for RING topology.
 
- Protected Attributes inherited from MayaFlux::Nodes::Network::NodeNetwork
std::atomic_flag m_audio_buffer_lock = ATOMIC_FLAG_INIT
 Spinlock guarding m_last_audio_buffer.
 
uint32_t m_block_size { 512 }
 
std::atomic< uint32_t > m_channel_mask { 0 }
 Bitfield of channels this network is registered on.
 
bool m_enabled = true
 
bool m_initialized = false
 
std::vector< double > m_last_audio_buffer
 
std::shared_ptr< OperatorChainm_operator_chain
 
OutputMode m_output_mode = OutputMode::NONE
 
double m_output_scale { 1.0 }
 Post-processing scalar applied to m_last_audio_buffer each batch.
 
std::vector< ParameterMappingm_parameter_mappings
 
std::atomic< uint32_t > m_pending_reset_mask { 0 }
 
std::atomic< bool > m_processed_this_cycle { false }
 
std::atomic< bool > m_processing_state { false }
 Per-channel processing state (lock-free atomic flags)
 
uint32_t m_sample_rate { 48000 }
 
Topology m_topology = Topology::INDEPENDENT
 

Detailed Description

NodeNetwork subclass whose nodes are named, hierarchically transformable mesh slots.

Each slot holds a MeshWriterNode (geometry) and a local-space glm::mat4. Slots form an optional DAG via parent indices; MeshNetwork resolves processing order so parents are always updated before children. World transforms propagate as: world = parent_world * local.

The primary operator (set via create_operator<T> / set_operator) runs first each cycle. The operator chain (get_operator_chain()) runs after. Both receive the slot list via the operator interface.

MeshNetwork initializes m_operator_chain on construction because it requires multi-operator sequencing as a necessity, not an option.

No topology enum from NodeNetwork is used: the DAG is explicit via parent indices in each MeshSlot.

Usage:

auto net = std::make_shared<MeshNetwork>();
auto torso_node = std::make_shared<GpuSync::MeshWriterNode>();
torso_node->set_mesh(torso_verts, torso_indices);
uint32_t torso = net->add_slot("torso", torso_node);
auto arm_node = std::make_shared<GpuSync::MeshWriterNode>();
arm_node->set_mesh(arm_verts, arm_indices);
uint32_t arm_l = net->add_slot("arm_l", arm_node, torso);
net->create_operator<MeshTransformOperator>();
net->get_operator_chain()->emplace<MeshFieldOperator>();
Chain operator that applies Tendency field deformation to the vertex data of individual MeshNetwork s...
Primary operator that drives slot local transforms via Tendency fields and propagates world transform...

Definition at line 44 of file MeshNetwork.hpp.


The documentation for this class was generated from the following files: