diff --git a/graph.cpp b/graph.cpp index f8b5c902..7a730a7f 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3590,13 +3590,17 @@ bool celldrawer::cell_clipped() { EX ld precise_width = .5; +int grid_depth = 0; + EX void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec) { ld d = hdist(V1*h1, V2*h2); - while(d > precise_width && d < 100) { + while(d > precise_width && d < 100 && grid_depth < 10) { if(!eqmatrix(V1, V2, 1e-6)) { gridline(V1, h1, V1, inverse(V1) * V2 * h2, col, prec); return; } hyperpoint h = midz(h1, h2); + grid_depth++; gridline(V1, h1, V1, h, col, prec); gridline(V1, h, V1, h2, col, prec); + grid_depth--; return; } #if MAXMDIM >= 4