41 const bool one_input_ops =
ELEM(
55 switch (node->custom1) {
74 bNode &node =
params.add_node(
"FunctionNodeIntegerMath");
89 const int weight = is_integer ? 0 : -1;
96 if (item->name !=
nullptr && item->identifier[0] !=
'\0') {
125 static auto exec_preset = mf::build::exec_presets::AllSpanOrSingle();
126 static auto add_fn = mf::build::SI2_SO<int, int, int>(
127 "Add", [](
int a,
int b) {
return a +
b; }, exec_preset);
128 static auto sub_fn = mf::build::SI2_SO<int, int, int>(
129 "Subtract", [](
int a,
int b) {
return a -
b; }, exec_preset);
130 static auto multiply_fn = mf::build::SI2_SO<int, int, int>(
131 "Multiply", [](
int a,
int b) {
return a *
b; }, exec_preset);
132 static auto divide_fn = mf::build::SI2_SO<int, int, int>(
134 static auto divide_floor_fn = mf::build::SI2_SO<int, int, int>(
138 static auto divide_ceil_fn = mf::build::SI2_SO<int, int, int>(
142 static auto divide_round_fn = mf::build::SI2_SO<int, int, int>(
144 static auto pow_fn = mf::build::SI2_SO<int, int, int>(
145 "Power", [](
int a,
int b) {
return math::pow(a,
b); }, exec_preset);
146 static auto madd_fn = mf::build::SI3_SO<int, int, int, int>(
147 "Multiply Add", [](
int a,
int b,
int c) {
return a *
b + c; }, exec_preset);
148 static auto floored_mod_fn = mf::build::SI2_SO<int, int, int>(
152 static auto mod_fn = mf::build::SI2_SO<int, int, int>(
153 "Modulo", [](
int a,
int b) {
return b != 0 ? a %
b : 0; }, exec_preset);
154 static auto abs_fn = mf::build::SI1_SO<int, int>(
155 "Absolute", [](
int a) {
return math::abs(a); }, exec_preset);
156 static auto sign_fn = mf::build::SI1_SO<int, int>(
157 "Sign", [](
int a) {
return math::sign(a); }, exec_preset);
158 static auto min_fn = mf::build::SI2_SO<int, int, int>(
159 "Minimum", [](
int a,
int b) {
return math::min(a,
b); }, exec_preset);
160 static auto max_fn = mf::build::SI2_SO<int, int, int>(
161 "Maximum", [](
int a,
int b) {
return math::max(a,
b); }, exec_preset);
162 static auto gcd_fn = mf::build::SI2_SO<int, int, int>(
163 "GCD", [](
int a,
int b) {
return std::gcd(a,
b); }, exec_preset);
164 static auto lcm_fn = mf::build::SI2_SO<int, int, int>(
165 "LCM", [](
int a,
int b) {
return std::lcm(a,
b); }, exec_preset);
166 static auto negate_fn = mf::build::SI1_SO<int, int>(
167 "Negate", [](
int a) {
return -a; }, exec_preset);
179 return ÷_floor_fn;
181 return ÷_ceil_fn;
183 return ÷_round_fn;
189 return &floored_mod_fn;
219 using namespace value_elem;
226 IntElem output_elem =
params.get_input_elem<IntElem>(
"Value");
227 output_elem.merge(
params.get_input_elem<IntElem>(
"Value_001"));
228 params.set_output_elem(
"Value", output_elem);
255 const StringRef first_input_id =
"Value";
256 const StringRef second_input_id =
"Value_001";
260 params.set_input(first_input_id,
261 params.get_output<
int>(output_id) -
params.get_input<
int>(second_input_id));
265 params.set_input(first_input_id,
266 params.get_output<
int>(output_id) +
params.get_input<
int>(second_input_id));
270 params.set_input(first_input_id,
272 params.get_input<
int>(second_input_id)));
276 params.set_input(first_input_id,
277 params.get_output<
int>(output_id) *
params.get_input<
int>(second_input_id));
#define NODE_CLASS_CONVERTER
#define BLI_assert_unreachable()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define BLT_I18NCONTEXT_ID_NODETREE
#define CTX_IFACE_(context, msgid)
@ NODE_INTEGER_MATH_ABSOLUTE
@ NODE_INTEGER_MATH_MODULO
@ NODE_INTEGER_MATH_POWER
@ NODE_INTEGER_MATH_MINIMUM
@ NODE_INTEGER_MATH_MULTIPLY_ADD
@ NODE_INTEGER_MATH_SUBTRACT
@ NODE_INTEGER_MATH_MULTIPLY
@ NODE_INTEGER_MATH_DIVIDE_FLOOR
@ NODE_INTEGER_MATH_DIVIDE_CEIL
@ NODE_INTEGER_MATH_NEGATE
@ NODE_INTEGER_MATH_MAXIMUM
@ NODE_INTEGER_MATH_FLOORED_MODULO
@ NODE_INTEGER_MATH_DIVIDE_ROUND
@ NODE_INTEGER_MATH_DIVIDE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void rna_Node_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
#define NOD_inline_enum_accessors(member)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
void set_matching_fn(const mf::MultiFunction *fn)
NodeIntegerMathOperation operation
void operator()(LinkSearchOpParams ¶ms)
local_group_size(16, 16) .push_constant(Type b
MINLINE int divide_floor_i(int a, int b)
void node_set_socket_availability(bNodeTree *ntree, bNodeSocket *sock, bool is_available)
void node_register_type(bNodeType *ntype)
T pow(const T &x, const T &power)
T safe_divide(const T &a, const T &b)
T min(const T &a, const T &b)
T mod_periodic(const T &a, const T &b)
T max(const T &a, const T &b)
static void node_rna(StructRNA *srna)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static const mf::MultiFunction * get_multi_function(const bNode &bnode)
static void node_eval_elem(value_elem::ElemEvalParams ¶ms)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_label(const bNodeTree *, const bNode *node, char *label, int maxlen)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
static void node_eval_inverse_elem(value_elem::InverseElemEvalParams ¶ms)
static void node_eval_inverse(inverse_eval::InverseEvalParams ¶ms)
static void node_update(bNodeTree *ntree, bNode *node)
static int safe_divide_round_i(const int a, const int b)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_sock_label_clear(bNodeSocket *sock)
void node_sock_label(bNodeSocket *sock, const char *name)
bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r_name)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
const EnumPropertyItem rna_enum_node_integer_math_items[]
struct bNodeSocket * next
NodeInverseElemEvalFunction eval_inverse_elem
NodeInverseEvalFunction eval_inverse
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeElemEvalFunction eval_elem
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)