Fix #120179: Assert failure after sculpt trim operation

Seems to be caused by c53e220aef. I didn't think our PBVH building would
ever create a node with no triangles, but I guess I was wrong, since I
checked and the PBVH is clearly being rebuilt after the trim operation,
so it seems there isn't anything else weird going on here.

Rather than trying to figure that out, I'll just add the empty check
back here. Eventually we should completely replace the algorithm that
creates the PBVH nodes anyway.
This commit is contained in:
Hans Goudey 2024-04-02 17:58:36 -04:00
parent d001302200
commit 768c68f19b
1 changed files with 10 additions and 6 deletions

View File

@ -1053,10 +1053,12 @@ struct PBVHBatches {
void create_index_faces(const PBVH_GPU_Args &args)
{
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArray material_indices = *attributes.lookup_or_default<int>(
"material_index", bke::AttrDomain::Face, 0);
material_index = material_indices[args.tri_faces[args.prim_indices.first()]];
if (!args.prim_indices.is_empty()) {
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArray material_indices = *attributes.lookup_or_default<int>(
"material_index", bke::AttrDomain::Face, 0);
material_index = material_indices[args.tri_faces[args.prim_indices.first()]];
}
const Span<int2> edges = args.mesh->edges();
@ -1144,8 +1146,10 @@ struct PBVHBatches {
const BitGroupVector<> &grid_hidden = args.subdiv_ccg->grid_hidden;
const Span<int> grid_to_face_map = args.subdiv_ccg->grid_to_face_map;
material_index = material_indices[BKE_subdiv_ccg_grid_to_face_index(
*args.subdiv_ccg, args.grid_indices.first())];
if (!args.grid_indices.is_empty()) {
material_index = material_indices[BKE_subdiv_ccg_grid_to_face_index(
*args.subdiv_ccg, args.grid_indices.first())];
}
needs_tri_index = true;
int gridsize = args.ccg_key.grid_size;