From 8f8bca9c2ff655c4f62d22a5713425bb68194df7 Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Sun, 5 Apr 2020 12:15:29 -0400 Subject: [PATCH] Fix to_mesh_iter bug --- README.md | 4 ++-- src/rule.rs | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8eab82f..9ef6901 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ ## Highest priority: -- `to_mesh_iter` has a bug which `ram_horn_twist` exhibits. The bug - is not present in `to_mesh`. Fix this! - See `automata_scratch/examples.py` and implement some of the tougher examples. - `spiral_nested_2` & `spiral_nested_3` (how to compose @@ -38,6 +36,8 @@ - they're actually static - they implement Copy - the closure can move them +- Use an actual logging framework. +- Migrate tests to... well... actual tests. ## If I'm bored: diff --git a/src/rule.rs b/src/rule.rs index 02d46e6..e1e9236 100644 --- a/src/rule.rs +++ b/src/rule.rs @@ -77,14 +77,6 @@ pub struct Child { impl Rule { - // TODO: Do I want to make 'geom' shared somehow, maybe with Rc? I - // could end up having a lot of identical geometry that need not be - // duplicated until it is transformed into the global space. - // - // This might produce bigger gains if I rewrite to_mesh so that - // rather than repeatedly transforming meshes, it stacks - // transformations and then applies them all at once. - /// Convert this `Rule` to mesh data, recursively (depth first). /// `iters_left` sets the maximum recursion depth. This returns /// (geometry, number of rule evaluations). @@ -229,10 +221,9 @@ impl Rule { // merged 'new_geom' into, not 'new_geom' directly. To // account for this, we must shift vmap by the offset that // 'geom.connect' gave us: - for (offset, child) in offsets.iter().zip(eval.children.iter_mut()) { - child.vmap = child.vmap.iter().map(|n| { - n + offset - }).collect(); + let off = offsets[0]; + for child in eval.children.iter_mut() { + child.vmap = child.vmap.iter().map(|n| n + off).collect(); } // We're done evaluating this rule, so increment 'next'.