Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_input_index.cc
| Context not available. | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| #include "FN_field.hh" | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| Context not available. | |||||
| b.add_output<decl::Int>("Index").field_source(); | b.add_output<decl::Int>("Index").field_source(); | ||||
| } | } | ||||
| class IndexFieldInput final : public fn::FieldInput { | |||||
| public: | |||||
| IndexFieldInput() : FieldInput(CPPType::get<int>(), "Index") | |||||
| { | |||||
| } | |||||
| const GVArray *get_varray_for_context(const fn::FieldContext &UNUSED(context), | |||||
| IndexMask mask, | |||||
| ResourceScope &scope) const final | |||||
| { | |||||
| /* TODO: Investigate a similar method to IndexRange::as_span() */ | |||||
| auto index_func = [](int i) { return i; }; | |||||
| return &scope.construct< | |||||
| fn::GVArray_For_EmbeddedVArray<int, VArray_For_Func<int, decltype(index_func)>>>( | |||||
| mask.min_array_size(), mask.min_array_size(), index_func); | |||||
| } | |||||
| }; | |||||
| static void geo_node_input_index_exec(GeoNodeExecParams params) | static void geo_node_input_index_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| Field<int> index_field{std::make_shared<IndexFieldInput>()}; | Field<int> index_field{std::make_shared<fn::IndexFieldInput>()}; | ||||
| params.set_output("Index", std::move(index_field)); | params.set_output("Index", std::move(index_field)); | ||||
| } | } | ||||
| Context not available. | |||||