Files
materialcraft/crates/core/src/pattern_node_kind.rs
T
chasse20 d318484b41 Checkpoint native SBS primitive workflow
Replace the legacy Rust procedural library with clean-room native primitives, typed function execution and FX-Map graphs. Save supported content as native SBS and organize the model, evaluators, codecs and editors into focused modules.

Add shared graph editing behavior, flat filtered node menus, frame and comment editing, named Explorer outputs and an original atomic sample. Document the tested scope and remaining interoperability work.
2026-11-05 18:23:06 -05:00

51 lines
1.3 KiB
Rust

use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PatternNodeKind {
#[serde(rename = "paramset")]
Quadrant,
#[serde(rename = "markov2")]
Switch,
#[serde(rename = "addnode")]
Iterate,
#[serde(rename = "passthrough")]
Dot,
}
impl PatternNodeKind {
pub const ALL: [Self; 4] = [Self::Quadrant, Self::Switch, Self::Iterate, Self::Dot];
pub fn native_id(self) -> &'static str {
match self {
Self::Quadrant => "paramset",
Self::Switch => "markov2",
Self::Iterate => "addnode",
Self::Dot => "passthrough",
}
}
pub fn label(self) -> &'static str {
match self {
Self::Quadrant => "Quadrant",
Self::Switch => "Switch",
Self::Iterate => "Iterate",
Self::Dot => "Dot",
}
}
pub fn child_count(self) -> usize {
match self {
Self::Quadrant => 4,
Self::Switch | Self::Iterate => 2,
Self::Dot => 1,
}
}
pub fn child_port(self, slot: usize) -> Option<&'static str> {
if self == Self::Dot {
return (slot == 0).then_some("output");
}
["output0", "output1", "output2", "output3"].get(..self.child_count())?.get(slot).copied()
}
}