17static_assert(-1 == ~0,
"Two's complement must be used for bitwise operations.");
35 "Returns a value where the bits of A and B are both set"},
40 "Returns a value where the bits of either A or B are set"},
45 "Returns a value where only one bit from A and B is set"},
50 "Returns the opposite bit value of A, in decimal it is equivalent of A = -A - 1"},
55 "Shifts the bit values of A by the specified Shift amount. Positive values shift left, "
56 "negative values shift right."},
61 "Rotates the bit values of A by the specified Shift amount. Positive values rotate left, "
62 "negative values rotate right."},
63 {0,
nullptr, 0,
nullptr,
nullptr},
77 if (
const bNode *node =
b.node_or_null()) {
79 b_socket.available(!
ELEM(
96 bNode &node =
params.add_node(
"FunctionNodeBitMath");
111 const int weight = is_integer ? 0 : -1;
114 if (item.name !=
nullptr && item.identifier[0] !=
'\0') {
127 const char *operation_name =
IFACE_(
"Unknown");
139 static auto exec_preset = mf::build::exec_presets::AllSpanOrSingle();
140 static auto and_fn = mf::build::SI2_SO<int, int, int>(
141 "And", [](
int a,
int b) {
return a &
b; }, exec_preset);
142 static auto or_fn = mf::build::SI2_SO<int, int, int>(
143 "Or", [](
int a,
int b) {
return a |
b; }, exec_preset);
144 static auto xor_fn = mf::build::SI2_SO<int, int, int>(
145 "Xor", [](
int a,
int b) {
return a ^
b; }, exec_preset);
146 static auto not_fn = mf::build::SI1_SO<int, int>(
"Not", [](
int a) {
return ~a; }, exec_preset);
147 static auto shift_fn = mf::build::SI2_SO<int, int, int>(
150 const uint32_t value = a;
153 const uint64_t wide_result = shift > 0 ? wide_value << shift : wide_value >> -shift;
154 return uint32_t(wide_result >> 16);
157 static auto rotate_fn = mf::build::SI2_SO<int, int, int>(
160 const uint32_t value = a;
163 const uint64_t double_result = (wide_value << shift);
164 return uint32_t((double_result | (double_result >> 32)) & ((
uint64_t(1) << 33) - 1));
216 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_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_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
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)