diff options
Diffstat (limited to 'source/blender/nodes/geometry')
24 files changed, 163 insertions, 84 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 4ad6efebfa8..613375bca57 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -285,6 +285,12 @@ template<typename T> class AccumulateFieldInput final : public bke::GeometryFiel } return false; } + + std::optional<eAttrDomain> preferred_domain( + const GeometryComponent & /*component*/) const override + { + return source_domain_; + } }; template<typename T> class TotalFieldInput final : public bke::GeometryFieldInput { @@ -355,6 +361,11 @@ template<typename T> class TotalFieldInput final : public bke::GeometryFieldInpu } return false; } + + std::optional<eAttrDomain> preferred_domain(const GeometryComponent & /*component*/) const + { + return source_domain_; + } }; template<typename T> std::string identifier_suffix() diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index c9df66f1eea..99dd4d9f798 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -106,33 +106,6 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } -static void try_capture_field_on_geometry(GeometryComponent &component, - const AttributeIDRef &attribute_id, - const eAttrDomain domain, - const GField &field) -{ - const int domain_size = component.attribute_domain_size(domain); - if (domain_size == 0) { - return; - } - bke::GeometryFieldContext field_context{component, domain}; - MutableAttributeAccessor attributes = *component.attributes_for_write(); - const IndexMask mask{IndexMask(domain_size)}; - - const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(field.cpp_type()); - GAttributeWriter output_attribute = attributes.lookup_or_add_for_write( - attribute_id, domain, data_type); - if (!output_attribute) { - return; - } - - fn::FieldEvaluator evaluator{field_context, &mask}; - evaluator.add_with_destination(field, output_attribute.varray); - evaluator.evaluate(); - - output_attribute.finish(); -} - static StringRefNull identifier_suffix(eCustomDataType data_type) { switch (data_type) { @@ -206,7 +179,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_instances()) { GeometryComponent &component = geometry_set.get_component_for_write( GEO_COMPONENT_TYPE_INSTANCES); - try_capture_field_on_geometry(component, anonymous_id.get(), domain, field); + bke::try_capture_field_on_geometry(component, anonymous_id.get(), domain, field); } } else { @@ -217,7 +190,7 @@ static void node_geo_exec(GeoNodeExecParams params) for (const GeometryComponentType type : types) { if (geometry_set.has(type)) { GeometryComponent &component = geometry_set.get_component_for_write(type); - try_capture_field_on_geometry(component, anonymous_id.get(), domain, field); + bke::try_capture_field_on_geometry(component, anonymous_id.get(), domain, field); } } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc index 28d979facac..d3d0dcfb794 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc @@ -90,6 +90,11 @@ class EndpointFieldInput final : public bke::CurvesFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const CurvesGeometry & /*curves*/) const + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index b1c3bbfb81e..b4181528696 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -108,6 +108,11 @@ class HandleTypeFieldInput final : public bke::CurvesFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const CurvesGeometry & /*curves*/) const + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc index b5d8d1f020a..6fe806adb7c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc @@ -280,6 +280,11 @@ class IndexOnSplineFieldInput final : public bke::CurvesFieldInput { { return dynamic_cast<const IndexOnSplineFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const CurvesGeometry & /*curves*/) const + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 9ef9ee8ad6e..f0bd01a012b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -106,6 +106,11 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc index 4d7e4b00c5a..d5feaae46ed 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc @@ -141,6 +141,12 @@ class FieldAtIndex final : public bke::GeometryFieldInput { return output_array; } + + std::optional<eAttrDomain> preferred_domain( + const GeometryComponent & /*component*/) const override + { + return value_field_domain_; + } }; static StringRefNull identifier_suffix(eCustomDataType data_type) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc index bff2e7831c6..2979d0e4639 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc @@ -84,6 +84,11 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const CurvesGeometry & /*curves*/) const + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc index f2e7379b3a2..0b9084d3715 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc @@ -95,6 +95,11 @@ class AngleFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const AngleFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; class SignedAngleFieldInput final : public bke::MeshFieldInput { @@ -162,6 +167,11 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const SignedAngleFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc index bfe8753c039..a579202738d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc @@ -48,6 +48,11 @@ class EdgeNeighborCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const EdgeNeighborCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc index c8ceae239a4..c80b3797874 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc @@ -73,6 +73,11 @@ class EdgeVerticesFieldInput final : public bke::MeshFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static VArray<float3> construct_edge_positions_gvarray(const Mesh &mesh, @@ -127,6 +132,11 @@ class EdgePositionFieldInput final : public bke::MeshFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc index be921c1f1c5..a8670209014 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc @@ -55,6 +55,11 @@ class FaceAreaFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const FaceAreaFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_FACE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index 90fa47c8217..7b084995fc3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -87,6 +87,11 @@ class PlanarFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const PlanarFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_FACE; + } }; static void geo_node_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc index 9e85eae3a31..429526588ce 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc @@ -66,6 +66,11 @@ class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const FaceNeighborCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_FACE; + } }; static VArray<int> construct_vertex_count_varray(const Mesh &mesh, const eAttrDomain domain) @@ -102,6 +107,11 @@ class FaceVertexCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const FaceVertexCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_FACE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc index 9d7735e707d..6d19d3be511 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc @@ -61,6 +61,11 @@ class IslandFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const IslandFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; class IslandCountFieldInput final : public bke::MeshFieldInput { @@ -100,6 +105,11 @@ class IslandCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const IslandCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc index ab44a6c8515..6b7f62a944c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc @@ -58,6 +58,11 @@ class VertexCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const VertexCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; static VArray<int> construct_face_count_gvarray(const Mesh &mesh, const eAttrDomain domain) @@ -98,6 +103,11 @@ class VertexFaceCountFieldInput final : public bke::MeshFieldInput { { return dynamic_cast<const VertexFaceCountFieldInput *>(&other) != nullptr; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc index a54daabde3b..00c92e30443 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc @@ -143,6 +143,11 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { @@ -206,6 +211,11 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_POINT; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc index df1427ac5b9..0326c55b65a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc @@ -111,6 +111,12 @@ class InterpolateDomain final : public bke::GeometryFieldInput { return attributes.adapt_domain( GVArray::ForGArray(std::move(values)), src_domain_, context.domain()); } + + std::optional<eAttrDomain> preferred_domain( + const GeometryComponent & /*component*/) const override + { + return src_domain_; + } }; static StringRefNull identifier_suffix(eCustomDataType data_type) diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc index 628688f3b47..dfb4181926e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc @@ -100,6 +100,12 @@ class MaterialSelectionFieldInput final : public bke::GeometryFieldInput { } return false; } + + std::optional<eAttrDomain> preferred_domain( + const GeometryComponent & /*component*/) const override + { + return ATTR_DOMAIN_FACE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc index 88cccfb2f94..1b9852cf7b9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc @@ -65,6 +65,11 @@ class BoundaryFieldInput final : public bke::MeshFieldInput { return mesh.attributes().adapt_domain<bool>( VArray<bool>::ForContainer(std::move(boundary)), ATTR_DOMAIN_EDGE, domain); } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_EDGE; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index d0b770aadad..51b21b218fe 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -87,56 +87,6 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } -static void try_capture_field_on_geometry(GeometryComponent &component, - const StringRef name, - const eAttrDomain domain, - const GField &field, - std::atomic<bool> &r_failure) -{ - MutableAttributeAccessor attributes = *component.attributes_for_write(); - const int domain_size = attributes.domain_size(domain); - if (domain_size == 0) { - return; - } - - bke::GeometryFieldContext field_context{component, domain}; - const IndexMask mask{IndexMask(domain_size)}; - - const CPPType &type = field.cpp_type(); - const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(type); - const bke::AttributeValidator validator = attributes.lookup_validator(name); - - /* Could avoid allocating a new buffer if: - * - We are writing to an attribute that exists already with the correct domain and type. - * - The field does not depend on that attribute (we can't easily check for that yet). */ - void *buffer = MEM_mallocN(type.size() * domain_size, __func__); - - fn::FieldEvaluator evaluator{field_context, &mask}; - evaluator.add_with_destination(validator.validate_field_if_necessary(field), - GMutableSpan{type, buffer, domain_size}); - evaluator.evaluate(); - - if (GAttributeWriter attribute = attributes.lookup_for_write(name)) { - if (attribute.domain == domain && attribute.varray.type() == type) { - attribute.varray.set_all(buffer); - attribute.finish(); - type.destruct_n(buffer, domain_size); - MEM_freeN(buffer); - return; - } - } - attributes.remove(name); - if (attributes.add(name, domain, data_type, bke::AttributeInitMoveArray{buffer})) { - return; - } - - /* If the name corresponds to a builtin attribute, removing the attribute might fail if - * it's required, and adding the attribute might fail if the domain or type is incorrect. */ - type.destruct_n(buffer, domain_size); - MEM_freeN(buffer); - r_failure = true; -} - static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); @@ -192,7 +142,9 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_instances()) { GeometryComponent &component = geometry_set.get_component_for_write( GEO_COMPONENT_TYPE_INSTANCES); - try_capture_field_on_geometry(component, name, domain, field, failure); + if (!bke::try_capture_field_on_geometry(component, name, domain, field)) { + failure.store(true); + } } } else { @@ -201,7 +153,9 @@ static void node_geo_exec(GeoNodeExecParams params) {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) { if (geometry_set.has(type)) { GeometryComponent &component = geometry_set.get_component_for_write(type); - try_capture_field_on_geometry(component, name, domain, field, failure); + if (!bke::try_capture_field_on_geometry(component, name, domain, field)) { + failure.store(true); + } } } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc index ccb489f6e29..67e35f1f023 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc @@ -118,6 +118,11 @@ class PackIslandsFieldInput final : public bke::MeshFieldInput { { return construct_uv_gvarray(mesh, selection_field, uv_field, rotate, margin, domain); } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_CORNER; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index 801bc3f4642..ae9a532ed66 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -160,6 +160,11 @@ class UnwrapFieldInput final : public bke::MeshFieldInput { { return construct_uv_gvarray(mesh, selection, seam, fill_holes, margin, method, domain); } + + std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override + { + return ATTR_DOMAIN_CORNER; + } }; static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index 2c8a70901f8..ec900a41bbc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -6,7 +6,7 @@ #include "UI_resources.h" #include "ED_node.h" -#include "ED_spreadsheet.h" +#include "ED_viewer_path.hh" #include "NOD_socket_search_link.hh" @@ -30,12 +30,18 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryViewer *data = MEM_cnew<NodeGeometryViewer>(__func__); data->data_type = CD_PROP_FLOAT; + data->domain = ATTR_DOMAIN_AUTO; node->storage = data; } static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); +} + +static void node_layout_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); } @@ -79,7 +85,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) SpaceNode *snode = CTX_wm_space_node(¶ms.C); Main *bmain = CTX_data_main(¶ms.C); ED_node_set_active(bmain, snode, ¶ms.node_tree, &viewer_node, nullptr); - ED_spreadsheet_context_paths_set_geometry_node(bmain, snode, &viewer_node); + ed::viewer_path::activate_geometry_node(*bmain, *snode, viewer_node); }; const std::optional<eCustomDataType> type = node_socket_to_custom_data_type( @@ -132,7 +138,9 @@ void register_node_type_geo_viewer() node_type_update(&ntype, file_ns::node_update); node_type_init(&ntype, file_ns::node_init); ntype.declare = file_ns::node_declare; - ntype.draw_buttons_ex = file_ns::node_layout; + ntype.draw_buttons = file_ns::node_layout; + ntype.draw_buttons_ex = file_ns::node_layout_ex; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; + ntype.no_muting = true; nodeRegisterType(&ntype); } |