davidhaver-WIP-realize-depth #3

Closed
David-Haver wants to merge 65 commits from David-Haver/blender-old:davidhaver-WIP-realize-depth into WIP-realize-depth

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 7ae7891f99 - Show all commits

View File

@ -190,24 +190,61 @@ static void join_component_type(const bke::GeometryComponent::Type component_typ
result.add(joined_components.get_component_for_write(component_type));
}
void join_transform_instance_components(Span<const bke::InstancesComponent *> src_components,
Span<blender::float4x4> src_base_transforms,
GeometrySet &result)
{
BLI_assert(src_components.size() == src_base_transforms.size());
if (src_components.is_empty()){
return;
}
if (src_components.size() == 1){
result.add(*src_components.first());
return;
VArray<blender::float4x4>::ForSpan(src_base_transforms);
std::unique_ptr<bke::Instances> dst_instances = std::make_unique<bke::Instances>();
int tot_instances = 0;
for (const bke::InstancesComponent *src_component : src_components) {
tot_instances += src_component->get()->instances_num();
}
else{
result.add(*src_components[0]);
result.add(*src_components[1]);
result.add(*src_components[2]);
return;
// dst_instances->reserve(tot_instances);
for (const int i:src_components.index_range())
{
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,