Differential D16858 Diff 59005 source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc
| Show All 28 Lines | static void node_declare(NodeDeclarationBuilder &b) | ||||
| b.add_input<decl::Int>(N_("Point Index")) | b.add_input<decl::Int>(N_("Point Index")) | ||||
| .implicit_field(implicit_field_inputs::index) | .implicit_field(implicit_field_inputs::index) | ||||
| .description( | .description( | ||||
| N_("The index of the control point to evaluate. Defaults to the current index")); | N_("The index of the control point to evaluate. Defaults to the current index")); | ||||
| b.add_input<decl::Int>(N_("Offset")) | b.add_input<decl::Int>(N_("Offset")) | ||||
| .supports_field() | .supports_field() | ||||
| .description(N_("The number of control points along the curve to traverse")); | .description(N_("The number of control points along the curve to traverse")); | ||||
| b.add_output<decl::Bool>(N_("Is Valid Offset")) | b.add_output<decl::Bool>(N_("Is Valid Offset")) | ||||
| .dependent_field() | .field_source_reference_all() | ||||
| .description(N_("Whether the input control point plus the offset is a valid index of the " | .description(N_("Whether the input control point plus the offset is a valid index of the " | ||||
| "original curve")); | "original curve")); | ||||
| b.add_output<decl::Int>(N_("Point Index")) | b.add_output<decl::Int>(N_("Point Index")) | ||||
| .dependent_field() | .field_source_reference_all() | ||||
| .description(N_("The index of the control point plus the offset within the entire " | .description(N_("The index of the control point plus the offset within the entire " | ||||
| "curves data-block")); | "curves data-block")); | ||||
| } | } | ||||
| class ControlPointNeighborFieldInput final : public bke::CurvesFieldInput { | class ControlPointNeighborFieldInput final : public bke::CurvesFieldInput { | ||||
| private: | private: | ||||
| const Field<int> index_; | const Field<int> index_; | ||||
| const Field<int> offset_; | const Field<int> offset_; | ||||
| Show All 34 Lines | for (const int i_selection : mask) { | ||||
| curve_points, i_point, offsets[i_selection]); | curve_points, i_point, offsets[i_selection]); | ||||
| continue; | continue; | ||||
| } | } | ||||
| output[i_selection] = std::clamp(offset_point, 0, curves.points_num() - 1); | output[i_selection] = std::clamp(offset_point, 0, curves.points_num() - 1); | ||||
| } | } | ||||
| return VArray<int>::ForContainer(std::move(output)); | return VArray<int>::ForContainer(std::move(output)); | ||||
| } | } | ||||
| void for_each_field_input_recursive(FunctionRef<void(const FieldInput &)> fn) const | |||||
| { | |||||
| index_.node().for_each_field_input_recursive(fn); | |||||
| offset_.node().for_each_field_input_recursive(fn); | |||||
| } | |||||
| }; | }; | ||||
| class OffsetValidFieldInput final : public bke::CurvesFieldInput { | class OffsetValidFieldInput final : public bke::CurvesFieldInput { | ||||
| private: | private: | ||||
| const Field<int> index_; | const Field<int> index_; | ||||
| const Field<int> offset_; | const Field<int> offset_; | ||||
| public: | public: | ||||
| Show All 33 Lines | for (const int i_selection : mask) { | ||||
| if (cyclic[i_curve]) { | if (cyclic[i_curve]) { | ||||
| output[i_selection] = true; | output[i_selection] = true; | ||||
| continue; | continue; | ||||
| } | } | ||||
| output[i_selection] = curve_points.contains(i_point + offsets[i_selection]); | output[i_selection] = curve_points.contains(i_point + offsets[i_selection]); | ||||
| }; | }; | ||||
| return VArray<bool>::ForContainer(std::move(output)); | return VArray<bool>::ForContainer(std::move(output)); | ||||
| } | } | ||||
| void for_each_field_input_recursive(FunctionRef<void(const FieldInput &)> fn) const | |||||
| { | |||||
| index_.node().for_each_field_input_recursive(fn); | |||||
| offset_.node().for_each_field_input_recursive(fn); | |||||
| } | |||||
| }; | }; | ||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| Field<int> index = params.extract_input<Field<int>>("Point Index"); | Field<int> index = params.extract_input<Field<int>>("Point Index"); | ||||
| Field<int> offset = params.extract_input<Field<int>>("Offset"); | Field<int> offset = params.extract_input<Field<int>>("Offset"); | ||||
| if (params.output_is_required("Point Index")) { | if (params.output_is_required("Point Index")) { | ||||
| Show All 21 Lines | |||||