16static_assert(-1 == ~0,
"Two's complement must be used for bitwise operations.");
34 "Returns a value where the bits of A and B are both set"},
39 "Returns a value where the bits of either A or B are set"},
44 "Returns a value where only one bit from A and B is set"},
49 "Returns the opposite bit value of A, in decimal it is equivalent of A = -A - 1"},
54 "Shifts the bit values of A by the specified Shift amount. Positive values shift left, "
55 "negative values shift right."},
60 "Rotates the bit values of A by the specified Shift amount. Positive values rotate left, "
61 "negative values rotate right."},
62 {0,
nullptr, 0,
nullptr,
nullptr},
76 if (
const bNode *node =
b.node_or_null()) {
78 b_socket.available(!
ELEM(
95 bNode &node =
params.add_node(
"FunctionNodeBitMath");
110 const int weight = is_integer ? 0 : -1;
113 if (item.name !=
nullptr && item.identifier[0] !=
'\0') {
123 const char *operation_name =
IFACE_(
"Unknown");
135 static auto exec_preset = mf::build::exec_presets::AllSpanOrSingle();
136 static auto and_fn = mf::build::SI2_SO<int, int, int>(
137 "And", [](
int a,
int b) {
return a &
b; }, exec_preset);
138 static auto or_fn = mf::build::SI2_SO<int, int, int>(
139 "Or", [](
int a,
int b) {
return a |
b; }, exec_preset);
140 static auto xor_fn = mf::build::SI2_SO<int, int, int>(
141 "Xor", [](
int a,
int b) {
return a ^
b; }, exec_preset);
142 static auto not_fn = mf::build::SI1_SO<int, int>(
143 "Not", [](
int a) {
return ~a; }, exec_preset);
144 static auto shift_fn = mf::build::SI2_SO<int, int, int>(
147 const uint32_t value = a;
150 const uint64_t wide_result = shift > 0 ? wide_value << shift : wide_value >> -shift;
151 return uint32_t(wide_result >> 16);
154 static auto rotate_fn = mf::build::SI2_SO<int, int, int>(
157 const uint32_t value = a;
160 const uint64_t double_result = (wide_value << shift);
161 return uint32_t((double_result | (double_result >> 32)) & ((
uint64_t(1) << 33) - 1));
213 ntype.
ui_description =
"Perform bitwise operations on 32-bit integers";
#define NODE_CLASS_CONVERTER
#define BLI_assert_unreachable()
#define SNPRINTF(dst, format,...)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define BLT_I18NCONTEXT_DEFAULT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void rna_Node_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
#define NOD_inline_enum_accessors(member)
unsigned long long int uint64_t
void set_matching_fn(const mf::MultiFunction *fn)
void operator()(LinkSearchOpParams ¶ms)
BitMathOperation operation
void node_register_type(bNodeType &ntype)
T clamp(const T &a, const T &min, const T &max)
T mod_periodic(const T &a, const T &b)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static constexpr int32_t max_shift
const std::array< EnumPropertyItem, 7 > bit_math_operation_items
static void node_declare(NodeDeclarationBuilder &b)
static constexpr int32_t min_shift
static void node_label(const bNodeTree *, const bNode *node, char *label, int maxlen)
static void node_register()
static const mf::MultiFunction * get_multi_function(const bNode &bnode)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_rna(StructRNA *srna)
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, std::string idname, const std::optional< int16_t > legacy_type)
bool RNA_enum_name_gettexted(const EnumPropertyItem *item, int value, const char *translation_context, const char **r_name)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
std::string ui_description
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)