22 auto &switch_decl =
b.add_input<
decl::Bool>(
"Switch");
23 const bNode *node =
b.node_or_null();
27 const NodeSwitch &storage = node_storage(*node);
30 auto &false_decl =
b.add_input(socket_type,
"False");
31 auto &true_decl =
b.add_input(socket_type,
"True");
32 auto &output_decl =
b.add_output(socket_type,
"Output");
35 switch_decl.supports_field();
36 false_decl.supports_field();
37 true_decl.supports_field();
38 output_decl.dependent_field().reference_pass_all();
41 output_decl.propagate_all();
52 NodeSwitch *data = MEM_cnew<NodeSwitch>(__func__);
61 bNode &node =
params.add_node(
"GeometryNodeSwitch");
62 node_storage(node).input_type =
params.socket.type;
63 params.update_and_connect_available_socket(node,
"Output");
68 int true_false_weights = 0;
71 bNode &node =
params.add_node(
"GeometryNodeSwitch");
72 params.update_and_connect_available_socket(node,
"Switch");
80 bNode &node =
params.add_node(
"GeometryNodeSwitch");
81 node_storage(node).input_type =
params.socket.type;
82 params.update_and_connect_available_socket(node,
"False");
88 bNode &node =
params.add_node(
"GeometryNodeSwitch");
89 node_storage(node).input_type =
params.socket.type;
90 params.update_and_connect_available_socket(node,
"True");
98 bool can_be_field_ =
false;
104 const NodeSwitch &storage = node_storage(node);
109 for (
const bNodeSocket *socket : node.output_sockets()) {
110 if (socket->type == data_type) {
111 socket_type = socket->typeinfo;
121 inputs_.append_as(
"False", cpp_type, lf::ValueUsage::Maybe);
122 inputs_.append_as(
"True", cpp_type, lf::ValueUsage::Maybe);
123 outputs_.append_as(
"Value", cpp_type);
145 params.set_input_unused(input_to_ignore);
146 void *value_to_forward =
params.try_get_input_data_ptr_or_request(input_to_forward);
147 if (value_to_forward ==
nullptr) {
153 void *output_ptr =
params.get_output_data_ptr(0);
154 type.move_construct(value_to_forward, output_ptr);
165 if (
ELEM(
nullptr, false_value_variant, true_value_variant)) {
172 GField false_field = false_value_variant->extract<
GField>();
176 switch_multi_function,
177 {std::move(condition), std::move(false_field), std::move(true_field)})};
179 void *output_ptr =
params.get_output_data_ptr(0);
195 using T =
typename decltype(type_tag)::type;
196 if constexpr (std::is_void_v<T>) {
200 static auto switch_fn = mf::build::SI3_SO<bool, T, T, T>(
201 "Switch", [](
const bool condition,
const T &false_value,
const T &true_value) {
202 return condition ? true_value : false_value;
204 switch_multi_function = &switch_fn;
208 return *switch_multi_function;
268 using namespace node_geo_switch_cc;
270 return std::make_unique<LazyFunctionForSwitchNode>(node);
#define NODE_CLASS_CONVERTER
#define NODE_STORAGE_FUNCS(StorageT)
#define BLI_assert_unreachable()
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
StringRefNull name() const
static const CPPType & get()
void to_static_type_tag(const Fn &fn) const
bool is_context_dependent_field() const
static std::shared_ptr< FieldOperation > Create(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
Vector< Output > outputs_
const MultiFunction & get_switch_multi_function() const
void execute_impl(lf::Params ¶ms, const lf::Context &) const override
LazyFunctionForSwitchNode(const bNode &node)
void execute_field(Field< bool > condition, lf::Params ¶ms) const
void execute_single(const bool condition, lf::Params ¶ms) const
static constexpr int false_input_index
static constexpr int true_input_index
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_register_type(bNodeType *ntype)
QuaternionBase< float > Quaternion
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void register_node()
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
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)
std::unique_ptr< LazyFunction > get_switch_node_lazy_function(const bNode &node)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
const EnumPropertyItem * enum_items_filter(const EnumPropertyItem *original_item_array, FunctionRef< bool(const EnumPropertyItem &item)> fn)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
const blender::CPPType * geometry_nodes_cpp_type
const blender::CPPType * base_cpp_type
void(* initfunc)(bNodeTree *ntree, bNode *node)
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare