Geometry Nodes: add Boolean and Integer Input nodes
These nodes just output a single value of their respective types, making it possible to control multiple inputs with the same value. Differential Revision: https://developer.blender.org/D12932
This commit is contained in:
parent
01e2a532f5
commit
781289e31f
|
@ -172,7 +172,9 @@ def geometry_input_node_items(context):
|
|||
yield NodeItemCustom(draw=lambda self, layout, context: layout.separator())
|
||||
|
||||
yield NodeItem("GeometryNodeCollectionInfo")
|
||||
yield NodeItem("FunctionNodeInputBool")
|
||||
yield NodeItem("FunctionNodeInputColor")
|
||||
yield NodeItem("FunctionNodeInputInt")
|
||||
yield NodeItem("GeometryNodeIsViewport")
|
||||
yield NodeItem("GeometryNodeInputMaterial")
|
||||
yield NodeItem("GeometryNodeObjectInfo")
|
||||
|
|
|
@ -1568,6 +1568,8 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
|
|||
#define FN_NODE_ALIGN_EULER_TO_VECTOR 1216
|
||||
#define FN_NODE_INPUT_COLOR 1217
|
||||
#define FN_NODE_REPLACE_STRING 1218
|
||||
#define FN_NODE_INPUT_BOOL 1219
|
||||
#define FN_NODE_INPUT_INT 1220
|
||||
|
||||
/** \} */
|
||||
|
||||
|
|
|
@ -5876,6 +5876,8 @@ static void registerFunctionNodes()
|
|||
register_node_type_fn_boolean_math();
|
||||
register_node_type_fn_float_compare();
|
||||
register_node_type_fn_float_to_int();
|
||||
register_node_type_fn_input_bool();
|
||||
register_node_type_fn_input_int();
|
||||
register_node_type_fn_input_special_characters();
|
||||
register_node_type_fn_input_string();
|
||||
register_node_type_fn_input_vector();
|
||||
|
|
|
@ -1291,6 +1291,14 @@ typedef struct NodeAttributeCurveMap {
|
|||
CurveMapping *curve_rgb;
|
||||
} NodeAttributeCurveMap;
|
||||
|
||||
typedef struct NodeInputBool {
|
||||
uint8_t boolean;
|
||||
} NodeInputBool;
|
||||
|
||||
typedef struct NodeInputInt {
|
||||
int integer;
|
||||
} NodeInputInt;
|
||||
|
||||
typedef struct NodeInputVector {
|
||||
float vector[3];
|
||||
} NodeInputVector;
|
||||
|
|
|
@ -5014,6 +5014,34 @@ static void def_fn_input_color(StructRNA *srna)
|
|||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_fn_input_bool(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "NodeInputBool", "storage");
|
||||
|
||||
prop = RNA_def_property(srna, "boolean", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "boolean", 1);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Boolean", "Input value used for unconnected socket");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
}
|
||||
|
||||
static void def_fn_input_int(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "NodeInputInt", "storage");
|
||||
|
||||
prop = RNA_def_property(srna, "integer", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "integer");
|
||||
RNA_def_property_int_default(prop, 1);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Integer", "Input value used for unconnected socket");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_fn_input_vector(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
|
|
@ -140,7 +140,9 @@ set(SRC
|
|||
function/nodes/node_fn_boolean_math.cc
|
||||
function/nodes/node_fn_float_compare.cc
|
||||
function/nodes/node_fn_float_to_int.cc
|
||||
function/nodes/node_fn_input_bool.cc
|
||||
function/nodes/node_fn_input_color.cc
|
||||
function/nodes/node_fn_input_int.cc
|
||||
function/nodes/node_fn_input_special_characters.cc
|
||||
function/nodes/node_fn_input_string.cc
|
||||
function/nodes/node_fn_input_vector.cc
|
||||
|
|
|
@ -26,6 +26,8 @@ void register_node_type_fn_align_euler_to_vector(void);
|
|||
void register_node_type_fn_boolean_math(void);
|
||||
void register_node_type_fn_float_compare(void);
|
||||
void register_node_type_fn_float_to_int(void);
|
||||
void register_node_type_fn_input_bool(void);
|
||||
void register_node_type_fn_input_int(void);
|
||||
void register_node_type_fn_input_special_characters(void);
|
||||
void register_node_type_fn_input_string(void);
|
||||
void register_node_type_fn_input_vector(void);
|
||||
|
|
|
@ -269,7 +269,9 @@ DefNode(FunctionNode, FN_NODE_ALIGN_EULER_TO_VECTOR, def_fn_align_euler_to_vecto
|
|||
DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, def_boolean_math, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "")
|
||||
DefNode(FunctionNode, FN_NODE_COMPARE_FLOATS, def_float_compare, "COMPARE_FLOATS", CompareFloats, "Compare Floats", "")
|
||||
DefNode(FunctionNode, FN_NODE_FLOAT_TO_INT, def_float_to_int, "FLOAT_TO_INT", FloatToInt, "Float to Integer", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_BOOL, def_fn_input_bool, "INPUT_BOOL", InputBool, "Boolean", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_COLOR, def_fn_input_color, "INPUT_COLOR", InputColor, "Color", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_INT, def_fn_input_int, "INPUT_INT", InputInt, "Integer", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_SPECIAL_CHARACTERS, 0, "INPUT_SPECIAL_CHARACTERS", InputSpecialCharacters, "Special Characters", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_STRING, def_fn_input_string, "INPUT_STRING", InputString, "String", "")
|
||||
DefNode(FunctionNode, FN_NODE_INPUT_VECTOR, def_fn_input_vector, "INPUT_VECTOR", InputVector, "Vector", "")
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "node_function_util.hh"
|
||||
|
||||
#include "BLI_hash.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
namespace blender::nodes {
|
||||
|
||||
static void fn_node_input_bool_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Bool>("Boolean");
|
||||
};
|
||||
|
||||
static void fn_node_input_bool_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiLayout *col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "boolean", UI_ITEM_R_EXPAND, IFACE_("Value"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void fn_node_input_bool_build_multi_function(NodeMultiFunctionBuilder &builder)
|
||||
{
|
||||
bNode &bnode = builder.node();
|
||||
NodeInputBool *node_storage = static_cast<NodeInputBool *>(bnode.storage);
|
||||
builder.construct_and_set_matching_fn<fn::CustomMF_Constant<bool>>(node_storage->boolean);
|
||||
}
|
||||
|
||||
static void fn_node_input_bool_init(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
{
|
||||
NodeInputBool *data = (NodeInputBool *)MEM_callocN(sizeof(NodeInputBool), __func__);
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_fn_input_bool()
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
fn_node_type_base(&ntype, FN_NODE_INPUT_BOOL, "Boolean", 0, 0);
|
||||
ntype.declare = blender::nodes::fn_node_input_bool_declare;
|
||||
node_type_init(&ntype, blender::nodes::fn_node_input_bool_init);
|
||||
node_type_storage(
|
||||
&ntype, "NodeInputBool", node_free_standard_storage, node_copy_standard_storage);
|
||||
ntype.build_multi_function = blender::nodes::fn_node_input_bool_build_multi_function;
|
||||
ntype.draw_buttons = blender::nodes::fn_node_input_bool_layout;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "node_function_util.hh"
|
||||
|
||||
#include "BLI_hash.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
namespace blender::nodes {
|
||||
|
||||
static void fn_node_input_int_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Int>("Integer");
|
||||
};
|
||||
|
||||
static void fn_node_input_int_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiLayout *col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "integer", UI_ITEM_R_EXPAND, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void fn_node_input_int_build_multi_function(NodeMultiFunctionBuilder &builder)
|
||||
{
|
||||
bNode &bnode = builder.node();
|
||||
NodeInputInt *node_storage = static_cast<NodeInputInt *>(bnode.storage);
|
||||
builder.construct_and_set_matching_fn<fn::CustomMF_Constant<int>>(node_storage->integer);
|
||||
}
|
||||
|
||||
static void fn_node_input_int_init(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
{
|
||||
NodeInputInt *data = (NodeInputInt *)MEM_callocN(sizeof(NodeInputInt), __func__);
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_fn_input_int()
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
fn_node_type_base(&ntype, FN_NODE_INPUT_INT, "Integer", 0, 0);
|
||||
ntype.declare = blender::nodes::fn_node_input_int_declare;
|
||||
node_type_init(&ntype, blender::nodes::fn_node_input_int_init);
|
||||
node_type_storage(
|
||||
&ntype, "NodeInputInt", node_free_standard_storage, node_copy_standard_storage);
|
||||
ntype.build_multi_function = blender::nodes::fn_node_input_int_build_multi_function;
|
||||
ntype.draw_buttons = blender::nodes::fn_node_input_int_layout;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
Loading…
Reference in New Issue