forked from blender/blender
davidhaver-WIP-realize-depth #3
@ -195,19 +195,56 @@ void join_transform_instance_components(Span<const bke::InstancesComponent *> sr
|
|||||||
Span<blender::float4x4> src_base_transforms,
|
Span<blender::float4x4> src_base_transforms,
|
||||||
GeometrySet &result)
|
GeometrySet &result)
|
||||||
{
|
{
|
||||||
|
BLI_assert(src_components.size() == src_base_transforms.size());
|
||||||
if (src_components.is_empty()){
|
if (src_components.is_empty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (src_components.size() == 1){
|
VArray<blender::float4x4>::ForSpan(src_base_transforms);
|
||||||
result.add(*src_components.first());
|
std::unique_ptr<bke::Instances> dst_instances = std::make_unique<bke::Instances>();
|
||||||
return;
|
int tot_instances = 0;
|
||||||
|
for (const bke::InstancesComponent *src_component : src_components) {
|
||||||
|
tot_instances += src_component->get()->instances_num();
|
||||||
}
|
}
|
||||||
else{
|
// dst_instances->reserve(tot_instances);
|
||||||
result.add(*src_components[0]);
|
|
||||||
result.add(*src_components[1]);
|
for (const int i:src_components.index_range())
|
||||||
result.add(*src_components[2]);
|
{
|
||||||
return;
|
const bke::InstancesComponent *src_component = src_components[i];
|
||||||
|
const blender::float4x4 &base_transform = src_base_transforms[i];
|
||||||
|
const bke::Instances &src_instances = *src_component->get();
|
||||||
|
|
||||||
|
Span<bke::InstanceReference> src_references = src_instances.references();
|
||||||
|
Array<int> handle_map(src_references.size());
|
||||||
|
for (const int src_handle : src_references.index_range()) {
|
||||||
|
handle_map[src_handle] = dst_instances->add_reference(src_references[src_handle]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Span<float4x4> src_transforms = src_instances.transforms();
|
||||||
|
Span<int> src_reference_handles = src_instances.reference_handles();
|
||||||
|
for (const int i : src_transforms.index_range())
|
||||||
|
{
|
||||||
|
const int src_handle = src_reference_handles[i];
|
||||||
|
const int dst_handle = handle_map[src_handle];
|
||||||
|
const float4x4 &transform = base_transform * src_transforms[i];
|
||||||
|
dst_instances->add_instance(dst_handle, transform);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.replace_instances(dst_instances.release());
|
||||||
|
bke::InstancesComponent &dst_component = result.get_component_for_write<bke::InstancesComponent>();
|
||||||
|
join_attributes(src_components, dst_component, {"position"});
|
||||||
|
|
||||||
|
// if (src_components.size() == 1){
|
||||||
|
// result.add(*src_components.first());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// result.add(*src_components[0]);
|
||||||
|
// result.add(*src_components[1]);
|
||||||
|
// result.add(*src_components[2]);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometrySet join_geometries(const Span<GeometrySet> geometries,
|
GeometrySet join_geometries(const Span<GeometrySet> geometries,
|
||||||
|
Loading…
Reference in New Issue
Block a user