davidhaver-WIP-realize-depth #2

Merged
Arye Ramaty merged 11 commits from David-Haver/blender-old:davidhaver-WIP-realize-depth into WIP-realize-depth 2024-03-21 14:55:23 +01:00
Showing only changes of commit 5b38b1fb66 - Show all commits

View File

@ -639,9 +639,7 @@ static void gather_realize_tasks_recursive(GatherTasksInfo &gather_info,
const bke::GeometryComponent::Type type = component->type(); const bke::GeometryComponent::Type type = component->type();
switch (type) { switch (type) {
case bke::GeometryComponent::Type::Mesh: { case bke::GeometryComponent::Type::Mesh: {
const bke::MeshComponent &mesh_component = *static_cast<const bke::MeshComponent *>( const Mesh *mesh = (*static_cast<const bke::MeshComponent *>(component)).get();
component);
const Mesh *mesh = mesh_component.get();
if (mesh != nullptr && mesh->verts_num > 0) { if (mesh != nullptr && mesh->verts_num > 0) {
const int mesh_index = gather_info.meshes.order.index_of(mesh); const int mesh_index = gather_info.meshes.order.index_of(mesh);
const MeshRealizeInfo &mesh_info = gather_info.meshes.realize_info[mesh_index]; const MeshRealizeInfo &mesh_info = gather_info.meshes.realize_info[mesh_index];
@ -697,9 +695,8 @@ static void gather_realize_tasks_recursive(GatherTasksInfo &gather_info,
gather_info.instances.instances_components_transforms.append(base_transform); gather_info.instances.instances_components_transforms.append(base_transform);
} }
else { else {
const auto &instances_component = *static_cast<const bke::InstancesComponent *>( const Instances *instances =
component); (*static_cast<const bke::InstancesComponent *>(component)).get();
const Instances *instances = instances_component.get();
if (instances != nullptr && instances->instances_num() > 0) { if (instances != nullptr && instances->instances_num() > 0) {
gather_realize_tasks_for_instances(gather_info, gather_realize_tasks_for_instances(gather_info,
current_depth, current_depth,
@ -712,8 +709,9 @@ static void gather_realize_tasks_recursive(GatherTasksInfo &gather_info,
break; break;
} }
case bke::GeometryComponent::Type::Volume: { case bke::GeometryComponent::Type::Volume: {
const auto *volume_component = static_cast<const bke::VolumeComponent *>(component);
if (!gather_info.r_tasks.first_volume) { if (!gather_info.r_tasks.first_volume) {
const bke::VolumeComponent *volume_component = static_cast<const bke::VolumeComponent *>(
component);
volume_component->add_user(); volume_component->add_user();
gather_info.r_tasks.first_volume = ImplicitSharingPtr<const bke::VolumeComponent>( gather_info.r_tasks.first_volume = ImplicitSharingPtr<const bke::VolumeComponent>(
volume_component); volume_component);
@ -721,9 +719,9 @@ static void gather_realize_tasks_recursive(GatherTasksInfo &gather_info,
break; break;
} }
case bke::GeometryComponent::Type::Edit: { case bke::GeometryComponent::Type::Edit: {
const auto *edit_component = static_cast<const bke::GeometryComponentEditData *>(
component);
if (!gather_info.r_tasks.first_edit_data) { if (!gather_info.r_tasks.first_edit_data) {
const bke::GeometryComponentEditData *edit_component =
static_cast<const bke::GeometryComponentEditData *>(component);
edit_component->add_user(); edit_component->add_user();
gather_info.r_tasks.first_edit_data = gather_info.r_tasks.first_edit_data =
ImplicitSharingPtr<const bke::GeometryComponentEditData>(edit_component); ImplicitSharingPtr<const bke::GeometryComponentEditData>(edit_component);
@ -1957,9 +1955,9 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
return geometry_set; return geometry_set;
} }
bke::GeometrySet temp_geometry_set; Vector<const bke::GeometryComponent *> instances_components_to_merge;
propagate_instances_to_keep( instances_components_to_merge.append(
geometry_set, options.selection, temp_geometry_set, options.propagation_info); &geometry_set.get_component_for_write<bke::InstancesComponent>());
if (options.keep_original_ids) { if (options.keep_original_ids) {
remove_id_attribute_from_instances(geometry_set); remove_id_attribute_from_instances(geometry_set);
@ -1990,12 +1988,9 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
const float4x4 transform = float4x4::identity(); const float4x4 transform = float4x4::identity();
InstanceContext attribute_fallbacks(gather_info); InstanceContext attribute_fallbacks(gather_info);
if (temp_geometry_set.has_instances()) { gather_info.instances.instances_components_to_merge = std::move(instances_components_to_merge);
gather_info.instances.instances_components_to_merge.append( gather_info.instances.instances_components_transforms.append(float4x4::identity());
&temp_geometry_set.get_component_for_write<bke::InstancesComponent>()); gather_info.instances.attribute_fallback.append((gather_info.instances_attriubutes.size()));
gather_info.instances.instances_components_transforms.append(float4x4::identity());
gather_info.instances.attribute_fallback.append((gather_info.instances_attriubutes.size()));
}
gather_realize_tasks_recursive(gather_info, 0, -1, geometry_set, transform, attribute_fallbacks); gather_realize_tasks_recursive(gather_info, 0, -1, geometry_set, transform, attribute_fallbacks);