diff options
author | Jacques Lucke <jacques@blender.org> | 2021-12-06 21:05:29 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-12-06 21:13:24 +0300 |
commit | 2d4c7fa896ab4a6de163cd33746b54e67c7f8bac (patch) | |
tree | 71a0839f33a68172b15594dc76b83fe05315c273 /source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc | |
parent | 2814740f5be86fc389ba82ffbb3a40c43f47a9f5 (diff) |
Geometry Nodes: reduce code duplication with new GeometyrFieldInput
Most of our field inputs are currently specific to geometry. This patch introduces
a new `GeometryFieldInput` that reduces the overhead of adding new geometry
field input.
Differential Revision: https://developer.blender.org/D13489
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc b/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc index 0502f64ecb7..86f882df3cd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc @@ -85,8 +85,7 @@ static Array<float3> curve_tangent_point_domain(const CurveEval &curve) } static VArray<float3> construct_curve_tangent_gvarray(const CurveComponent &component, - const AttributeDomain domain, - ResourceScope &UNUSED(scope)) + const AttributeDomain domain) { const CurveEval *curve = component.get_for_read(); if (curve == nullptr) { @@ -118,27 +117,20 @@ static VArray<float3> construct_curve_tangent_gvarray(const CurveComponent &comp return nullptr; } -class TangentFieldInput final : public fn::FieldInput { +class TangentFieldInput final : public GeometryFieldInput { public: - TangentFieldInput() : fn::FieldInput(CPPType::get<float3>(), "Tangent node") + TangentFieldInput() : GeometryFieldInput(CPPType::get<float3>(), "Tangent node") { category_ = Category::Generated; } - GVArray get_varray_for_context(const fn::FieldContext &context, - IndexMask UNUSED(mask), - ResourceScope &scope) const final + GVArray get_varray_for_context(const GeometryComponent &component, + const AttributeDomain domain, + IndexMask UNUSED(mask)) const final { - if (const GeometryComponentFieldContext *geometry_context = - dynamic_cast<const GeometryComponentFieldContext *>(&context)) { - - const GeometryComponent &component = geometry_context->geometry_component(); - const AttributeDomain domain = geometry_context->domain(); - - if (component.type() == GEO_COMPONENT_TYPE_CURVE) { - const CurveComponent &curve_component = static_cast<const CurveComponent &>(component); - return construct_curve_tangent_gvarray(curve_component, domain, scope); - } + if (component.type() == GEO_COMPONENT_TYPE_CURVE) { + const CurveComponent &curve_component = static_cast<const CurveComponent &>(component); + return construct_curve_tangent_gvarray(curve_component, domain); } return {}; } |