Fix: Curve resolution input node missing default #104674

Merged
Hans Goudey merged 4 commits from HooglyBoogly/blender:fix-geometry-nodes-curve-resolution-default into main 2023-02-14 19:59:49 +01:00
1 changed files with 33 additions and 2 deletions

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_curves.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_input_spline_resolution_cc {
@ -9,10 +11,39 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Int>(N_("Resolution")).field_source();
}
class ResolutionFieldInput final : public bke::CurvesFieldInput {
public:
ResolutionFieldInput() : bke::CurvesFieldInput(CPPType::get<int>(), "resolution")
{
category_ = Category::NamedAttribute;
}
GVArray get_varray_for_context(const bke::CurvesGeometry &curves,
const eAttrDomain domain,
const IndexMask /*mask*/) const final
{
return curves.adapt_domain(curves.resolution(), ATTR_DOMAIN_CURVE, domain);
}
uint64_t hash() const final
{
return 82713465872345682;
}
bool is_equal_to(const fn::FieldNode &other) const final
{
return dynamic_cast<const ResolutionFieldInput *>(&other) != nullptr;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/) const final
{
return ATTR_DOMAIN_CURVE;
}
};
static void node_geo_exec(GeoNodeExecParams params)
{
Field<int> resolution_field = AttributeFieldInput::Create<int>("resolution");
params.set_output("Resolution", std::move(resolution_field));
params.set_output("Resolution", Field<int>(std::make_shared<ResolutionFieldInput>()));
}
} // namespace blender::nodes::node_geo_input_spline_resolution_cc