realize-depth #5

Merged
Arye Ramaty merged 43 commits from David-Haver/blender:realize-depth into WIP-realize-depth 2024-03-31 17:22:49 +02:00
5 changed files with 40 additions and 52 deletions
Showing only changes of commit 8bdb437601 - Show all commits

View File

@ -13,6 +13,6 @@ bke::GeometrySet join_geometries(Span<bke::GeometrySet> geometries,
const bke::AnonymousAttributePropagationInfo &propagation_info);
void join_attributes(Span<const bke::GeometryComponent *> src_components,
bke::GeometryComponent &r_result,
Span<StringRef> ignored_attributes = {});
Span<StringRef> ignored_attributes,
bke::GeometryComponent &r_result);
} // namespace blender::geometry

View File

@ -62,16 +62,8 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
const RealizeInstancesOptions &options);
/**
* Join all instances into a single geometry component for each geometry type. For example, all
* mesh instances (including the already realized mesh) are joined into a single mesh. The output
* geometry set does not contain any instances. If the input did not contain any instances, it is
* returned directly.
*
* The `id` attribute has special handling. If there is an id attribute on any component, the
* output will contain an `id` attribute as well. The output id is generated by mixing/hashing ids
* of instances and of the instanced geometry data.
*
* Will realize only the instances chosen by varied_depth_option to there chosen depth.
* Same #realize_instances but will realize only the instances chosen by
* varied_depth_option to there chosen depth.
*/
bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
const RealizeInstancesOptions &options,

View File

@ -74,8 +74,8 @@ static void fill_new_attribute(const Span<const GeometryComponent *> src_compone
}
void join_attributes(const Span<const GeometryComponent *> src_components,
GeometryComponent &r_result,
const Span<StringRef> ignored_attributes)
const Span<StringRef> ignored_attributes,
GeometryComponent &r_result)
{
const Map<AttributeIDRef, AttributeMetaData> info = get_final_attribute_info(src_components,
ignored_attributes);
@ -129,7 +129,7 @@ static void join_instances(const Span<const GeometryComponent *> src_components,
r_result.replace_instances(dst_instances.release());
auto &dst_component = r_result.get_component_for_write<bke::InstancesComponent>();
join_attributes(src_components, dst_component, {".reference_index"});
join_attributes(src_components, {".reference_index"}, dst_component);
}
static void join_volumes(const Span<const GeometryComponent *> /*src_components*/,

View File

@ -823,7 +823,6 @@ static bool attribute_foreach(const bke::GeometrySet &geometry_set,
return is_relevant;
}
/**
* Based on bke::GeometrySet::gather_attributes_for_propagation.
* Specialized for Specialized attribute_foreach to get:
@ -869,7 +868,8 @@ void static gather_attributes_for_propagation(
AttrDomain domain = meta_data.domain;
if (dst_component_type != bke::GeometryComponent::Type::Instance &&
domain == AttrDomain::Instance) {
domain == AttrDomain::Instance)
{
domain = AttrDomain::Point;
}
@ -1014,7 +1014,7 @@ static void execute_instances_tasks(
}
join_attributes(
for_join_attributes, dst_component, {"position", ".reference_index", "instance_transform"});
for_join_attributes, {"position", ".reference_index", "instance_transform"}, dst_component);
}
/** \} */
@ -1990,9 +1990,7 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
VariedDepthOption all_instances;
all_instances.depths = VArray<int>::ForSingle(VariedDepthOption::MAX_DEPTH,
geometry_set.get_instances()->instances_num());
IndexMaskMemory memory;
all_instances.selection = IndexMask::from_bools(
VArray<bool>::ForSingle(true, geometry_set.get_instances()->instances_num()), memory);
all_instances.selection = IndexMask(geometry_set.get_instances()->instances_num());
return realize_instances(geometry_set, options, all_instances);
}
@ -2049,12 +2047,8 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
const float4x4 transform = float4x4::identity();
InstanceContext attribute_fallbacks(gather_info);
gather_realize_tasks_recursive(gather_info,
0,
VariedDepthOption::MAX_DEPTH,
geometry_set,
transform,
attribute_fallbacks);
gather_realize_tasks_recursive(
gather_info, 0, VariedDepthOption::MAX_DEPTH, geometry_set, transform, attribute_fallbacks);
bke::GeometrySet new_geometry_set;
execute_instances_tasks(gather_info.instances.instances_components_to_merge,

View File

@ -18,13 +18,13 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_input<decl::Bool>("Selection")
.default_value(true)
.hide_value()
.supports_field()
.field_on_all()
.description("Which top-level instances to realize");
b.add_input<decl::Bool>("Realize All")
.default_value(true)
.supports_field()
.field_on_all()
.description("Determine wether to realize nested instances completly");
b.add_input<decl::Int>("Depth").default_value(0).min(0).supports_field().description(
b.add_input<decl::Int>("Depth").default_value(0).min(0).field_on_all().description(
"Number of levels of nested instances to realize for each top-level instance");
b.add_output<decl::Geometry>("Geometry").propagate_all();
}
@ -44,7 +44,9 @@ static void node_geo_exec(GeoNodeExecParams params)
static auto depth_override = mf::build::SI2_SO<int, bool, int>(
"depth_override",
[](int value, bool realize) { return realize ? -1 : std::max(value, 0); },
[](int value, bool realize_all_filed) {
return realize_all_filed ? geometry::VariedDepthOption::MAX_DEPTH : std::max(value, 0);
},
mf::build::exec_presets::AllSpanOrSingle());
static auto selection_override = mf::build::SI2_SO<int, bool, bool>(