mirror of
https://github.com/blender/blender
synced 2026-09-26 16:15:47 +03:00
Nodes: have either input or output socket in declaration
Support for having an input and output socket in the same socket declaration builder was added for the original node panels to be able to support inline sockets. However, those were generally disabled for now. As can be seen in the simulation and repeat zone, inline sockets can work differently too. Having an input and output in the same socket declaration builder builder makes some things simpler but makes other things much harder. For example, the current design wouldn't work all that well if the input and output socket has different types. This is easier to do with the `align_with_previous_socket` approach. I'm not yet entirely sure whether we want to use the same approach for corresponding sockets in the node tree interface, but that can be tried and decided separately. Pull Request: https://projects.blender.org/blender/blender/pulls/119599
This commit is contained in:
parent
5da0363013
commit
42093bbe3d
8 changed files with 117 additions and 299 deletions
|
|
@ -242,16 +242,13 @@ class NodeDeclarationBuilder;
|
|||
|
||||
class BaseSocketDeclarationBuilder {
|
||||
protected:
|
||||
/* Socket builder can hold both an input and an output declaration.
|
||||
* Each socket declaration has its own index for dependencies. */
|
||||
int index_in_ = -1;
|
||||
int index_out_ = -1;
|
||||
/* Index of the socket in the list of inputs or outputs. */
|
||||
int index_ = -1;
|
||||
bool reference_pass_all_ = false;
|
||||
bool field_on_all_ = false;
|
||||
bool propagate_from_all_ = false;
|
||||
NodeDeclarationBuilder *node_decl_builder_ = nullptr;
|
||||
SocketDeclaration *decl_in_base_ = nullptr;
|
||||
SocketDeclaration *decl_out_base_ = nullptr;
|
||||
SocketDeclaration *decl_base_ = nullptr;
|
||||
|
||||
friend class NodeDeclarationBuilder;
|
||||
|
||||
|
|
@ -364,17 +361,11 @@ class BaseSocketDeclarationBuilder {
|
|||
*/
|
||||
BaseSocketDeclarationBuilder &align_with_previous(bool value = true);
|
||||
|
||||
int input_index() const
|
||||
{
|
||||
BLI_assert(decl_in_base_ != nullptr);
|
||||
return index_in_;
|
||||
}
|
||||
/** Index in the list of inputs or outputs. */
|
||||
int index() const;
|
||||
|
||||
int output_index() const
|
||||
{
|
||||
BLI_assert(decl_out_base_ != nullptr);
|
||||
return index_out_;
|
||||
}
|
||||
bool is_input() const;
|
||||
bool is_output() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -387,8 +378,7 @@ class SocketDeclarationBuilder : public BaseSocketDeclarationBuilder {
|
|||
protected:
|
||||
using Self = typename SocketDecl::Builder;
|
||||
static_assert(std::is_base_of_v<SocketDeclaration, SocketDecl>);
|
||||
SocketDecl *decl_in_;
|
||||
SocketDecl *decl_out_;
|
||||
SocketDecl *decl_;
|
||||
|
||||
friend class NodeDeclarationBuilder;
|
||||
};
|
||||
|
|
@ -498,6 +488,8 @@ class NodeDeclarationBuilder {
|
|||
const bNodeTree *ntree_ = nullptr;
|
||||
const bNode *node_ = nullptr;
|
||||
Vector<std::unique_ptr<BaseSocketDeclarationBuilder>> socket_builders_;
|
||||
Vector<BaseSocketDeclarationBuilder *> input_socket_builders_;
|
||||
Vector<BaseSocketDeclarationBuilder *> output_socket_builders_;
|
||||
Vector<std::unique_ptr<PanelDeclarationBuilder>> panel_builders_;
|
||||
bool is_function_node_ = false;
|
||||
|
||||
|
|
@ -568,8 +560,6 @@ class NodeDeclarationBuilder {
|
|||
}
|
||||
|
||||
private:
|
||||
/* Note: in_out can be a combination of SOCK_IN and SOCK_OUT.
|
||||
* The generated socket declarations only have a single flag set. */
|
||||
template<typename DeclType>
|
||||
typename DeclType::Builder &add_socket(StringRef name,
|
||||
StringRef identifier_in,
|
||||
|
|
@ -628,6 +618,27 @@ typename DeclType::Builder &PanelDeclarationBuilder::add_output(StringRef name,
|
|||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #BaseSocketDeclarationBuilder Inline Methods
|
||||
* \{ */
|
||||
|
||||
inline int BaseSocketDeclarationBuilder::index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
inline bool BaseSocketDeclarationBuilder::is_input() const
|
||||
{
|
||||
return decl_base_->in_out == SOCK_IN;
|
||||
}
|
||||
|
||||
inline bool BaseSocketDeclarationBuilder::is_output() const
|
||||
{
|
||||
return decl_base_->in_out == SOCK_OUT;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #NodeDeclarationBuilder Inline Methods
|
||||
* \{ */
|
||||
|
|
@ -657,28 +668,32 @@ inline typename DeclType::Builder &NodeDeclarationBuilder::add_socket(StringRef
|
|||
static_assert(std::is_base_of_v<SocketDeclaration, DeclType>);
|
||||
using Builder = typename DeclType::Builder;
|
||||
|
||||
BLI_assert(ELEM(in_out, SOCK_IN, SOCK_OUT));
|
||||
|
||||
std::unique_ptr<Builder> socket_decl_builder = std::make_unique<Builder>();
|
||||
socket_decl_builder->node_decl_builder_ = this;
|
||||
|
||||
if (in_out & SOCK_IN) {
|
||||
std::unique_ptr<DeclType> socket_decl = std::make_unique<DeclType>();
|
||||
socket_decl_builder->decl_in_ = &*socket_decl;
|
||||
socket_decl_builder->decl_in_base_ = &*socket_decl;
|
||||
socket_decl_builder->decl_ = &*socket_decl;
|
||||
socket_decl_builder->decl_base_ = &*socket_decl;
|
||||
socket_decl->name = name;
|
||||
socket_decl->identifier = identifier_in.is_empty() ? name : identifier_in;
|
||||
socket_decl->in_out = SOCK_IN;
|
||||
socket_decl_builder->index_in_ = declaration_.inputs.append_and_get_index(socket_decl.get());
|
||||
socket_decl_builder->index_ = declaration_.inputs.append_and_get_index(socket_decl.get());
|
||||
declaration_.items.append(std::move(socket_decl));
|
||||
input_socket_builders_.append(&*socket_decl_builder);
|
||||
}
|
||||
if (in_out & SOCK_OUT) {
|
||||
std::unique_ptr<DeclType> socket_decl = std::make_unique<DeclType>();
|
||||
socket_decl_builder->decl_out_ = &*socket_decl;
|
||||
socket_decl_builder->decl_out_base_ = &*socket_decl;
|
||||
socket_decl_builder->decl_ = &*socket_decl;
|
||||
socket_decl_builder->decl_base_ = &*socket_decl;
|
||||
socket_decl->name = name;
|
||||
socket_decl->identifier = identifier_out.is_empty() ? name : identifier_out;
|
||||
socket_decl->in_out = SOCK_OUT;
|
||||
socket_decl_builder->index_out_ = declaration_.outputs.append_and_get_index(socket_decl.get());
|
||||
socket_decl_builder->index_ = declaration_.outputs.append_and_get_index(socket_decl.get());
|
||||
declaration_.items.append(std::move(socket_decl));
|
||||
output_socket_builders_.append(&*socket_decl_builder);
|
||||
}
|
||||
|
||||
Builder &socket_decl_builder_ref = *socket_decl_builder;
|
||||
|
|
|
|||
|
|
@ -319,45 +319,25 @@ class Custom : public SocketDeclaration {
|
|||
|
||||
inline FloatBuilder &FloatBuilder::min(const float value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_min_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_min_value = value;
|
||||
}
|
||||
decl_->soft_min_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FloatBuilder &FloatBuilder::max(const float value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_max_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_max_value = value;
|
||||
}
|
||||
decl_->soft_max_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FloatBuilder &FloatBuilder::default_value(const float value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FloatBuilder &FloatBuilder::subtype(PropertySubType subtype)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->subtype = subtype;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->subtype = subtype;
|
||||
}
|
||||
decl_->subtype = subtype;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -369,45 +349,25 @@ inline FloatBuilder &FloatBuilder::subtype(PropertySubType subtype)
|
|||
|
||||
inline IntBuilder &IntBuilder::min(const int value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_min_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_min_value = value;
|
||||
}
|
||||
decl_->soft_min_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntBuilder &IntBuilder::max(const int value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_max_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_max_value = value;
|
||||
}
|
||||
decl_->soft_max_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntBuilder &IntBuilder::default_value(const int value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntBuilder &IntBuilder::subtype(PropertySubType subtype)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->subtype = subtype;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->subtype = subtype;
|
||||
}
|
||||
decl_->subtype = subtype;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -419,56 +379,31 @@ inline IntBuilder &IntBuilder::subtype(PropertySubType subtype)
|
|||
|
||||
inline VectorBuilder &VectorBuilder::default_value(const float3 value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VectorBuilder &VectorBuilder::subtype(PropertySubType subtype)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->subtype = subtype;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->subtype = subtype;
|
||||
}
|
||||
decl_->subtype = subtype;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VectorBuilder &VectorBuilder::min(const float min)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_min_value = min;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_min_value = min;
|
||||
}
|
||||
decl_->soft_min_value = min;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VectorBuilder &VectorBuilder::max(const float max)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->soft_max_value = max;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->soft_max_value = max;
|
||||
}
|
||||
decl_->soft_max_value = max;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VectorBuilder &VectorBuilder::compact()
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->compact = true;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->compact = true;
|
||||
}
|
||||
decl_->compact = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -480,12 +415,7 @@ inline VectorBuilder &VectorBuilder::compact()
|
|||
|
||||
inline BoolBuilder &BoolBuilder::default_value(const bool value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -497,12 +427,7 @@ inline BoolBuilder &BoolBuilder::default_value(const bool value)
|
|||
|
||||
inline ColorBuilder &ColorBuilder::default_value(const ColorGeometry4f value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -514,12 +439,7 @@ inline ColorBuilder &ColorBuilder::default_value(const ColorGeometry4f value)
|
|||
|
||||
inline StringBuilder &StringBuilder::default_value(std::string value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = std::move(value);
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = std::move(value);
|
||||
}
|
||||
decl_->default_value = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -531,12 +451,7 @@ inline StringBuilder &StringBuilder::default_value(std::string value)
|
|||
|
||||
inline MenuBuilder &MenuBuilder::default_value(const int32_t value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -548,12 +463,7 @@ inline MenuBuilder &MenuBuilder::default_value(const int32_t value)
|
|||
|
||||
inline RotationBuilder &RotationBuilder::default_value(const math::EulerXYZ &value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->default_value = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->default_value = value;
|
||||
}
|
||||
decl_->default_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
output_decl.field_source();
|
||||
}
|
||||
else {
|
||||
output_decl.dependent_field({input_decl.input_index()});
|
||||
output_decl.dependent_field({input_decl.index()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
.default_value(0.01f)
|
||||
.min(0.0f)
|
||||
.subtype(PROP_DISTANCE)
|
||||
.field_source()
|
||||
.supports_field()
|
||||
.description(
|
||||
"The distance a point can be from the surface before the face is no longer "
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous();
|
||||
if (socket_type_supports_fields(socket_type)) {
|
||||
input_decl.supports_field();
|
||||
output_decl.dependent_field({input_decl.input_index()});
|
||||
output_decl.dependent_field({input_decl.index()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous();
|
||||
if (socket_type_supports_fields(socket_type)) {
|
||||
input_decl.supports_field();
|
||||
output_decl.dependent_field({input_decl.input_index()});
|
||||
output_decl.dependent_field({input_decl.index()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous();
|
||||
if (socket_type_supports_fields(socket_type)) {
|
||||
input_decl.supports_field();
|
||||
output_decl.dependent_field({input_decl.input_index()});
|
||||
output_decl.dependent_field({input_decl.index()});
|
||||
}
|
||||
}
|
||||
b.add_input<decl::Extend>("", "__extend__");
|
||||
|
|
@ -705,7 +705,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous();
|
||||
if (socket_type_supports_fields(socket_type)) {
|
||||
input_decl.supports_field();
|
||||
output_decl.dependent_field({input_decl.input_index()});
|
||||
output_decl.dependent_field({input_decl.index()});
|
||||
}
|
||||
}
|
||||
b.add_input<decl::Extend>("", "__extend__");
|
||||
|
|
|
|||
|
|
@ -36,18 +36,15 @@ void build_node_declaration(const bNodeType &typeinfo,
|
|||
void NodeDeclarationBuilder::finalize()
|
||||
{
|
||||
if (is_function_node_) {
|
||||
for (std::unique_ptr<BaseSocketDeclarationBuilder> &socket_builder : socket_builders_) {
|
||||
if (SocketDeclaration *socket_decl = socket_builder->decl_in_base_) {
|
||||
if (socket_decl->input_field_type != InputSocketFieldType::Implicit) {
|
||||
socket_decl->input_field_type = InputSocketFieldType::IsSupported;
|
||||
}
|
||||
for (BaseSocketDeclarationBuilder *socket_builder : input_socket_builders_) {
|
||||
if (socket_builder->decl_base_->input_field_type != InputSocketFieldType::Implicit) {
|
||||
socket_builder->decl_base_->input_field_type = InputSocketFieldType::IsSupported;
|
||||
}
|
||||
}
|
||||
for (std::unique_ptr<BaseSocketDeclarationBuilder> &socket_builder : socket_builders_) {
|
||||
if (SocketDeclaration *socket_decl = socket_builder->decl_out_base_) {
|
||||
socket_decl->output_field_dependency = OutputFieldDependency::ForDependentField();
|
||||
socket_builder->reference_pass_all_ = true;
|
||||
}
|
||||
for (BaseSocketDeclarationBuilder *socket_builder : output_socket_builders_) {
|
||||
socket_builder->decl_base_->output_field_dependency =
|
||||
OutputFieldDependency::ForDependentField();
|
||||
socket_builder->reference_pass_all_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,34 +61,26 @@ void NodeDeclarationBuilder::finalize()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::unique_ptr<BaseSocketDeclarationBuilder> &socket_builder : socket_builders_) {
|
||||
if (!socket_builder->decl_in_base_) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (BaseSocketDeclarationBuilder *socket_builder : input_socket_builders_) {
|
||||
if (socket_builder->field_on_all_) {
|
||||
aal::RelationsInNode &relations = this->get_anonymous_attribute_relations();
|
||||
const int field_input = socket_builder->index_in_;
|
||||
const int field_input = socket_builder->index_;
|
||||
for (const int geometry_input : geometry_inputs) {
|
||||
relations.eval_relations.append({field_input, geometry_input});
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::unique_ptr<BaseSocketDeclarationBuilder> &socket_builder : socket_builders_) {
|
||||
if (!socket_builder->decl_out_base_) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (BaseSocketDeclarationBuilder *socket_builder : output_socket_builders_) {
|
||||
if (socket_builder->field_on_all_) {
|
||||
aal::RelationsInNode &relations = this->get_anonymous_attribute_relations();
|
||||
const int field_output = socket_builder->index_out_;
|
||||
const int field_output = socket_builder->index_;
|
||||
for (const int geometry_output : geometry_outputs) {
|
||||
relations.available_relations.append({field_output, geometry_output});
|
||||
}
|
||||
}
|
||||
if (socket_builder->reference_pass_all_) {
|
||||
aal::RelationsInNode &relations = this->get_anonymous_attribute_relations();
|
||||
const int field_output = socket_builder->index_out_;
|
||||
const int field_output = socket_builder->index_;
|
||||
for (const int input_i : declaration_.inputs.index_range()) {
|
||||
SocketDeclaration &input_socket_decl = *declaration_.inputs[input_i];
|
||||
if (input_socket_decl.input_field_type != InputSocketFieldType::None) {
|
||||
|
|
@ -101,7 +90,7 @@ void NodeDeclarationBuilder::finalize()
|
|||
}
|
||||
if (socket_builder->propagate_from_all_) {
|
||||
aal::RelationsInNode &relations = this->get_anonymous_attribute_relations();
|
||||
const int geometry_output = socket_builder->index_out_;
|
||||
const int geometry_output = socket_builder->index_;
|
||||
for (const int geometry_input : geometry_inputs) {
|
||||
relations.propagate_relations.append({geometry_input, geometry_output});
|
||||
}
|
||||
|
|
@ -535,61 +524,49 @@ BaseSocketDeclarationBuilder &NodeDeclarationBuilder::add_output(const eCustomDa
|
|||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::supports_field()
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->input_field_type = InputSocketFieldType::IsSupported;
|
||||
}
|
||||
BLI_assert(this->is_input());
|
||||
decl_base_->input_field_type = InputSocketFieldType::IsSupported;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::dependent_field(
|
||||
Vector<int> input_dependencies)
|
||||
{
|
||||
BLI_assert(this->is_output());
|
||||
this->reference_pass(input_dependencies);
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->output_field_dependency = OutputFieldDependency::ForPartiallyDependentField(
|
||||
std::move(input_dependencies));
|
||||
}
|
||||
decl_base_->output_field_dependency = OutputFieldDependency::ForPartiallyDependentField(
|
||||
std::move(input_dependencies));
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::hide_label(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->hide_label = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->hide_label = value;
|
||||
}
|
||||
decl_base_->hide_label = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::hide_value(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->hide_value = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->hide_value = value;
|
||||
}
|
||||
decl_base_->hide_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::multi_input(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->is_multi_input = value;
|
||||
}
|
||||
BLI_assert(this->is_input());
|
||||
decl_base_->is_multi_input = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::reference_pass(
|
||||
const Span<int> input_indices)
|
||||
{
|
||||
BLI_assert(this->is_output());
|
||||
aal::RelationsInNode &relations = node_decl_builder_->get_anonymous_attribute_relations();
|
||||
for (const int from_input : input_indices) {
|
||||
aal::ReferenceRelation relation;
|
||||
relation.from_field_input = from_input;
|
||||
relation.to_field_output = index_out_;
|
||||
relation.to_field_output = index_;
|
||||
relations.reference_relations.append(relation);
|
||||
}
|
||||
return *this;
|
||||
|
|
@ -598,20 +575,20 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::reference_pass(
|
|||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::field_on(const Span<int> indices)
|
||||
{
|
||||
aal::RelationsInNode &relations = node_decl_builder_->get_anonymous_attribute_relations();
|
||||
if (decl_in_base_) {
|
||||
if (this->is_input()) {
|
||||
this->supports_field();
|
||||
for (const int input_index : indices) {
|
||||
aal::EvalRelation relation;
|
||||
relation.field_input = index_in_;
|
||||
relation.field_input = index_;
|
||||
relation.geometry_input = input_index;
|
||||
relations.eval_relations.append(relation);
|
||||
}
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
else {
|
||||
this->field_source();
|
||||
for (const int output_index : indices) {
|
||||
aal::AvailableRelation relation;
|
||||
relation.field_output = index_out_;
|
||||
relation.field_output = index_;
|
||||
relation.geometry_output = output_index;
|
||||
relations.available_relations.append(relation);
|
||||
}
|
||||
|
|
@ -621,87 +598,52 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::field_on(const Span<
|
|||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::short_label(std::string value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->description = std::move(value);
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->description = std::move(value);
|
||||
}
|
||||
decl_base_->short_label = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::description(std::string value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->description = std::move(value);
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->description = std::move(value);
|
||||
}
|
||||
decl_base_->description = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::translation_context(std::string value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->translation_context = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->translation_context = std::move(value);
|
||||
}
|
||||
decl_base_->translation_context = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::no_muted_links(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->no_mute_links = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->no_mute_links = value;
|
||||
}
|
||||
decl_base_->no_mute_links = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::unavailable(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->is_unavailable = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->is_unavailable = value;
|
||||
}
|
||||
decl_base_->is_unavailable = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::is_attribute_name(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->is_attribute_name = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->is_attribute_name = value;
|
||||
}
|
||||
decl_base_->is_attribute_name = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::is_default_link_socket(bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->is_default_link_socket = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->is_default_link_socket = value;
|
||||
}
|
||||
decl_base_->is_default_link_socket = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::field_on_all()
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
if (this->is_input()) {
|
||||
this->supports_field();
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
if (this->is_output()) {
|
||||
this->field_source();
|
||||
}
|
||||
field_on_all_ = true;
|
||||
|
|
@ -710,19 +652,17 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::field_on_all()
|
|||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::field_source()
|
||||
{
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->output_field_dependency = OutputFieldDependency::ForFieldSource();
|
||||
}
|
||||
BLI_assert(this->is_output());
|
||||
decl_base_->output_field_dependency = OutputFieldDependency::ForFieldSource();
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::implicit_field(ImplicitInputValueFn fn)
|
||||
{
|
||||
BLI_assert(this->is_input());
|
||||
this->hide_value();
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->input_field_type = InputSocketFieldType::Implicit;
|
||||
decl_in_base_->implicit_input_fn = std::make_unique<ImplicitInputValueFn>(std::move(fn));
|
||||
}
|
||||
decl_base_->input_field_type = InputSocketFieldType::Implicit;
|
||||
decl_base_->implicit_input_fn = std::make_unique<ImplicitInputValueFn>(std::move(fn));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -744,9 +684,8 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::implicit_field_on(
|
|||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::dependent_field()
|
||||
{
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->output_field_dependency = OutputFieldDependency::ForDependentField();
|
||||
}
|
||||
BLI_assert(this->is_output());
|
||||
decl_base_->output_field_dependency = OutputFieldDependency::ForDependentField();
|
||||
this->reference_pass_all();
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -773,59 +712,34 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::propagate_all()
|
|||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::compositor_realization_options(
|
||||
CompositorInputRealizationOptions value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->compositor_realization_options_ = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->compositor_realization_options_ = value;
|
||||
}
|
||||
decl_base_->compositor_realization_options_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::compositor_domain_priority(
|
||||
int priority)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->compositor_domain_priority_ = priority;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->compositor_domain_priority_ = priority;
|
||||
}
|
||||
decl_base_->compositor_domain_priority_ = priority;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::compositor_expects_single_value(
|
||||
bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->compositor_expects_single_value_ = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->compositor_expects_single_value_ = value;
|
||||
}
|
||||
decl_base_->compositor_expects_single_value_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::make_available(
|
||||
std::function<void(bNode &)> fn)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->make_available_fn_ = std::move(fn);
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->make_available_fn_ = std::move(fn);
|
||||
}
|
||||
decl_base_->make_available_fn_ = std::move(fn);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::align_with_previous(const bool value)
|
||||
{
|
||||
if (decl_in_base_) {
|
||||
decl_in_base_->align_with_previous_socket = value;
|
||||
}
|
||||
if (decl_out_base_) {
|
||||
decl_out_base_->align_with_previous_socket = value;
|
||||
}
|
||||
decl_base_->align_with_previous_socket = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -676,46 +676,26 @@ bool Geometry::only_instances() const
|
|||
|
||||
GeometryBuilder &GeometryBuilder::supported_type(bke::GeometryComponent::Type supported_type)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->supported_types_ = {supported_type};
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->supported_types_ = {supported_type};
|
||||
}
|
||||
decl_->supported_types_ = {supported_type};
|
||||
return *this;
|
||||
}
|
||||
|
||||
GeometryBuilder &GeometryBuilder::supported_type(
|
||||
blender::Vector<bke::GeometryComponent::Type> supported_types)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->supported_types_ = supported_types;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->supported_types_ = supported_types;
|
||||
}
|
||||
decl_->supported_types_ = supported_types;
|
||||
return *this;
|
||||
}
|
||||
|
||||
GeometryBuilder &GeometryBuilder::only_realized_data(bool value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->only_realized_data_ = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->only_realized_data_ = value;
|
||||
}
|
||||
decl_->only_realized_data_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
GeometryBuilder &GeometryBuilder::only_instances(bool value)
|
||||
{
|
||||
if (decl_in_) {
|
||||
decl_in_->only_instances_ = value;
|
||||
}
|
||||
if (decl_out_) {
|
||||
decl_out_->only_instances_ = value;
|
||||
}
|
||||
decl_->only_instances_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue