Geometry Nodes: Expand the Boolean Math node
Currently the Boolean Math node only has 3 basic logic gates: AND, OR, and NOT. This commit adds 6 additional logic gates for convenience and ease of use. - **Not And (NAND)** returns true when at least one input is false. - **Nor (NOR)** returns true when both inputs are false. - **Equal (XNOR)** returns true when both inputs are equal. - **Not Equal (XOR)** returns true when both inputs are different. - **Imply (IMPLY)** returns true unless the first input is true and the second is false. - **Subtract (NIMPLY)** returns true when the first input is true and the second is false. Differential Revision: https://developer.blender.org/D13774
This commit is contained in:
parent
368bfa80f9
commit
14f6afb090
|
@ -1931,6 +1931,14 @@ enum {
|
|||
NODE_BOOLEAN_MATH_AND = 0,
|
||||
NODE_BOOLEAN_MATH_OR = 1,
|
||||
NODE_BOOLEAN_MATH_NOT = 2,
|
||||
|
||||
NODE_BOOLEAN_MATH_NAND = 3,
|
||||
NODE_BOOLEAN_MATH_NOR = 4,
|
||||
NODE_BOOLEAN_MATH_XNOR = 5,
|
||||
NODE_BOOLEAN_MATH_XOR = 6,
|
||||
|
||||
NODE_BOOLEAN_MATH_IMPLY = 7,
|
||||
NODE_BOOLEAN_MATH_NIMPLY = 8,
|
||||
};
|
||||
|
||||
/** Float compare node operations. */
|
||||
|
|
|
@ -300,9 +300,33 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = {
|
|||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_node_boolean_math_items[] = {
|
||||
{NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "Outputs true only when both inputs are true"},
|
||||
{NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "Outputs or when at least one of the inputs is true"},
|
||||
{NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Outputs the opposite of the input"},
|
||||
{NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "True when both inputs are true"},
|
||||
{NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "True when at least one input is true"},
|
||||
{NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Opposite of the input"},
|
||||
{0, "", ICON_NONE, NULL, NULL},
|
||||
{NODE_BOOLEAN_MATH_NAND, "NAND", 0, "Not And", "True when at least one input is false"},
|
||||
{NODE_BOOLEAN_MATH_NOR, "NOR", 0, "Nor", "True when both inputs are false"},
|
||||
{NODE_BOOLEAN_MATH_XNOR,
|
||||
"XNOR",
|
||||
0,
|
||||
"Equal",
|
||||
"True when both inputs are equal (exclusive nor)"},
|
||||
{NODE_BOOLEAN_MATH_XOR,
|
||||
"XOR",
|
||||
0,
|
||||
"Not Equal",
|
||||
"True when both inputs are different (exclusive or)"},
|
||||
{0, "", ICON_NONE, NULL, NULL},
|
||||
{NODE_BOOLEAN_MATH_IMPLY,
|
||||
"IMPLY",
|
||||
0,
|
||||
"Imply",
|
||||
"True unless the first input is true and the second is false"},
|
||||
{NODE_BOOLEAN_MATH_NIMPLY,
|
||||
"NIMPLY",
|
||||
0,
|
||||
"Subtract",
|
||||
"True when the first input is true and the second is false (not imply)"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ static void node_boolean_math_update(bNodeTree *ntree, bNode *node)
|
|||
{
|
||||
bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1);
|
||||
|
||||
nodeSetSocketAvailability(
|
||||
ntree, sockB, ELEM(node->custom1, NODE_BOOLEAN_MATH_AND, NODE_BOOLEAN_MATH_OR));
|
||||
nodeSetSocketAvailability(ntree, sockB, !ELEM(node->custom1, NODE_BOOLEAN_MATH_NOT));
|
||||
}
|
||||
|
||||
static void node_boolean_math_label(const bNodeTree *UNUSED(ntree),
|
||||
|
@ -67,6 +66,18 @@ static const fn::MultiFunction *get_multi_function(bNode &bnode)
|
|||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> or_fn{"Or",
|
||||
[](bool a, bool b) { return a || b; }};
|
||||
static fn::CustomMF_SI_SO<bool, bool> not_fn{"Not", [](bool a) { return !a; }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> nand_fn{"Not And",
|
||||
[](bool a, bool b) { return !(a && b); }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> nor_fn{"Nor",
|
||||
[](bool a, bool b) { return !(a || b); }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> xnor_fn{"Equal",
|
||||
[](bool a, bool b) { return a == b; }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> xor_fn{"Not Equal",
|
||||
[](bool a, bool b) { return a != b; }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> imply_fn{"Imply",
|
||||
[](bool a, bool b) { return !a || b; }};
|
||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> nimply_fn{"Subtract",
|
||||
[](bool a, bool b) { return a && !b; }};
|
||||
|
||||
switch (bnode.custom1) {
|
||||
case NODE_BOOLEAN_MATH_AND:
|
||||
|
@ -75,6 +86,18 @@ static const fn::MultiFunction *get_multi_function(bNode &bnode)
|
|||
return &or_fn;
|
||||
case NODE_BOOLEAN_MATH_NOT:
|
||||
return ¬_fn;
|
||||
case NODE_BOOLEAN_MATH_NAND:
|
||||
return &nand_fn;
|
||||
case NODE_BOOLEAN_MATH_NOR:
|
||||
return &nor_fn;
|
||||
case NODE_BOOLEAN_MATH_XNOR:
|
||||
return &xnor_fn;
|
||||
case NODE_BOOLEAN_MATH_XOR:
|
||||
return &xor_fn;
|
||||
case NODE_BOOLEAN_MATH_IMPLY:
|
||||
return &imply_fn;
|
||||
case NODE_BOOLEAN_MATH_NIMPLY:
|
||||
return &nimply_fn;
|
||||
}
|
||||
|
||||
BLI_assert_unreachable();
|
||||
|
|
Loading…
Reference in New Issue