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,6 +427,8 @@ 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;
/* Allow col to be empty: then target mesh will just remove self-intersections. */
if (col) {
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) { FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) {
if (ob->type == OB_MESH && ob != ctx->object) { if (ob->type == OB_MESH && ob != ctx->object) {
col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false); col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false);
@ -442,6 +445,7 @@ static Mesh *collection_boolean_exact(BooleanModifierData *bmd,
} }
} }
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);