New nodes: Logical boolean operations (OR, AND, XOR, NOT) (#1399)
* Add Boolean Operations Nodes Adds OR AND XOR and NOT operators * Fix operand naming Inputs to the 'Min' 'Max' 'Equality' and boolean operations nodes were previously named 'First' and 'Second' and are now called 'Operand A' and 'Operand B' * Rename Equality to Equals --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
48fdaddc37
commit
3419e739af
|
|
@ -1861,8 +1861,8 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
|||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::MaxParameterNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("First", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Second", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::max_properties,
|
||||
|
|
@ -1873,20 +1873,20 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
|||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::MinParameterNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("First", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Second", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::min_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Equality",
|
||||
name: "Equals",
|
||||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::EqParameterNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("First", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Second", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::eq_properties,
|
||||
|
|
@ -1908,11 +1908,56 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
|||
name: "Log to Console",
|
||||
category: "Logic",
|
||||
identifier: NodeImplementation::proto("graphene_core::logic::LogToConsoleNode"),
|
||||
inputs: vec![DocumentInputType::value("First", TaggedValue::String("Not Connected to a value yet".into()), true)],
|
||||
inputs: vec![DocumentInputType::value("Input", TaggedValue::String("Not Connected to a value yet".into()), true)],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::General)],
|
||||
properties: node_properties::no_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Or",
|
||||
category: "Logic",
|
||||
identifier: NodeImplementation::proto("graphene_core::logic::LogicOrNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Operand A", TaggedValue::Bool(false), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::Bool(false), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Boolean)],
|
||||
properties: node_properties::logic_operator_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "And",
|
||||
category: "Logic",
|
||||
identifier: NodeImplementation::proto("graphene_core::logic::LogicAndNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Operand A", TaggedValue::Bool(false), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::Bool(false), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Boolean)],
|
||||
properties: node_properties::logic_operator_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "XOR",
|
||||
category: "Logic",
|
||||
identifier: NodeImplementation::proto("graphene_core::logic::LogicXorNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Operand A", TaggedValue::Bool(false), true),
|
||||
DocumentInputType::value("Operand B", TaggedValue::Bool(false), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Boolean)],
|
||||
properties: node_properties::logic_operator_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Not",
|
||||
category: "Logic",
|
||||
identifier: NodeImplementation::proto("graphene_core::logic::LogicNotNode"),
|
||||
inputs: vec![DocumentInputType::value("Input", TaggedValue::Bool(false), true)],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Boolean)],
|
||||
properties: node_properties::no_properties,
|
||||
..Default::default()
|
||||
},
|
||||
(*IMAGINATE_NODE).clone(),
|
||||
DocumentNodeType {
|
||||
name: "Circle",
|
||||
|
|
|
|||
|
|
@ -1145,7 +1145,7 @@ pub fn eq_properties(document_node: &DocumentNode, node_id: NodeId, _context: &m
|
|||
|
||||
LayoutGroup::Row { widgets }
|
||||
};
|
||||
vec![operand("Equality", 1)]
|
||||
vec![operand("Equals", 1)]
|
||||
}
|
||||
|
||||
pub fn modulo_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
|
|
@ -1206,6 +1206,11 @@ pub fn spline_properties(document_node: &DocumentNode, node_id: NodeId, _context
|
|||
}]
|
||||
}
|
||||
|
||||
pub fn logic_operator_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let widgets = bool_widget(document_node, node_id, 0, "Operand B", true);
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
|
||||
pub fn transform_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let translation_assist = |widgets: &mut Vec<WidgetHolder>| {
|
||||
let pivot_index = 5;
|
||||
|
|
|
|||
|
|
@ -7,3 +7,37 @@ fn log_to_console<T: core::fmt::Debug>(value: T) -> T {
|
|||
debug!("{:#?}", value);
|
||||
value
|
||||
}
|
||||
|
||||
pub struct LogicOrNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(LogicOrNode)]
|
||||
fn logic_or(first: bool, second: bool) -> bool {
|
||||
first || second
|
||||
}
|
||||
|
||||
pub struct LogicAndNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(LogicAndNode)]
|
||||
fn logic_and(first: bool, second: bool) -> bool {
|
||||
first && second
|
||||
}
|
||||
|
||||
pub struct LogicXorNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(LogicXorNode)]
|
||||
fn logic_xor(first: bool, second: bool) -> bool {
|
||||
first ^ second
|
||||
}
|
||||
|
||||
pub struct LogicNotNode;
|
||||
|
||||
#[node_macro::node_fn(LogicNotNode)]
|
||||
fn logic_not(first: bool) -> bool {
|
||||
!first
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ fn max<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
|
|||
}
|
||||
}
|
||||
|
||||
// Equality
|
||||
// Equals
|
||||
pub struct EqParameterNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,10 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
register_node!(graphene_core::logic::LogToConsoleNode, input: DVec2, params: []),
|
||||
register_node!(graphene_core::logic::LogToConsoleNode, input: VectorData, params: []),
|
||||
register_node!(graphene_core::logic::LogToConsoleNode, input: DAffine2, params: []),
|
||||
register_node!(graphene_core::logic::LogicOrNode<_>, input: bool, params: [bool]),
|
||||
register_node!(graphene_core::logic::LogicAndNode<_>, input: bool, params: [bool]),
|
||||
register_node!(graphene_core::logic::LogicXorNode<_>, input: bool, params: [bool]),
|
||||
register_node!(graphene_core::logic::LogicNotNode, input: bool, params: []),
|
||||
async_node!(graphene_core::ops::IntoNode<_, ImageFrame<SRGBA8>>, input: ImageFrame<Color>, output: ImageFrame<SRGBA8>, params: []),
|
||||
async_node!(graphene_core::ops::IntoNode<_, ImageFrame<Color>>, input: ImageFrame<SRGBA8>, output: ImageFrame<Color>, params: []),
|
||||
#[cfg(feature = "gpu")]
|
||||
|
|
|
|||
Loading…
Reference in New Issue