diff --git a/src/linalg.cc b/src/linalg.cc index 67990552..274a70a5 100644 --- a/src/linalg.cc +++ b/src/linalg.cc @@ -14,6 +14,7 @@ */ BoundingBox operator*(const Transform3d &m, const BoundingBox &box) { + if (box.isEmpty()) return box; BoundingBox newbox; Vector3d boxvec[2] = { box.min(), box.max() }; for (int k=0;k<2;k++) { diff --git a/testdata/scad/misc/rotate-empty-bbox.scad b/testdata/scad/misc/rotate-empty-bbox.scad new file mode 100644 index 00000000..f39a923f --- /dev/null +++ b/testdata/scad/misc/rotate-empty-bbox.scad @@ -0,0 +1,11 @@ +// rotate([90,0,0]) results in a matrix with some close-to-zero values +// Transforming an empty boundingbox by this matrix has caused a problem resulting +// in the union being evaluated to nothing. +rotate([90,0,0]) +difference() { + cube(60, center=true); + union() { + translate([0,0,40]) cube(50, center=true); + cube(0); + } +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index daf7c1e5..6e1f9057 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -840,7 +840,8 @@ list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include- ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/rotate-empty-bbox.scad) list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES}) list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad) diff --git a/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png b/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png new file mode 100644 index 00000000..f3fa75fb Binary files /dev/null and b/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png differ diff --git a/tests/regression/opencsgtest/rotate-empty-bbox-expected.png b/tests/regression/opencsgtest/rotate-empty-bbox-expected.png new file mode 100644 index 00000000..182a8795 Binary files /dev/null and b/tests/regression/opencsgtest/rotate-empty-bbox-expected.png differ diff --git a/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png b/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png new file mode 100644 index 00000000..4408dc19 Binary files /dev/null and b/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png differ