23 std::destroy_at(&declaration);
34 typeinfo.
declare(node_decl_builder);
35 node_decl_builder.finalize();
38void NodeDeclarationBuilder::build_remaining_anonymous_attribute_relations()
41 for (
const int i : declaration_.inputs.index_range()) {
42 if (
dynamic_cast<decl::Geometry *
>(declaration_.
inputs[i])) {
46 Vector<int> geometry_outputs;
47 for (
const int i : declaration_.outputs.index_range()) {
48 if (
dynamic_cast<decl::Geometry *
>(declaration_.
outputs[i])) {
49 geometry_outputs.append(i);
53 for (BaseSocketDeclarationBuilder *socket_builder : input_socket_builders_) {
54 if (socket_builder->field_on_all_) {
56 const int field_input = socket_builder->index_;
57 for (
const int geometry_input : geometry_inputs) {
58 relations.eval_relations.append({field_input, geometry_input});
62 for (BaseSocketDeclarationBuilder *socket_builder : output_socket_builders_) {
63 if (socket_builder->field_on_all_) {
65 const int field_output = socket_builder->index_;
66 for (
const int geometry_output : geometry_outputs) {
67 relations.available_relations.append({field_output, geometry_output});
70 if (socket_builder->reference_pass_all_) {
72 const int field_output = socket_builder->index_;
73 for (
const int input_i : declaration_.inputs.index_range()) {
74 SocketDeclaration &input_socket_decl = *declaration_.
inputs[input_i];
76 relations.reference_relations.append({input_i, field_output});
80 if (socket_builder->propagate_from_all_) {
82 const int geometry_output = socket_builder->index_;
83 for (
const int geometry_input : geometry_inputs) {
84 relations.propagate_relations.append({geometry_input, geometry_output});
92 this->build_remaining_anonymous_attribute_relations();
99 : declaration_(declaration), ntree_(ntree), node_(node)
124 if (panel_builders_.is_empty()) {
130 PanelDeclarationBuilder *last_panel_builder = panel_builders_.last().get();
131 if (last_panel_builder != panel_builder) {
132 last_panel_builder->is_complete_ =
true;
136namespace anonymous_attribute_lifetime {
142 stream <<
" " << relation.from_geometry_input <<
" -> " << relation.to_geometry_output
147 stream <<
" " << relation.from_field_input <<
" -> " << relation.to_field_output <<
"\n";
149 stream <<
"Eval Relations: " << relations.
eval_relations.size() <<
"\n";
151 stream <<
" eval " << relation.field_input <<
" on " << relation.geometry_input <<
"\n";
155 stream <<
" " << relation.field_output <<
" available on " << relation.geometry_output
160 stream <<
" output " << i <<
" available on none\n";
175 struct ValidationState {
177 int remaining_items = 0;
185 panel_states.
push({});
189 ValidationState &
state = panel_states.
peek();
195 std::cout <<
"Socket added after panel" << std::endl;
204 if (socket_decl->in_out !=
state.socket_in_out && !this->allow_any_socket_order) {
205 std::cout <<
"Output socket added after input socket" << std::endl;
210 if (panel_states.
size() > 1) {
211 if (
state.remaining_items <= 0) {
212 std::cout <<
"More sockets than expected in panel" << std::endl;
215 --
state.remaining_items;
217 if (
state.remaining_items == 0) {
231 if (panel_decl->num_child_decls > 0) {
233 panel_states.
push({panel_decl->num_child_decls});
237 if (panel_states.
size() > 1) {
238 --
state.remaining_items;
239 if (
state.remaining_items == 0) {
251 if (panel_states.
size() != 1) {
252 std::cout <<
"Incomplete last panel" << std::endl;
267 switch (socket_decl->in_out) {
269 if (current_input ==
nullptr || !socket_decl->matches(*current_input)) {
272 current_input = current_input->
next;
275 if (current_output ==
nullptr || !socket_decl->matches(*current_output)) {
278 current_output = current_output->
next;
285 if (!node.panel_states().contains_ptr(current_panel) || !panel_decl->matches(*current_panel))
300 if (current_input !=
nullptr || current_output !=
nullptr ||
301 node.panel_states().contains_ptr(current_panel))
315 return this->
build(ntree, node);
330 if (socket.
name != this->name) {
359 std::unique_ptr<PanelDeclaration> panel_decl = std::make_unique<PanelDeclaration>();
360 std::unique_ptr<PanelDeclarationBuilder> panel_decl_builder =
361 std::make_unique<PanelDeclarationBuilder>();
362 panel_decl_builder->decl_ = &*panel_decl;
364 panel_decl_builder->node_decl_builder_ =
this;
365 if (identifier >= 0) {
366 panel_decl->identifier = identifier;
370 panel_decl->identifier = declaration_.
items.
size();
372 panel_decl->name = name;
376 panel_builders_.append(std::move(panel_decl_builder));
377 set_active_panel_builder(&builder_ref);
405 switch (socket_type) {
456 std::unique_ptr<SocketDeclaration> decl;
458 using DeclT =
typename decltype(type_tag)::type;
459 decl = std::make_unique<DeclT>();
469 using DeclT =
typename decltype(type_tag)::type;
491 using DeclT =
typename decltype(type_tag)::type;
510 declaration_.
items.
append(std::make_unique<SeparatorDeclaration>());
518 using DeclT =
typename decltype(type_tag)::type;
540 using DeclT =
typename decltype(type_tag)::type;
579 std::move(input_dependencies));
607 for (
const int from_input : input_indices) {
621 for (
const int input_index :
indices) {
630 for (
const int output_index :
indices) {
756 decl_base_->compositor_realization_options_ = value;
763 decl_base_->compositor_domain_priority_ = priority;
770 decl_base_->compositor_expects_single_value_ = value;
775 std::function<
void(
bNode &)> fn)
777 decl_base_->make_available_fn_ = std::move(fn);
790 decl_base_->socket_name_rna = std::make_unique<SocketNameRNA>();
791 decl_base_->socket_name_rna->owner =
ptr;
792 decl_base_->socket_name_rna->property_name = property_name;
803 const_cast<void *
>(data)),
807OutputFieldDependency OutputFieldDependency::ForFieldSource()
809 OutputFieldDependency field_dependency;
811 return field_dependency;
814OutputFieldDependency OutputFieldDependency::ForDataSource()
816 OutputFieldDependency field_dependency;
818 return field_dependency;
821OutputFieldDependency OutputFieldDependency::ForDependentField()
823 OutputFieldDependency field_dependency;
825 return field_dependency;
828OutputFieldDependency OutputFieldDependency::ForPartiallyDependentField(Vector<int> indices)
830 OutputFieldDependency field_dependency;
831 if (indices.is_empty()) {
836 field_dependency.linked_input_indices_ = std::move(indices);
838 return field_dependency;
841OutputSocketFieldType OutputFieldDependency::field_type()
const
846Span<int> OutputFieldDependency::linked_input_indices()
const
848 return linked_input_indices_;
853 return compositor_realization_options_;
858 return compositor_domain_priority_;
863 return compositor_expects_single_value_;
868 if (make_available_fn_) {
869 make_available_fn_(node);
891namespace implicit_field_inputs {
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
NodeTreeInterfaceItemType
void push(const T &value)
void append(const T &value)
BaseSocketDeclarationBuilder & dependent_field()
BaseSocketDeclarationBuilder & align_with_previous(bool value=true)
BaseSocketDeclarationBuilder & implicit_field_on_all(ImplicitInputValueFn fn)
BaseSocketDeclarationBuilder & make_available(std::function< void(bNode &)> fn)
NodeDeclarationBuilder * node_decl_builder_
BaseSocketDeclarationBuilder & field_source()
BaseSocketDeclarationBuilder & implicit_field_on(ImplicitInputValueFn fn, Span< int > input_indices)
BaseSocketDeclarationBuilder & propagate_all()
BaseSocketDeclarationBuilder & available(bool value=true)
BaseSocketDeclarationBuilder & field_on_all()
BaseSocketDeclarationBuilder & is_attribute_name(bool value=true)
BaseSocketDeclarationBuilder & reference_pass(Span< int > input_indices)
BaseSocketDeclarationBuilder & compositor_realization_options(CompositorInputRealizationOptions value)
BaseSocketDeclarationBuilder & description(std::string value="")
BaseSocketDeclarationBuilder & socket_name_ptr(PointerRNA ptr, StringRef property_name)
BaseSocketDeclarationBuilder & compositor_expects_single_value(bool value=true)
BaseSocketDeclarationBuilder & short_label(std::string value="")
BaseSocketDeclarationBuilder & supports_field()
BaseSocketDeclarationBuilder & hide_label(bool value=true)
BaseSocketDeclarationBuilder & translation_context(std::string value=BLT_I18NCONTEXT_DEFAULT)
BaseSocketDeclarationBuilder & implicit_field(ImplicitInputValueFn fn)
BaseSocketDeclarationBuilder & multi_input(bool value=true)
BaseSocketDeclarationBuilder & is_default_link_socket(bool value=true)
BaseSocketDeclarationBuilder & compositor_domain_priority(int priority)
BaseSocketDeclarationBuilder & field_source_reference_all()
BaseSocketDeclarationBuilder & field_on(Span< int > indices)
BaseSocketDeclarationBuilder & hide_value(bool value=true)
SocketDeclaration * decl_base_
BaseSocketDeclarationBuilder & no_muted_links(bool value=true)
BaseSocketDeclarationBuilder & reference_pass_all()
void allow_any_socket_order(bool enable=true)
aal::RelationsInNode & get_anonymous_attribute_relations()
void use_custom_socket_order(bool enable=true)
NodeDeclarationBuilder(NodeDeclaration &declaration, const bNodeTree *ntree=nullptr, const bNode *node=nullptr)
DeclType::Builder & add_input(StringRef name, StringRef identifier="")
PanelDeclarationBuilder & add_panel(StringRef name, int identifier=-1)
DeclType::Builder & add_output(StringRef name, StringRef identifier="")
bool allow_any_socket_order
Vector< ItemDeclarationPtr > items
Vector< SocketDeclaration * > inputs
bool matches(const bNode &node) const
Vector< SocketDeclaration * > outputs
bool use_custom_socket_order
Span< SocketDeclaration * > sockets(eNodeSocketInOut in_out) const
Self & default_closed(bool closed)
Self & description(std::string value="")
DeclType::Builder & add_input(StringRef name, StringRef identifier="")
Self & draw_buttons(PanelDrawButtonsFunction func)
DeclType::Builder & add_output(StringRef name, StringRef identifier="")
NodeDeclarationBuilder * node_decl_builder_
void update_or_build(const bNodePanelState &old_panel, bNodePanelState &new_panel) const
bool matches(const bNodePanelState &panel) const
PanelDrawButtonsFunction draw_buttons
void build(bNodePanelState &panel) const
bool align_with_previous_socket
bool matches_common_data(const bNodeSocket &socket) const
int compositor_domain_priority() const
OutputFieldDependency output_field_dependency
std::unique_ptr< ImplicitInputValueFn > implicit_input_fn
void make_available(bNode &node) const
const CompositorInputRealizationOptions & compositor_realization_options() const
bool is_default_link_socket
std::string translation_context
virtual bNodeSocket & update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
bool compositor_expects_single_value() const
void set_common_flags(bNodeSocket &socket) const
virtual bNodeSocket & build(bNodeTree &ntree, bNode &node) const =0
InputSocketFieldType input_field_type
std::optional< eNodeSocketDatatype > custom_data_type_to_socket_type(eCustomDataType type)
std::ostream & operator<<(std::ostream &stream, const RelationsInNode &relations)
void(*)(uiLayout *, bContext *, PointerRNA *) PanelDrawButtonsFunction
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
static void reset_declaration(NodeDeclaration &declaration)
std::unique_ptr< SocketDeclaration > make_declaration_for_socket_type(const eNodeSocketDatatype socket_type)
CompositorInputRealizationOptions
std::function< void(const bNode &node, void *r_value)> ImplicitInputValueFn
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
struct bNodeSocket * next
NodeDeclareFunction declare
Vector< AvailableRelation > available_relations
Vector< ReferenceRelation > reference_relations
Vector< int > available_on_none
Vector< EvalRelation > eval_relations
Vector< PropagateRelation > propagate_relations