28 b.use_custom_socket_order();
29 b.allow_any_socket_order();
30 b.add_default_layout();
31 b.add_input<
decl::Geometry>(
"Geometry"_ustr).description(
"Geometry to sort the elements of");
32 b.add_output<
decl::Geometry>(
"Geometry"_ustr).propagate_all_geometry().align_with_previous();
35 .evaluated_geometry_field()
52 const int domain_size,
57 if (domain_size == 0) {
63 evaluator.
add(group_id_field);
64 evaluator.
add(weight_field);
85 std::atomic<bool> has_reorder =
false;
86 std::atomic<bool> has_unsupported =
false;
91 instances->instances_num(),
97 *instances, *indices, attribute_filter);
107 if (src_component ==
nullptr || src_component->
is_empty()) {
110 if (!domains.contains(domain)) {
111 has_unsupported =
true;
121 if (!indices.has_value()) {
125 *src_component, *indices, domain, attribute_filter);
126 geometry_set.
remove(type);
127 geometry_set.
add(*dst_component.
get());
132 if (has_unsupported && !has_reorder) {
134 TIP_(
"Domain and geometry type combination is unsupported"));
137 params.
set_output(
"Geometry"_ustr, std::move(geometry_set));
150 items.
append({0,
nullptr, 0,
nullptr,
nullptr});
168 supported_items.
data(),
178 ntype.
ui_name =
"Sort Elements";
179 ntype.
ui_description =
"Rearrange geometry elements, changing their indices";
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_SORT_ELEMENTS
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
constexpr bool contains(const T &value) const
void append(const T &value)
int attribute_domain_size(AttrDomain domain) const
virtual bool is_empty() const
void set_selection(Field< bool > selection)
int add(GField field, GVArray *varray_ptr)
IndexMask get_evaluated_selection_as_mask() const
const GVArray & get_evaluated(const int field_index) const
void error_message_add(const NodeWarningType type, StringRef message) const
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
T extract_input(const UString identifier)
const bNode & node() const
void set_output(const UString identifier, T &&value)
static void remember_deformed_positions_if_necessary(GeometrySet &geometry)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
void node_register_type(bNodeType &ntype)
std::optional< Array< int > > sort_indices_by_weights(int domain_size, const IndexMask &mask, const VArray< int > &group_id, const VArray< float > &weight)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
const MultiValueMap< bke::GeometryComponent::Type, bke::AttrDomain > & components_supported_reordering()
bke::GeometryComponentPtr reordered_component(const bke::GeometryComponent &src_component, Span< int > old_by_new_map, bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter)
bke::Instances * reorder_instaces(const bke::Instances &src_instances, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_rna(StructRNA *srna)
static Vector< EnumPropertyItem > items_value_in(const Span< T > values, const EnumPropertyItem *src_items)
static std::optional< Array< int > > sorted_indices(const fn::FieldContext &field_context, const int domain_size, const Field< bool > selection_field, const Field< int > group_id_field, const Field< float > weight_field)
static void node_init(bNodeTree *, bNode *node)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
const EnumPropertyItem rna_enum_attribute_domain_items[]
void replace_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
const Instances * get_instances() const
void remove(const GeometryComponent::Type component_type)
void add(const GeometryComponent &component)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)