Merge pull request #755 from revarbat/revarbat_dev

Quantize up  to a multiple of 4 for rounded edges.
This commit is contained in:
Revar Desmera 2022-01-12 23:43:38 -08:00 committed by GitHub
commit 27a8d90f01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,9 +102,9 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// Creates a cube or cuboid object, with optional chamfering or rounding of edges and corners. // Creates a cube or cuboid object, with optional chamfering or rounding of edges and corners.
// You cannot mix chamfering and rounding: just one edge treatment with the same size applies to all selected edges. // You cannot mix chamfering and rounding: just one edge treatment with the same size applies to all selected edges.
// Negative chamfers and roundings can be applied to create external fillets, but they // Negative chamfers and roundings can be applied to create external fillets, but they
// but only apply to edges around the top or bottom faces. If you specify an edge set other than "ALL" // only apply to edges around the top or bottom faces. If you specify an edge set other than "ALL"
// with such roundings or chamfers then you will get an error. See // with negative roundings or chamfers then you will get an error. See [Specifying Edges](attachments.scad#section-specifying-edges)
// [Specifying Edges](attachments.scad#section-specifying-edges) for information on how to specify edge sets. // for information on how to specify edge sets.
// Arguments: // Arguments:
// size = The size of the cube, a number or length 3 vector. // size = The size of the cube, a number or length 3 vector.
// --- // ---
@ -192,7 +192,7 @@ module cuboid(
dummy=assert(is_finite(r) && !approx(r,0)); dummy=assert(is_finite(r) && !approx(r,0));
c = [min(r,size.x/2), min(r,size.y/2), min(r,size.z/2)]; c = [min(r,size.x/2), min(r,size.y/2), min(r,size.z/2)];
c2 = v_mul(corner,c/2); c2 = v_mul(corner,c/2);
$fn = is_finite(chamfer)? 4 : segs(r); $fn = is_finite(chamfer)? 4 : quantup(segs(r),4);
translate(v_mul(corner, size/2-c)) { translate(v_mul(corner, size/2-c)) {
if (cnt == 0 || approx(r,0)) { if (cnt == 0 || approx(r,0)) {
translate(c2) cube(c, center=true); translate(c2) cube(c, center=true);