diff --git a/src/csg/parser.cpp b/src/csg/parser.cpp index 53352b41e38f1e215253f1a9ea96df176d7c728b..fca91f2f4bd32ce458a70e66852e73b01c7b40c2 100644 --- a/src/csg/parser.cpp +++ b/src/csg/parser.cpp @@ -412,6 +412,7 @@ template <> struct action> { for (const auto &curr_obj : st.current_2d_group) { mulmat.group.objs.push_back(curr_obj); } + st.current_2d_group.clear(); st.current_2d_objs.back().push_back(mulmat); st.current_matrices.pop_back(); } @@ -435,6 +436,7 @@ template <> struct action> { for (const auto &curr_obj : st.current_3d_group) { mulmat.group.objs.push_back(curr_obj); } + st.current_3d_group.clear(); st.current_3d_objs.back().push_back(mulmat); st.current_matrices.pop_back(); } diff --git a/src/csg/tests/parser/boolean.t.cpp b/src/csg/tests/parser/boolean.t.cpp index 8a563511a876d204aaa477c578d00cf0fea4201b..6b7ff2c029fd18dce1d214a75940fccd66273463 100644 --- a/src/csg/tests/parser/boolean.t.cpp +++ b/src/csg/tests/parser/boolean.t.cpp @@ -119,3 +119,15 @@ multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0.1], [0, 0, 1, 0], [0, 0, 0, 1]]) { CHECK(cone.radius2 == 0.4); CHECK(cone.center == false); } + +TEST_CASE("mulmat and empty group", "[csg]") { + auto st = *csg::parse_csg(R"( +multmatrix([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) { + cylinder($fn = 0, $fa = 12, $fs = 2, h = 200, r1 = 7, r2 = 7, center = false); +} +group(); +)"); + auto un = std::get(st.top.objs.at(1)); + + CHECK(un.objs.size() == 0); +}