Sorta fix curve_horn_start

This commit is contained in:
Chris Hodapp 2020-02-16 18:15:29 -05:00
parent 3eb8d12e03
commit f4f6a7db5d
2 changed files with 17 additions and 43 deletions

View File

@ -2,7 +2,8 @@
## Highest priority: ## Highest priority:
- Continue converting `curve_horn_*`. - Fix issue with `curve_horn_*` that prevents geometry being joined in
middle.
- Consider trampolining `to_mesh`. My call stack seems needlessly - Consider trampolining `to_mesh`. My call stack seems needlessly
deep in spots. Can I make tail-recursive? deep in spots. Can I make tail-recursive?
- -

View File

@ -275,51 +275,23 @@ fn cube() -> OpenMesh {
}.transform(geometry::Translation3::new(-0.5, -0.5, -0.5).to_homogeneous()) }.transform(geometry::Translation3::new(-0.5, -0.5, -0.5).to_homogeneous())
} }
/*
fn curve_horn_start() -> RuleStep { fn curve_horn_start() -> RuleStep {
// Seed is a square in XY, sidelength 1, centered at (0,0,0): let id = nalgebra::geometry::Transform3::identity().to_homogeneous();
let seed = { let flip180 = nalgebra::geometry::Rotation3::from_axis_angle(
let m = OpenMesh {
verts: vec![
vertex(0.0, 0.0, 0.0),
vertex(1.0, 0.0, 0.0),
vertex(1.0, 1.0, 0.0),
vertex(0.0, 1.0, 0.0),
],
faces: vec![
0, 1, 2,
0, 2, 3,
],
idxs_entrance: vec![0],
idxs_exit: vec![0],
idxs_body: (0, 0),
};
let xform = nalgebra::geometry::Translation3::new(-0.5, -0.5, 0.0).to_homogeneous();
m.transform(xform)
};
vec![
// Since neither of the other two rules *start* with geometry:
RuleStep { geom: seed.clone(),
rule: Box::new(Rule::EmptyRule),
xform: nalgebra::geometry::Transform3::identity().to_homogeneous(),
},
// Recurse in both directions:
RuleStep { geom: seed.clone(),
rule: Box::new(Rule::Recurse(curve_horn_thing_rule)),
xform: nalgebra::geometry::Transform3::identity().to_homogeneous(),
},
RuleStep { geom: seed.clone(),
rule: Box::new(Rule::Recurse(curve_horn_thing_rule)),
xform: nalgebra::geometry::Rotation3::from_axis_angle(
&nalgebra::Vector3::y_axis(), &nalgebra::Vector3::y_axis(),
std::f32::consts::FRAC_PI_2).to_homogeneous(), std::f32::consts::PI).to_homogeneous();
}, RuleStep {
] geom: empty_mesh(),
final_geom: empty_mesh(),
children: vec![
(Rule::Recurse(curve_horn_thing_rule), id),
(Rule::Recurse(curve_horn_thing_rule), flip180),
],
}
// TODO: This has duplicate geometry in the middle because four
// vertices of each start point never technically connect.
} }
//use std::convert::TryFrom;
*/
fn curve_horn_thing_rule() -> RuleStep { fn curve_horn_thing_rule() -> RuleStep {
let y = &Vector3::y_axis(); let y = &Vector3::y_axis();
@ -442,4 +414,5 @@ fn main() {
run_test(Rule::Recurse(cube_thing_rule), 3, "cube_thing"); run_test(Rule::Recurse(cube_thing_rule), 3, "cube_thing");
run_test(Rule::Recurse(curve_horn_thing_rule), 100, "curve_horn_thing"); run_test(Rule::Recurse(curve_horn_thing_rule), 100, "curve_horn_thing");
run_test(Rule::Recurse(curve_horn_start), 100, "curve_horn2");
} }