Many nodes operate on all the instances that are passed into them. For example,
the Subdivision Surface node subdivides the mesh at the root but also instanced
meshes. This works well for most nodes, but there are a few nodes were the old
`modify_geometry_sets` function was not very well defined and it was tricky to
use correctly.
The fundamental problem was that the behavior is not obvious when a node creates
or modifies instances and how those are integrated with the already existing
instances.
This patch solves this with the following changes:
* Remove the old `GeometrySet::modify_geometry_sets` and related
`*_during_modify` methods.
* Add a new `blender::geometry::foreach_real_geometry` function that is similar
to the old `modify_geometry_sets` but has a more well-defined interface:
* It never passes instances into the callback. So existing instances can't be
modified with it.
* The callback is allowed to create new instances. This will automatically be
merged back with potentially already existing instances. The callback does
not have to worry about accidentally invalidating existing instances like
before.
* A few existing usages used `modify_geometry_sets` to actually modify existing
instances (usually just removing attributes). Those can't use the new
`foreach_real_geometry`, so they just get a custom simple recursive
implementation instead of using a generic function.
Pull Request: https://projects.blender.org/blender/blender/pulls/143898
28 lines
1.2 KiB
C++
28 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BKE_geometry_set.hh"
|
|
|
|
namespace blender::geometry {
|
|
|
|
/**
|
|
* \param allow_merging_instance_references: If true, instance references from multiple instances
|
|
* components may be merged when they are the same. This is typically good because it reduces the
|
|
* amount of processing for later nodes. However, this may be undesirable in some cases if the
|
|
* instance references are modified afterwards and the calling code assumes that the instances
|
|
* references are just concatenated.
|
|
*/
|
|
bke::GeometrySet join_geometries(Span<bke::GeometrySet> geometries,
|
|
const bke::AttributeFilter &attribute_filter,
|
|
const std::optional<Span<bke::GeometryComponent::Type>>
|
|
&component_types_to_join = std::nullopt,
|
|
bool allow_merging_instance_references = true);
|
|
|
|
void join_attributes(const Span<const bke::GeometryComponent *> src_components,
|
|
bke::GeometryComponent &r_result,
|
|
const Span<StringRef> ignored_attributes = {});
|
|
} // namespace blender::geometry
|