Exact Boolean: let Collection be empty.

With an empty collection, Exact Boolean performs the useful function
of removing self-intersections.
This commit is contained in:
Howard Trickey 2020-10-10 12:03:48 -04:00
parent c68338ee89
commit 1b04eb6c44

View File

@ -96,7 +96,8 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return !bmd->object || bmd->object->type != OB_MESH; return !bmd->object || bmd->object->type != OB_MESH;
} }
if (bmd->flag & eBooleanModifierFlag_Collection) { if (bmd->flag & eBooleanModifierFlag_Collection) {
return !col; /* The Exact solver tolerates an empty collection. */
return !col && bmd->solver != eBooleanModifierSolver_Exact;
} }
return false; return false;
} }
@ -426,22 +427,25 @@ static Mesh *collection_boolean_exact(BooleanModifierData *bmd,
BLI_array_append(meshes, mesh); BLI_array_append(meshes, mesh);
BLI_array_append(objects, ctx->object); BLI_array_append(objects, ctx->object);
Mesh *col_mesh; Mesh *col_mesh;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) { /* Allow col to be empty: then target mesh will just remove self-intersections. */
if (ob->type == OB_MESH && ob != ctx->object) { if (col) {
col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false); FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) {
/* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh! if (ob->type == OB_MESH && ob != ctx->object) {
* But for 2.90 better not try to be smart here. */ col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false);
BKE_mesh_wrapper_ensure_mdata(col_mesh); /* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
BLI_array_append(meshes, col_mesh); * But for 2.90 better not try to be smart here. */
BLI_array_append(objects, ob); BKE_mesh_wrapper_ensure_mdata(col_mesh);
bat.totvert += col_mesh->totvert; BLI_array_append(meshes, col_mesh);
bat.totedge += col_mesh->totedge; BLI_array_append(objects, ob);
bat.totloop += col_mesh->totloop; bat.totvert += col_mesh->totvert;
bat.totface += col_mesh->totpoly; bat.totedge += col_mesh->totedge;
++num_shapes; bat.totloop += col_mesh->totloop;
bat.totface += col_mesh->totpoly;
++num_shapes;
}
} }
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
} }
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
int *shape_face_end = MEM_mallocN(num_shapes * sizeof(int), __func__); int *shape_face_end = MEM_mallocN(num_shapes * sizeof(int), __func__);
int *shape_vert_end = MEM_mallocN(num_shapes * sizeof(int), __func__); int *shape_vert_end = MEM_mallocN(num_shapes * sizeof(int), __func__);
bool is_neg_mat0 = is_negative_m4(ctx->object->obmat); bool is_neg_mat0 = is_negative_m4(ctx->object->obmat);