23 std::destroy_at(&declaration);
34 typeinfo.
declare(node_decl_builder);
38void NodeDeclarationBuilder::build_remaining_anonymous_attribute_relations()
45 for (
const int i : declaration_.
inputs.index_range()) {
46 if (is_data_socket_decl(declaration_.
inputs[
i])) {
50 Vector<int> geometry_outputs;
51 for (
const int i : declaration_.outputs.index_range()) {
52 if (is_data_socket_decl(declaration_.outputs[
i])) {
57 for (BaseSocketDeclarationBuilder *socket_builder : input_socket_builders_) {
58 if (socket_builder->field_on_all_) {
60 const int field_input = socket_builder->decl_base_->index;
61 for (
const int geometry_input : geometry_inputs) {
62 relations.eval_relations.append({field_input, geometry_input});
66 for (BaseSocketDeclarationBuilder *socket_builder : output_socket_builders_) {
67 if (socket_builder->field_on_all_) {
69 const int field_output = socket_builder->decl_base_->index;
70 for (
const int geometry_output : geometry_outputs) {
71 relations.available_relations.append({field_output, geometry_output});
74 if (socket_builder->reference_pass_all_) {
76 const int field_output = socket_builder->decl_base_->index;
77 for (
const int input_i : declaration_.inputs.index_range()) {
78 SocketDeclaration &input_socket_decl = *declaration_.inputs[input_i];
80 relations.reference_relations.append({input_i, field_output});
84 if (socket_builder->propagate_from_all_) {
86 const int geometry_output = socket_builder->decl_base_->index;
87 for (
const int geometry_input : geometry_inputs) {
88 relations.propagate_relations.append({geometry_input, geometry_output});
96 this->build_remaining_anonymous_attribute_relations();
97 if (is_function_node_) {
106 declaration_.assert_valid();
126 declaration_.use_custom_socket_order = enable;
131 BLI_assert(declaration_.use_custom_socket_order);
132 declaration_.allow_any_socket_order = enable;
154 stream <<
" " << relation.from_field_input <<
" -> " << relation.to_field_output <<
"\n";
156 stream <<
"Eval Relations: " << relations.
eval_relations.size() <<
"\n";
158 stream <<
" eval " << relation.field_input <<
" on " << relation.geometry_input <<
"\n";
162 stream <<
" " << relation.field_output <<
" available on " << relation.geometry_output
167 stream <<
" output " <<
i <<
" available on none\n";
180 bool found_input =
false;
181 bool found_panel =
false;
184 if (
const auto *socket_decl =
dynamic_cast<const SocketDeclaration *
>(item_decl)) {
185 if (socket_decl->in_out ==
SOCK_IN) {
188 r_flat_inputs.
append(socket_decl);
192 r_flat_outputs.
append(socket_decl);
195 else if (
const auto *panel_decl =
dynamic_cast<const PanelDeclaration *
>(item_decl)) {
227 switch (socket_decl->in_out) {
229 if (current_input ==
nullptr || !socket_decl->matches(*current_input)) {
232 current_input = current_input->
next;
235 if (current_output ==
nullptr || !socket_decl->matches(*current_output)) {
238 current_output = current_output->
next;
245 if (!node.panel_states().contains_ptr(current_panel) || !panel_decl->matches(*current_panel))
262 if (current_input !=
nullptr || current_output !=
nullptr ||
263 node.panel_states().contains_ptr(current_panel))
277 return this->
build(ntree, node);
322 switch (socket_type) {
379 std::unique_ptr<SocketDeclaration>
decl;
381 using DeclT =
typename decltype(type_tag)::type;
382 decl = std::make_unique<DeclT>();
392 using DeclT =
typename decltype(type_tag)::type;
414 using DeclT =
typename decltype(type_tag)::type;
433 auto decl_ptr = std::make_unique<SeparatorDeclaration>();
452 auto decl_ptr = std::make_unique<LayoutDeclaration>();
461 auto panel_decl_ptr = std::make_unique<PanelDeclaration>();
463 auto panel_decl_builder_ptr = std::make_unique<PanelDeclarationBuilder>(this->
node_decl_builder,
467 if (identifier >= 0) {
474 panel_decl.
name = name;
477 this->
node_decl_builder.declaration_.all_items.append(std::move(panel_decl_ptr));
478 this->
node_decl_builder.panel_builders_.append_and_get_index(std::move(panel_decl_builder_ptr));
479 this->
items.append(&panel_decl);
480 return panel_decl_builder;
515 if (this->
items.is_empty()) {
520 if (socket_decl->is_panel_toggle && (socket_decl->in_out &
SOCK_IN) &&
543 std::move(input_dependencies));
577 aal::RelationsInNode &relations =
node_decl_builder_->get_anonymous_attribute_relations();
578 for (
const int from_input : input_indices) {
579 aal::ReferenceRelation relation;
580 relation.from_field_input = from_input;
582 relations.reference_relations.append(relation);
589 aal::RelationsInNode &relations =
node_decl_builder_->get_anonymous_attribute_relations();
592 for (
const int input_index :
indices) {
593 aal::EvalRelation relation;
595 relation.geometry_input = input_index;
596 relations.eval_relations.append(relation);
601 for (
const int output_index :
indices) {
602 aal::AvailableRelation relation;
604 relation.geometry_output = output_index;
605 relations.available_relations.append(relation);
625 std::optional<std::string> value)
627 decl_base_->translation_context = std::move(value);
751 decl_base_->compositor_realization_mode_ = value;
759 decl_base_->compositor_domain_priority_ = priority;
766 decl_base_->compositor_expects_single_value_ = value;
771 std::function<
void(
bNode &)>
fn)
779 decl_base_->custom_draw_fn = std::make_unique<CustomSocketDrawFn>(std::move(
fn));
785 decl_base_->align_with_previous_socket = value;
799 decl_base_->socket_name_rna = std::make_unique<SocketNameRNA>();
801 decl_base_->socket_name_rna->property_name = property_name;
812 const_cast<void *
>(
data)),
832 return field_dependency;
839 return field_dependency;
846 return field_dependency;
857 field_dependency.linked_input_indices_ = std::move(
indices);
859 return field_dependency;
869 return linked_input_indices_;
874 return compositor_realization_mode_;
879 return compositor_domain_priority_;
884 return compositor_expects_single_value_;
889 if (make_available_fn_) {
890 make_available_fn_(node);
896 decl_->description = std::move(value);
901 std::optional<std::string> value)
903 decl_->translation_context = value;
909 decl_->default_collapsed = closed;
982 switch (input_type) {
#define BLI_assert_unreachable()
#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
BMesh const char void * data
InputSocketFieldType input_field_type
void append(const T &value)
void append(const 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 & compositor_realization_mode(CompositorInputRealizationMode value)
BaseSocketDeclarationBuilder & propagate_all()
BaseSocketDeclarationBuilder & available(bool value=true)
BaseSocketDeclarationBuilder & implicit_field(NodeDefaultInputType default_input)
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 & compositor_expects_single_value(bool value=true)
BaseSocketDeclarationBuilder & short_label(std::string value="")
BaseSocketDeclarationBuilder & supports_field()
BaseSocketDeclarationBuilder & hide_label(bool value=true)
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 & 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
const CompositorInputRealizationMode & compositor_realization_mode() const
void make_available(bNode &node) const
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
std::optional< eNodeSocketDatatype > custom_data_type_to_socket_type(eCustomDataType type)
std::ostream & operator<<(std::ostream &stream, const RelationsInNode &relations)
CompositorInputRealizationMode
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)
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)
struct bNodeSocket * next
bNodeTypeHandle * typeinfo
bNodePanelState * panel_states_array
NodeDeclareFunction declare
Vector< AvailableRelation > available_relations
Vector< ReferenceRelation > reference_relations
Vector< int > available_on_none
Vector< EvalRelation > eval_relations
Vector< PropagateRelation > propagate_relations