GPv3: Initial Geometry Nodes support #112535

Merged
Falk David merged 61 commits from filedescriptor/blender:gpv3-geometry-nodes into main 2023-10-10 16:49:39 +02:00
2 changed files with 26 additions and 0 deletions
Showing only changes of commit 6f9afc7372 - Show all commits

View File

@ -103,6 +103,10 @@ class GreasePencilLayerFieldContext : public fn::FieldContext {
{
return layer_index_;
}
GVArray get_varray_for_input(const fn::FieldInput &field_input,
const IndexMask &mask,
ResourceScope &scope) const;
};
class InstancesFieldContext : public fn::FieldContext {

View File

@ -35,6 +35,28 @@ CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const eAttr
BLI_assert(curves.attributes().domain_supported(domain));
}
GVArray GreasePencilLayerFieldContext::get_varray_for_input(const fn::FieldInput &field_input,
const IndexMask &mask,
ResourceScope &scope) const
{
if (const GeometryFieldInput *geometry_field_input = dynamic_cast<const GeometryFieldInput *>(
&field_input))
{
const GeometryFieldContext context{this->grease_pencil(), this->domain(), this->layer_index()};
return geometry_field_input->get_varray_for_context(context, mask, scope);
}
if (const bke::greasepencil::Drawing *drawing =
bke::greasepencil::get_eval_grease_pencil_layer_drawing(this->grease_pencil(),
this->layer_index()))
{
if (drawing->strokes().attributes().domain_supported(this->domain())) {
const CurvesFieldContext context{drawing->strokes(), this->domain()};
return field_input.get_varray_for_context(context, mask, scope);
}
}
return {};
filedescriptor marked this conversation as resolved
Review

This seems to be missing the default case which is just field_input.get_array_for_context(*this).

I think this could be simplified. We just have do check if the field_input is a CurvesFieldInput. Then we do the conversion to CurvesFieldContext. Otherwise, we can just do the default operation mentioned above. The conversion to GeometryFieldContext is done in GeometryFieldInput::get_varray_for_context already.

This seems to be missing the default case which is just `field_input.get_array_for_context(*this)`. I think this could be simplified. We just have do check if the `field_input` is a `CurvesFieldInput`. Then we do the conversion to `CurvesFieldContext`. Otherwise, we can just do the default operation mentioned above. The conversion to `GeometryFieldContext` is done in `GeometryFieldInput::get_varray_for_context` already.
}
GeometryFieldContext::GeometryFieldContext(const GeometryFieldContext &other,
const eAttrDomain domain)
: geometry_(other.geometry_),