From c19e65b962e4d5c52ae777d02cf85e1425cb3a03 Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Mon, 6 Apr 2020 10:38:30 -0400 Subject: [PATCH] Fixed another bug in to_mesh_iter! This was a more minor bug - but a bug that was making it produce non-manifold geometry. --- README.md | 8 ++++---- src/rule.rs | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f048e5f..90a7893 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ## Highest priority: -- Clean up `ramhorn_branch` because it's fugly. Also, fix - non-manifold stuff at higher recursions. +- Clean up `ramhorn_branch` because it's fugly. - See `automata_scratch/examples.py` and implement some of the tougher examples. - `spiral_nested_2` & `spiral_nested_3` (how to compose @@ -15,8 +14,9 @@ - Elegance & succinctness (my recent closure work may help with this): - Why must I repeat myself so much in these definitions? - What patterns can I factor out? I do some things regularly, like: - the clockwise boundaries, the zigzag connections, the iterating over - a `Vec` to transform each element and make another vector. + the clockwise boundaries, the zigzag connections + - Procedural macro to shorten this `Tag::Parent`, `Tag::Body` + nonsense - and perhaps force to groups of 3? - Docs on modules - Grep for all TODOs in code, really. - Look at performance. Can I save on copies of geometry by using diff --git a/src/rule.rs b/src/rule.rs index 2764aa4..0dab978 100644 --- a/src/rule.rs +++ b/src/rule.rs @@ -202,10 +202,17 @@ impl Rule { geom = geom.connect(vec![(geom2, child.vmap.clone())]).0; // TODO: Fix clone? - - // and backtrack: - stack.pop(); - n -= 1; + + // If we end recursion on one child, we must end it + // similarly on every sibling (i.e. get its geometry & + // final geometry, and merge it in) - so we increment + // s.next and let the loop re-run. + s.next += 1; + if s.next >= s.rules.len() { + // Backtrack only at the last child: + stack.pop(); + n -= 1; + } continue; } @@ -248,7 +255,7 @@ impl Rule { n += 1; } } - + return (geom, eval_count); }