forked from blender/blender
Realize depth code review fixes #6
@ -12,7 +12,7 @@ namespace blender::geometry {
|
|||||||
bke::GeometrySet join_geometries(Span<bke::GeometrySet> geometries,
|
bke::GeometrySet join_geometries(Span<bke::GeometrySet> geometries,
|
||||||
const bke::AnonymousAttributePropagationInfo &propagation_info);
|
const bke::AnonymousAttributePropagationInfo &propagation_info);
|
||||||
|
|
||||||
void join_attributes(Span<const bke::GeometryComponent *> src_components,
|
void join_attributes(const Span<const GeometryComponent *> src_components,
|
||||||
Span<StringRef> ignored_attributes,
|
GeometryComponent &r_result,
|
||||||
bke::GeometryComponent &r_result);
|
const Span<StringRef> ignored_attributes = {})
|
||||||
} // namespace blender::geometry
|
} // namespace blender::geometry
|
||||||
|
@ -74,8 +74,8 @@ static void fill_new_attribute(const Span<const GeometryComponent *> src_compone
|
|||||||
}
|
}
|
||||||
|
|
||||||
void join_attributes(const Span<const GeometryComponent *> src_components,
|
void join_attributes(const Span<const GeometryComponent *> src_components,
|
||||||
const Span<StringRef> ignored_attributes,
|
GeometryComponent &result,
|
||||||
GeometryComponent &r_result)
|
const Span<StringRef> ignored_attributes = {})
|
||||||
{
|
{
|
||||||
const Map<AttributeIDRef, AttributeMetaData> info = get_final_attribute_info(src_components,
|
const Map<AttributeIDRef, AttributeMetaData> info = get_final_attribute_info(src_components,
|
||||||
ignored_attributes);
|
ignored_attributes);
|
||||||
@ -85,7 +85,7 @@ void join_attributes(const Span<const GeometryComponent *> src_components,
|
|||||||
const AttributeMetaData &meta_data = item.value;
|
const AttributeMetaData &meta_data = item.value;
|
||||||
|
|
||||||
bke::GSpanAttributeWriter write_attribute =
|
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);
|
attribute_id, meta_data.domain, meta_data.data_type);
|
||||||
if (!write_attribute) {
|
if (!write_attribute) {
|
||||||
continue;
|
continue;
|
||||||
@ -97,7 +97,7 @@ void join_attributes(const Span<const GeometryComponent *> src_components,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void join_instances(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);
|
Array<int> offsets_data(src_components.size() + 1);
|
||||||
for (const int i : src_components.index_range()) {
|
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));
|
array_utils::gather(handle_map.as_span(), src_handles, all_handles.slice(dst_range));
|
||||||
}
|
}
|
||||||
|
|
||||||
r_result.replace_instances(dst_instances.release());
|
result.replace_instances(dst_instances.release());
|
||||||
auto &dst_component = r_result.get_component_for_write<bke::InstancesComponent>();
|
auto &dst_component = result.get_component_for_write<bke::InstancesComponent>();
|
||||||
join_attributes(src_components, {".reference_index"}, dst_component);
|
join_attributes(src_components, dst_component, {".reference_index"});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void join_volumes(const Span<const GeometryComponent *> /*src_components*/,
|
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,
|
static void join_component_type(const bke::GeometryComponent::Type component_type,
|
||||||
const Span<GeometrySet> src_geometry_sets,
|
const Span<GeometrySet> src_geometry_sets,
|
||||||
const bke::AnonymousAttributePropagationInfo &propagation_info,
|
const bke::AnonymousAttributePropagationInfo &propagation_info,
|
||||||
GeometrySet &r_result)
|
GeometrySet &result)
|
||||||
{
|
{
|
||||||
Vector<const GeometryComponent *> components;
|
Vector<const GeometryComponent *> components;
|
||||||
for (const GeometrySet &geometry_set : src_geometry_sets) {
|
for (const GeometrySet &geometry_set : src_geometry_sets) {
|
||||||
@ -156,16 +156,16 @@ static void join_component_type(const bke::GeometryComponent::Type component_typ
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (components.size() == 1) {
|
if (components.size() == 1) {
|
||||||
r_result.add(*components.first());
|
result.add(*components.first());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (component_type) {
|
switch (component_type) {
|
||||||
case bke::GeometryComponent::Type::Instance:
|
case bke::GeometryComponent::Type::Instance:
|
||||||
join_instances(components, r_result);
|
join_instances(components, result);
|
||||||
return;
|
return;
|
||||||
case bke::GeometryComponent::Type::Volume:
|
case bke::GeometryComponent::Type::Volume:
|
||||||
join_volumes(components, r_result);
|
join_volumes(components, result);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -185,10 +185,9 @@ static void join_component_type(const bke::GeometryComponent::Type component_typ
|
|||||||
options.keep_original_ids = true;
|
options.keep_original_ids = true;
|
||||||
options.realize_instance_attributes = false;
|
options.realize_instance_attributes = false;
|
||||||
options.propagation_info = propagation_info;
|
options.propagation_info = propagation_info;
|
||||||
|
|
||||||
GeometrySet joined_components = realize_instances(
|
GeometrySet joined_components = realize_instances(
|
||||||
GeometrySet::from_instances(instances.release()), options);
|
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,
|
GeometrySet join_geometries(const Span<GeometrySet> geometries,
|
||||||
|
Loading…
Reference in New Issue
Block a user