25 std::destroy_at(&declaration);
36 typeinfo.
declare(node_decl_builder);
40void NodeDeclarationBuilder::build_remaining_anonymous_attribute_relations()
47 for (
const int i : declaration_.
inputs.index_range()) {
48 if (is_data_socket_decl(declaration_.
inputs[
i])) {
52 Vector<int> data_outputs;
53 for (
const int i : declaration_.outputs.index_range()) {
54 if (is_data_socket_decl(declaration_.outputs[
i])) {
59 for (BaseSocketDeclarationBuilder *socket_builder : input_socket_builders_) {
60 if (socket_builder->field_on_all_) {
62 const int field_input = socket_builder->decl_base_->index;
63 for (
const int data_input : data_inputs) {
64 relations.eval_relations.append({field_input, data_input});
68 for (BaseSocketDeclarationBuilder *socket_builder : output_socket_builders_) {
69 if (socket_builder->field_on_all_) {
71 const int field_output = socket_builder->decl_base_->index;
72 for (
const int data_output : data_outputs) {
73 relations.available_relations.append({field_output, data_output});
76 if (socket_builder->reference_pass_all_) {
78 const int field_output = socket_builder->decl_base_->index;
79 for (
const int input_i : declaration_.inputs.index_range()) {
80 SocketDeclaration &input_socket_decl = *declaration_.inputs[input_i];
84 relations.reference_relations.append({input_i, field_output});
88 if (socket_builder->propagate_from_all_) {
90 const int data_output = socket_builder->decl_base_->index;
91 for (
const int data_input : data_inputs) {
92 relations.propagate_relations.append({data_input, data_output});
100 this->build_remaining_anonymous_attribute_relations();
101 if (is_function_node_) {
110 declaration_.assert_valid();
118 : DeclarationListBuilder(*this,
declaration.root_items),
130 declaration_.use_custom_socket_order = enable;
135 BLI_assert(declaration_.use_custom_socket_order);
136 declaration_.allow_any_socket_order = enable;
158 stream <<
" " << relation.from_field_input <<
" -> " << relation.to_field_output <<
"\n";
160 stream <<
"Eval Relations: " << relations.
eval_relations.size() <<
"\n";
162 stream <<
" eval " << relation.field_input <<
" on " << relation.geometry_input <<
"\n";
166 stream <<
" " << relation.field_output <<
" available on " << relation.geometry_output
171 stream <<
" output " <<
i <<
" available on none\n";
184 bool found_input =
false;
185 bool found_panel =
false;
188 if (
const auto *socket_decl =
dynamic_cast<const SocketDeclaration *
>(item_decl)) {
189 if (socket_decl->in_out ==
SOCK_IN) {
192 r_flat_inputs.
append(socket_decl);
196 r_flat_outputs.
append(socket_decl);
199 else if (
const auto *panel_decl =
dynamic_cast<const PanelDeclaration *
>(item_decl)) {
231 switch (socket_decl->in_out) {
233 if (current_input ==
nullptr || !socket_decl->matches(*current_input)) {
236 current_input = current_input->
next;
239 if (current_output ==
nullptr || !socket_decl->matches(*current_output)) {
242 current_output = current_output->
next;
249 if (!node.panel_states().contains_ptr(current_panel) || !panel_decl->matches(*current_panel))
266 if (current_input !=
nullptr || current_output !=
nullptr ||
267 node.panel_states().contains_ptr(current_panel))
281 return this->
build(ntree, node);
293 if (socket.
name != this->name) {
314 switch (socket_type) {
374 std::unique_ptr<SocketDeclaration>
decl;
376 using DeclT =
typename decltype(type_tag)::type;
377 decl = std::make_unique<DeclT>();
387 using DeclT =
typename decltype(type_tag)::type;
409 using DeclT =
typename decltype(type_tag)::type;
428 auto decl_ptr = std::make_unique<SeparatorDeclaration>();
447 auto decl_ptr = std::make_unique<LayoutDeclaration>();
456 auto panel_decl_ptr = std::make_unique<PanelDeclaration>();
458 auto panel_decl_builder_ptr = std::make_unique<PanelDeclarationBuilder>(this->
node_decl_builder,
462 if (identifier >= 0) {
472 this->
node_decl_builder.declaration_.all_items.append(std::move(panel_decl_ptr));
473 this->
node_decl_builder.panel_builders_.append_and_get_index(std::move(panel_decl_builder_ptr));
474 this->
items.append(&panel_decl);
475 return panel_decl_builder;
510 if (this->
items.is_empty()) {
515 if (socket_decl->is_panel_toggle && (socket_decl->in_out &
SOCK_IN) &&
538 std::move(input_dependencies));
572 aal::RelationsInNode &relations =
node_decl_builder_->get_anonymous_attribute_relations();
573 for (
const int from_input : input_indices) {
574 aal::ReferenceRelation relation;
575 relation.from_field_input = from_input;
577 relations.reference_relations.append(relation);
584 aal::RelationsInNode &relations =
node_decl_builder_->get_anonymous_attribute_relations();
587 for (
const int input_index :
indices) {
588 aal::EvalRelation relation;
590 relation.geometry_input = input_index;
591 relations.eval_relations.append(relation);
596 for (
const int output_index :
indices) {
597 aal::AvailableRelation relation;
599 relation.geometry_output = output_index;
600 relations.available_relations.append(relation);
620 std::optional<std::string> value)
622 decl_base_->translation_context = std::move(value);
746 decl_base_->compositor_realization_mode_ = value;
754 decl_base_->compositor_domain_priority_ = priority;
759 std::function<
void(
bNode &)>
fn)
767 decl_base_->custom_draw_fn = std::make_unique<CustomSocketDrawFn>(std::move(
fn));
774 decl_base_->usage_inference_fn = std::make_unique<InputSocketUsageInferenceFn>(std::move(
fn));
781 int menu_input_count = 0;
793 if (!socket->is_available()) {
802 return node.input_socket(0);
806 const int menu_value)
811 value->
value = menu_value;
814 -> std::optional<bool> {
816 if (
const std::optional<bool> any_output_used =
params.any_output_is_used()) {
817 if (!*any_output_used) {
833 const StringRef menu_input_identifier,
const int menu_value)
845 node,
SOCK_IN, menu_input_identifier);
849 value->
value = menu_values[0];
852 [menu_input_identifier, menu_values](
854 if (
const std::optional<bool> any_output_used =
params.any_output_is_used()) {
855 if (!*any_output_used) {
867 bool menu_might_be_any_value =
false;
868 for (
const int menu_value : menu_values) {
869 menu_might_be_any_value =
params.menu_input_may_be(menu_input_identifier, menu_value);
870 if (menu_might_be_any_value) {
879 return menu_might_be_any_value;
883 const std::optional<bool> menu_might_be_used =
885 if (!menu_might_be_used.has_value()) {
886 return menu_might_be_any_value;
891 return *menu_might_be_used && menu_might_be_any_value;
898 decl_base_->align_with_previous_socket = value;
914 decl_base_->socket_name_rna = std::make_unique<SocketNameRNA>();
916 decl_base_->socket_name_rna->property_name = property_name;
927 const_cast<void *
>(
data)),
953 return field_dependency;
960 return field_dependency;
967 return field_dependency;
978 field_dependency.linked_input_indices_ = std::move(
indices);
980 return field_dependency;
990 return linked_input_indices_;
995 return compositor_realization_mode_;
1000 return compositor_domain_priority_;
1005 if (make_available_fn_) {
1006 make_available_fn_(node);
1012 decl_->description = std::move(value);
1017 std::optional<std::string> value)
1019 decl_->translation_context = value;
1025 decl_->default_collapsed = closed;
1052 r_value,
fn::Field<int>(std::make_shared<bke::IDAttributeFieldInput>()));
1079 return std::nullopt;
1095 return std::nullopt;
1102 switch (input_type) {
1120 const std::optional<StringRefNull> label_override)
1126 label_override.has_value() ? *label_override : this->label);
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
@ NODE_DEFAULT_INPUT_HANDLE_RIGHT_FIELD
@ NODE_DEFAULT_INPUT_HANDLE_LEFT_FIELD
@ NODE_DEFAULT_INPUT_ID_INDEX_FIELD
@ NODE_DEFAULT_INPUT_INSTANCE_TRANSFORM_FIELD
@ NODE_DEFAULT_INPUT_VALUE
@ NODE_DEFAULT_INPUT_INDEX_FIELD
@ NODE_DEFAULT_INPUT_NORMAL_FIELD
NodeSocketInterfaceStructureType
@ NODE_INTERFACE_SOCKET_STRUCTURE_TYPE_AUTO
BMesh const char void * data
eNodeSocketDatatype socket_type
InputSocketFieldType input_field_type
void append(const T &value)
void append(const T &value)
static SocketValueVariant & ConstructIn(void *ptr, T &&value)
BaseSocketDeclarationBuilder & is_layer_name(bool value=true)
BaseSocketDeclarationBuilder & dependent_field()
BaseSocketDeclarationBuilder & align_with_previous(bool value=true)
BaseSocketDeclarationBuilder & make_available(std::function< void(bNode &)> fn)
NodeDeclarationBuilder * node_decl_builder_
BaseSocketDeclarationBuilder & field_source()
BaseSocketDeclarationBuilder & optional_label(bool value=true)
BaseSocketDeclarationBuilder & usage_by_menu(const StringRef menu_input_identifier, const int menu_value)
BaseSocketDeclarationBuilder & usage_by_single_menu(const int menu_value)
BaseSocketDeclarationBuilder & compositor_realization_mode(CompositorInputRealizationMode value)
BaseSocketDeclarationBuilder & propagate_all()
BaseSocketDeclarationBuilder & available(bool value=true)
BaseSocketDeclarationBuilder & implicit_field(NodeDefaultInputType default_input)
BaseSocketDeclarationBuilder & usage_inference(InputSocketUsageInferenceFn fn)
BaseSocketDeclarationBuilder & field_on_all()
BaseSocketDeclarationBuilder & is_attribute_name(bool value=true)
BaseSocketDeclarationBuilder & reference_pass(Span< int > input_indices)
BaseSocketDeclarationBuilder & compact(bool value=true)
BaseSocketDeclarationBuilder & structure_type(StructureType structure_type)
BaseSocketDeclarationBuilder & description(std::string value="")
BaseSocketDeclarationBuilder & socket_name_ptr(PointerRNA ptr, StringRef property_name)
BaseSocketDeclarationBuilder & short_label(std::string value="")
BaseSocketDeclarationBuilder & supports_field()
BaseSocketDeclarationBuilder & implicit_field_on_all(NodeDefaultInputType default_input)
BaseSocketDeclarationBuilder & translation_context(std::optional< std::string > value=std::nullopt)
BaseSocketDeclarationBuilder & multi_input(bool value=true)
BaseSocketDeclarationBuilder & custom_draw(CustomSocketDrawFn fn)
BaseSocketDeclarationBuilder & panel_toggle(bool value=true)
BaseSocketDeclarationBuilder & is_default_link_socket(bool value=true)
BaseSocketDeclarationBuilder & compositor_domain_priority(int priority)
BaseSocketDeclarationBuilder & is_volume_grid_name(bool value=true)
BaseSocketDeclarationBuilder & field_source_reference_all()
BaseSocketDeclarationBuilder & field_on(Span< int > indices)
BaseSocketDeclarationBuilder & hide_value(bool value=true)
BaseSocketDeclarationBuilder & propagate_all_instance_attributes()
SocketDeclaration * decl_base_
BaseSocketDeclarationBuilder & implicit_field_on(NodeDefaultInputType default_input, Span< int > input_indices)
BaseSocketDeclarationBuilder & no_muted_links(bool value=true)
BaseSocketDeclarationBuilder & reference_pass_all()
BaseSocketDeclarationBuilder & default_input_type(NodeDefaultInputType value)
DeclType::Builder & add_output(StringRef name, StringRef identifier="")
void add_default_layout()
void add_layout(std::function< void(uiLayout *, bContext *, PointerRNA *)> draw)
NodeDeclarationBuilder & node_decl_builder
PanelDeclaration * parent_panel_decl
Vector< ItemDeclaration * > & items
PanelDeclarationBuilder & add_panel(StringRef name, int identifier=-1)
DeclType::Builder & add_input(StringRef name, StringRef identifier="")
const PanelDeclaration * parent
NodeDeclarationBuilder(const bke::bNodeType &typeinfo, NodeDeclaration &declaration, const bNodeTree *ntree=nullptr, const bNode *node=nullptr)
void allow_any_socket_order(bool enable=true)
aal::RelationsInNode & get_anonymous_attribute_relations()
NodeDeclaration & declaration()
void use_custom_socket_order(bool enable=true)
Vector< ItemDeclaration * > root_items
bool allow_any_socket_order
Vector< SocketDeclaration * > inputs
void assert_valid() const
bool matches(const bNode &node) const
Vector< SocketDeclaration * > outputs
bool use_custom_socket_order
Vector< ItemDeclarationPtr > all_items
Span< SocketDeclaration * > sockets(eNodeSocketInOut in_out) const
static OutputFieldDependency ForPartiallyDependentField(Vector< int > indices)
static OutputFieldDependency ForDataSource()
static OutputFieldDependency ForDependentField()
Span< int > linked_input_indices() const
static OutputFieldDependency ForFieldSource()
OutputSocketFieldType field_type() const
Self & default_closed(bool closed)
Self & description(std::string value="")
Self & translation_context(std::optional< std::string > value=std::nullopt)
PanelDeclarationBuilder(NodeDeclarationBuilder &node_builder, PanelDeclaration &decl)
Vector< ItemDeclaration * > items
void update_or_build(const bNodePanelState &old_panel, bNodePanelState &new_panel) const
bool matches(const bNodePanelState &panel) const
PanelDeclaration * parent_panel
const SocketDeclaration * panel_input_decl() const
void build(bNodePanelState &panel) const
bool matches_common_data(const bNodeSocket &socket) const
int compositor_domain_priority() const
StructureType structure_type
std::unique_ptr< InputSocketUsageInferenceFn > usage_inference_fn
const CompositorInputRealizationMode & compositor_realization_mode() const
void make_available(bNode &node) const
virtual bNodeSocket & update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
void set_common_flags(bNodeSocket &socket) const
virtual bNodeSocket & build(bNodeTree &ntree, bNode &node) const =0
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
std::optional< eNodeSocketDatatype > custom_data_type_to_socket_type(eCustomDataType type)
std::ostream & operator<<(std::ostream &stream, const RelationsInNode &relations)
CompositorInputRealizationMode
std::function< std::optional< bool >( const socket_usage_inference::InputSocketUsageParams ¶ms)> InputSocketUsageInferenceFn
std::optional< ImplicitInputValueFn > get_implicit_input_value_fn(const NodeDefaultInputType type)
static void assert_valid_panels_recursive(const NodeDeclaration &node_decl, const Span< const ItemDeclaration * > items, Vector< const SocketDeclaration * > &r_flat_inputs, Vector< const SocketDeclaration * > &r_flat_outputs)
static const bNodeSocket & find_single_menu_input(const bNode &node)
void build_node_declaration(const bke::bNodeType &typeinfo, NodeDeclaration &r_declaration, const bNodeTree *ntree, const bNode *node)
static bool socket_type_to_static_decl_type(const eNodeSocketDatatype socket_type, Fn &&fn)
std::unique_ptr< ItemDeclaration > ItemDeclarationPtr
bool socket_type_supports_default_input_type(const bke::bNodeSocketType &socket_type, const NodeDefaultInputType input_type)
std::function< void(CustomSocketDrawParams ¶ms)> CustomSocketDrawFn
static void reset_declaration(NodeDeclaration &declaration)
std::unique_ptr< SocketDeclaration > make_declaration_for_socket_type(const eNodeSocketDatatype socket_type)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bNodeSocketRuntimeHandle * runtime
struct bNodeSocket * next
bNodeTypeHandle * typeinfo
bNodePanelState * panel_states_array
NodeDeclareFunction declare
void draw_standard(uiLayout &layout, std::optional< StringRefNull > label_override=std::nullopt)
Vector< AvailableRelation > available_relations
Vector< ReferenceRelation > reference_relations
Vector< int > available_on_none
Vector< EvalRelation > eval_relations
Vector< PropagateRelation > propagate_relations