Skip to content

Commit

Permalink
Remove spurious warnings in OpenSCAD 2021.01
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-siegel committed Mar 11, 2021
1 parent 7e0755b commit 8429c4b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/scad/puzzlecad/puzzlecad-burr.scad
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ module burr_piece_base(burr_spec, test_poly = undef) {

// If the facing cell *is* defined but is from a different component, then
// we need to render a space-filler.
if (lookup3(burr, facing_cell) > 0 && lookup3(burr, facing_cell) != lookup3(burr, cell)) {
if (is_nonzero(lookup3(burr, facing_cell)) && lookup3(burr, facing_cell) != lookup3(burr, cell)) {

// Space-filler is 2*insets wide in the facing direction, and (scale - 2*insets - bevel/2)
// in the orthogonal directions. This ensures that the corners exactly meet the bevel line
Expand All @@ -283,9 +283,9 @@ module burr_piece_base(burr_spec, test_poly = undef) {
// duplicates.
if (face < 5)
for (other_face=[face+1:5]) {
if (lookup3(burr, facing_cell) > 0 &&
lookup3(burr, cell + directions[other_face]) > 0 &&
lookup3(burr, facing_cell + directions[other_face]) > 0 &&
if (is_nonzero(lookup3(burr, facing_cell)) &&
is_nonzero(lookup3(burr, cell + directions[other_face])) &&
is_nonzero(lookup3(burr, facing_cell + directions[other_face])) &&
( lookup3(burr, facing_cell) != lookup3(burr, cell) ||
lookup3(burr, cell + directions[other_face]) != lookup3(burr, cell) ||
lookup3(burr, facing_cell + directions[other_face]) != lookup3(burr, cell)
Expand Down
4 changes: 2 additions & 2 deletions src/main/scad/puzzlecad/puzzlecad-layout.scad
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function auto_layout_joints(layers, next_joint_letter, z, type) =

function is_joint_location(layers, offset, x, y, z) =
layers[z][y][x][0] > 0 && layers[z + offset][y][x][0] > 0 &&
!(layers[z][y-1][x][0] > 0 && layers[z][y+1][x][0] > 0 && layers[z + offset][y-1][x][0] > 0 && layers[z + offset][y+1][x][0] > 0) &&
!(layers[z][y][x-1][0] > 0 && layers[z][y][x+1][0] > 0 && layers[z + offset][y][x-1][0] > 0 && layers[z + offset][y][x+1][0] > 0);
!(is_nonzero(layers[z][y-1][x][0]) && is_nonzero(layers[z][y+1][x][0]) && is_nonzero(layers[z + offset][y-1][x][0]) && is_nonzero(layers[z + offset][y+1][x][0])) &&
!(is_nonzero(layers[z][y][x-1][0]) && is_nonzero(layers[z][y][x+1][0]) && is_nonzero(layers[z + offset][y][x-1][0]) && is_nonzero(layers[z + offset][y][x+1][0]));

function to_blank_layer(layer) =
[ for (yslice = layer)
Expand Down
1 change: 1 addition & 0 deletions src/main/scad/puzzlecad/puzzlecad-polyhedra.scad
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ function has_beveling() =
!is_undef($burr_bevel_adjustments);

function is_positive_bevel(bevel) =
is_undef(bevel) ? undef :
let (bevel_or_pair = to_2_vector(bevel))
bevel_or_pair[0] >= 0.01 || bevel_or_pair[1] >= 0.01;

Expand Down
3 changes: 3 additions & 0 deletions src/main/scad/puzzlecad/puzzlecad-util.scad
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ function union_of_number_lists(list1, list2, i = 0, j = 0) =

/***** Misc *****/

// Returns true if x is defined and not equal to 0.
function is_nonzero(x) = !is_undef(x) && x != 0;

function argmin(list, i = 0, cur_argmin = undef, cur_min = undef) =
i >= len(list) ? cur_argmin
: is_undef(cur_argmin) || list[i] < cur_min ? argmin(list, i + 1, i, list[i])
Expand Down

0 comments on commit 8429c4b

Please sign in to comment.