From 4b7739e80dd83d3d3b4180c28bbf35738a5c533e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 19 Jan 2020 11:49:35 +0100 Subject: [PATCH] fixed a freeze when drawing offscreen grid lines --- graph.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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