24 auto &switch_decl =
b.add_input<
decl::Bool>(
"Switch");
25 const bNode *node =
b.node_or_null();
29 const NodeSwitch &storage = node_storage(*node);
32 auto &false_decl =
b.add_input(socket_type,
"False");
33 auto &true_decl =
b.add_input(socket_type,
"True");
34 auto &output_decl =
b.add_output(socket_type,
"Output");
37 switch_decl.supports_field();
38 false_decl.supports_field();
39 true_decl.supports_field();
40 output_decl.dependent_field().reference_pass_all();
43 output_decl.propagate_all();
63 bNode &node =
params.add_node(
"GeometryNodeSwitch");
64 node_storage(node).input_type =
params.socket.type;
65 params.update_and_connect_available_socket(node,
"Output");
70 int true_false_weights = 0;
73 bNode &node =
params.add_node(
"GeometryNodeSwitch");
74 params.update_and_connect_available_socket(node,
"Switch");
82 bNode &node =
params.add_node(
"GeometryNodeSwitch");
83 node_storage(node).input_type =
params.socket.type;
84 params.update_and_connect_available_socket(node,
"False");
90 bNode &node =
params.add_node(
"GeometryNodeSwitch");
91 node_storage(node).input_type =
params.socket.type;
92 params.update_and_connect_available_socket(node,
"True");
100 bool can_be_field_ =
false;
106 const NodeSwitch &storage = node_storage(node);
111 for (
const bNodeSocket *socket : node.output_sockets()) {
112 if (socket->type == data_type) {
113 socket_type = socket->typeinfo;
125 outputs_.append_as(
"Value", cpp_type);
147 params.set_input_unused(input_to_ignore);
148 void *value_to_forward =
params.try_get_input_data_ptr_or_request(input_to_forward);
149 if (value_to_forward ==
nullptr) {
155 void *output_ptr =
params.get_output_data_ptr(0);
167 if (
ELEM(
nullptr, false_value_variant, true_value_variant)) {
174 GField false_field = false_value_variant->extract<
GField>();
178 switch_multi_function,
179 {std::move(condition), std::move(false_field), std::move(true_field)})};
181 void *output_ptr =
params.get_output_data_ptr(0);
188 const MultiFunction *switch_multi_function =
nullptr;
189 base_type_->to_static_type_tag<float,
197 using T =
typename decltype(type_tag)::type;
198 if constexpr (std::is_void_v<T>) {
202 static auto switch_fn = mf::build::SI3_SO<bool, T, T, T>(
203 "Switch", [](
const bool condition,
const T &false_value,
const T &true_value) {
204 return condition ? true_value : false_value;
206 switch_multi_function = &switch_fn;
210 return *switch_multi_function;
219 return &node.input_socket(1);
236 if (!
U.experimental.use_bundle_and_closure_nodes) {
293 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)
BMesh const char void * data
static const CPPType & get()
void move_construct(void *src, void *dst) const
bool is_context_dependent_field() const
Vector< Output > outputs_
static std::shared_ptr< FieldOperation > Create(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
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
void * MEM_callocN(size_t len, const char *str)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
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)
static const bNodeSocket * node_internally_linked_input(const bNodeTree &, const bNode &node, const bNodeSocket &)
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)
MatBase< float, 4, 4 > float4x4
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
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
NodeInternallyLinkedInputFunction internally_linked_input
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
bool ignore_inferred_input_socket_visibility
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)