26 auto &switch_decl =
b.add_input<
decl::Bool>(
"Switch");
27 const bNode *node =
b.node_or_null();
31 const NodeSwitch &storage = node_storage(*node);
34 auto &false_decl =
b.add_input(socket_type,
"False");
35 auto &true_decl =
b.add_input(socket_type,
"True");
36 auto &output_decl =
b.add_output(socket_type,
"Output");
39 switch_decl.supports_field();
40 false_decl.supports_field();
41 true_decl.supports_field();
42 output_decl.dependent_field().reference_pass_all();
45 output_decl.propagate_all();
48 output_decl.reference_pass_all();
52 StructureType::Single :
53 StructureType::Dynamic;
55 switch_decl.structure_type(structure_type);
56 false_decl.structure_type(structure_type);
57 true_decl.structure_type(structure_type);
58 output_decl.structure_type(structure_type);
77 bNode &node =
params.add_node(
"GeometryNodeSwitch");
78 node_storage(node).input_type =
params.socket.type;
79 params.update_and_connect_available_socket(node,
"Output");
84 int true_false_weights = 0;
87 bNode &node =
params.add_node(
"GeometryNodeSwitch");
88 params.update_and_connect_available_socket(node,
"Switch");
96 bNode &node =
params.add_node(
"GeometryNodeSwitch");
97 node_storage(node).input_type =
params.socket.type;
98 params.update_and_connect_available_socket(node,
"False");
104 bNode &node =
params.add_node(
"GeometryNodeSwitch");
105 node_storage(node).input_type =
params.socket.type;
106 params.update_and_connect_available_socket(node,
"True");
114 bool can_be_field_ =
false;
120 const NodeSwitch &storage = node_storage(node);
125 for (
const bNodeSocket *socket : node.output_sockets()) {
126 if (socket->type == data_type) {
127 socket_type = socket->typeinfo;
139 outputs_.append_as(
"Value", cpp_type);
161 params.set_input_unused(input_to_ignore);
162 void *value_to_forward =
params.try_get_input_data_ptr_or_request(input_to_forward);
163 if (value_to_forward ==
nullptr) {
169 void *output_ptr =
params.get_output_data_ptr(0);
181 if (
ELEM(
nullptr, false_value_variant, true_value_variant)) {
188 GField false_field = false_value_variant->extract<
GField>();
192 switch_multi_function,
193 {std::move(condition), std::move(false_field), std::move(true_field)})};
195 void *output_ptr =
params.get_output_data_ptr(0);
202 const MultiFunction *switch_multi_function =
nullptr;
203 base_type_->to_static_type_tag<
float,
212 using T =
typename decltype(type_tag)::type;
213 if constexpr (std::is_void_v<T>) {
217 static auto switch_fn = mf::build::SI3_SO<bool, T, T, T>(
218 "Switch", [](
const bool condition,
const T &false_value,
const T &true_value) {
219 return condition ? true_value : false_value;
221 switch_multi_function = &switch_fn;
225 return *switch_multi_function;
234 return &node.input_socket(1);
303 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 > from(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
static SocketValueVariant & ConstructIn(void *ptr, T &&value)
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)
bool can_contain_reference(eNodeSocketDatatype socket_type)
bool can_contain_referenced_data(eNodeSocketDatatype socket_type)
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)
bool socket_type_always_single(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 * 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)