Realize depth code review fixes #6

Merged
Arye Ramaty merged 10 commits from David-Haver/blender:realize-depth into WIP-realize-depth 2024-04-22 11:18:11 +02:00
2 changed files with 15 additions and 16 deletions
Showing only changes of commit 67cae5c971 - Show all commits

View File

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

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,
const Span<StringRef> ignored_attributes,
GeometryComponent &r_result)
GeometryComponent &result,
const Span<StringRef> ignored_attributes = {})
{
const Map<AttributeIDRef, AttributeMetaData> info = get_final_attribute_info(src_components,
ignored_attributes);
@ -85,7 +85,7 @@ void join_attributes(const Span<const GeometryComponent *> src_components,
const AttributeMetaData &meta_data = item.value;
bke::GSpanAttributeWriter write_attribute =
r_result.attributes_for_write()->lookup_or_add_for_write_only_span(
result.attributes_for_write()->lookup_or_add_for_write_only_span(
attribute_id, meta_data.domain, meta_data.data_type);
if (!write_attribute) {
continue;
@ -97,7 +97,7 @@ void join_attributes(const Span<const GeometryComponent *> src_components,
}
static void join_instances(const Span<const GeometryComponent *> src_components,
GeometrySet &r_result)
GeometrySet &result)
{
Array<int> offsets_data(src_components.size() + 1);
for (const int i : src_components.index_range()) {
@ -127,9 +127,9 @@ static void join_instances(const Span<const GeometryComponent *> src_components,
array_utils::gather(handle_map.as_span(), src_handles, all_handles.slice(dst_range));
}
r_result.replace_instances(dst_instances.release());
auto &dst_component = r_result.get_component_for_write<bke::InstancesComponent>();
join_attributes(src_components, {".reference_index"}, dst_component);
result.replace_instances(dst_instances.release());
auto &dst_component = result.get_component_for_write<bke::InstancesComponent>();
join_attributes(src_components, dst_component, {".reference_index"});
}
static void join_volumes(const Span<const GeometryComponent *> /*src_components*/,
@ -142,7 +142,7 @@ static void join_volumes(const Span<const GeometryComponent *> /*src_components*
static void join_component_type(const bke::GeometryComponent::Type component_type,
const Span<GeometrySet> src_geometry_sets,
const bke::AnonymousAttributePropagationInfo &propagation_info,
GeometrySet &r_result)
GeometrySet &result)
{
Vector<const GeometryComponent *> components;
for (const GeometrySet &geometry_set : src_geometry_sets) {
@ -156,16 +156,16 @@ static void join_component_type(const bke::GeometryComponent::Type component_typ
return;
}
if (components.size() == 1) {
r_result.add(*components.first());
result.add(*components.first());
return;
}
switch (component_type) {
case bke::GeometryComponent::Type::Instance:
join_instances(components, r_result);
join_instances(components, result);
return;
case bke::GeometryComponent::Type::Volume:
join_volumes(components, r_result);
join_volumes(components, result);
return;
default:
break;
@ -185,10 +185,9 @@ static void join_component_type(const bke::GeometryComponent::Type component_typ
options.keep_original_ids = true;
options.realize_instance_attributes = false;
options.propagation_info = propagation_info;
GeometrySet joined_components = realize_instances(
GeometrySet::from_instances(instances.release()), options);
r_result.add(joined_components.get_component_for_write(component_type));
result.add(joined_components.get_component_for_write(component_type));
}
GeometrySet join_geometries(const Span<GeometrySet> geometries,