Solve (sort of) non-manifold issue in curve_horn stuff
This commit is contained in:
parent
f4f6a7db5d
commit
e3e7391cea
@ -2,13 +2,10 @@
|
|||||||
|
|
||||||
## Highest priority:
|
## Highest priority:
|
||||||
|
|
||||||
- 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?
|
||||||
-
|
|
||||||
|
|
||||||
## Important:
|
## Important but less critical:
|
||||||
|
|
||||||
- Grep for all TODOs in code, really.
|
- Grep for all TODOs in code, really.
|
||||||
- Look at everything in README.md in automata_scratch.
|
- Look at everything in README.md in automata_scratch.
|
||||||
@ -19,6 +16,8 @@
|
|||||||
|
|
||||||
## If I'm bored:
|
## If I'm bored:
|
||||||
|
|
||||||
|
- See `curve_horn_start` comments; can I elegantly solve this issue of
|
||||||
|
how to connect an exit vertex multiple places?
|
||||||
- Fix links in tri_mesh docs that use relative paths & do a PR?
|
- Fix links in tri_mesh docs that use relative paths & do a PR?
|
||||||
- Look in https://www.nalgebra.org/quick_reference/# for "pour
|
- Look in https://www.nalgebra.org/quick_reference/# for "pour
|
||||||
obtain". Can I fix this somehow? Looks like a French-ism that made
|
obtain". Can I fix this somehow? Looks like a French-ism that made
|
||||||
|
|||||||
94
src/main.rs
94
src/main.rs
@ -86,10 +86,6 @@ impl OpenMesh {
|
|||||||
|
|
||||||
fn connect(&self, others: &Vec<OpenMesh>) -> OpenMesh {
|
fn connect(&self, others: &Vec<OpenMesh>) -> OpenMesh {
|
||||||
|
|
||||||
//println!("DEBUG: connect(), self has {} exit groups, others have {:?}",
|
|
||||||
// self.exit_groups.len(), others.iter().map(|o| o.exit_groups.len()).collect::<Vec<usize>>());
|
|
||||||
//println!("DEBUG: connect(), self: verts.len()={} faces.len()={} max face={}", self.verts.len(), self.faces.len(), self.faces.iter().map(|f| match f { Tag::Body(n) => n, Tag::Exit(_,n) => n }).max().unwrap());
|
|
||||||
|
|
||||||
// Copy body vertices & faces:
|
// Copy body vertices & faces:
|
||||||
let mut verts: Vec<Vertex> = self.verts.clone();
|
let mut verts: Vec<Vertex> = self.verts.clone();
|
||||||
let mut faces = self.faces.clone();
|
let mut faces = self.faces.clone();
|
||||||
@ -101,11 +97,6 @@ impl OpenMesh {
|
|||||||
let mut offsets: Vec<usize> = vec![0; others.len()];
|
let mut offsets: Vec<usize> = vec![0; others.len()];
|
||||||
for (i,other) in others.iter().enumerate() {
|
for (i,other) in others.iter().enumerate() {
|
||||||
|
|
||||||
//let max_ = other.faces.iter().map(|f| match f { Tag::Body(n) => n, Tag::Exit(_,n) => n }).max().unwrap_or(&0);
|
|
||||||
//println!("DEBUG: connect(), other[{}]: verts.len()={} faces.len()={} max face={}", i, other.verts.len(), other.faces.len(), max_);
|
|
||||||
//println!("DEBUG: start body_offset={}", body_offset);
|
|
||||||
//println!("DEBUG: start exit_offset={}", exit_offset);
|
|
||||||
|
|
||||||
// Append body vertices & exit vertices directly:
|
// Append body vertices & exit vertices directly:
|
||||||
verts.append(&mut other.verts.clone());
|
verts.append(&mut other.verts.clone());
|
||||||
|
|
||||||
@ -124,17 +115,11 @@ impl OpenMesh {
|
|||||||
offsets[i] = body_offset;
|
offsets[i] = body_offset;
|
||||||
// Increase offsets by the number of elements we appended:
|
// Increase offsets by the number of elements we appended:
|
||||||
body_offset += other.verts.len();
|
body_offset += other.verts.len();
|
||||||
|
|
||||||
//println!("DEBUG: end body_offset={}", body_offset);
|
|
||||||
//println!("DEBUG: end exit_offset={}", exit_offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//println!("DEBUG: offsets={:?}", offsets);
|
|
||||||
|
|
||||||
// All of the Exit face indices from 'self' need to be
|
// All of the Exit face indices from 'self' need to be
|
||||||
// modified to refer to Body vertices of something in
|
// modified to refer to Body vertices of something in
|
||||||
// 'others':
|
// 'others':
|
||||||
//println!("DEBUG: initial faces={:?}", faces);
|
|
||||||
for i in 0..faces.len() {
|
for i in 0..faces.len() {
|
||||||
match faces[i] {
|
match faces[i] {
|
||||||
Tag::Exit(g, n) => {
|
Tag::Exit(g, n) => {
|
||||||
@ -143,18 +128,12 @@ impl OpenMesh {
|
|||||||
_ => { },
|
_ => { },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//println!("DEBUG: final faces={:?}", faces);
|
|
||||||
|
|
||||||
let m = OpenMesh {
|
OpenMesh {
|
||||||
verts: verts,
|
verts: verts,
|
||||||
faces: faces,
|
faces: faces,
|
||||||
exit_groups: exit_groups,
|
exit_groups: exit_groups,
|
||||||
};
|
}
|
||||||
|
|
||||||
// TODO: Why is this still ending up with Exit faces despite my loop above?
|
|
||||||
//println!("DEBUG: Returning mesh with verts.len()={} faces.len()={} max face={}", m.verts.len(), m.faces.len(), m.faces.iter().map(|f| match f { Tag::Body(n) => n, Tag::Exit(_,n) => n }).max().unwrap());
|
|
||||||
//println!("Returning: {:?}", m);
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,15 +260,34 @@ fn curve_horn_start() -> RuleStep {
|
|||||||
&nalgebra::Vector3::y_axis(),
|
&nalgebra::Vector3::y_axis(),
|
||||||
std::f32::consts::PI).to_homogeneous();
|
std::f32::consts::PI).to_homogeneous();
|
||||||
RuleStep {
|
RuleStep {
|
||||||
geom: empty_mesh(),
|
geom: OpenMesh {
|
||||||
|
verts: vec![],
|
||||||
|
faces: vec![
|
||||||
|
Tag::Exit(1, 0), Tag::Exit(1, 2), Tag::Exit(0, 1),
|
||||||
|
Tag::Exit(1, 2), Tag::Exit(0, 3), Tag::Exit(0, 1),
|
||||||
|
Tag::Exit(0, 0), Tag::Exit(0, 2), Tag::Exit(1, 1),
|
||||||
|
Tag::Exit(0, 2), Tag::Exit(1, 3), Tag::Exit(1, 1),
|
||||||
|
Tag::Exit(0, 3), Tag::Exit(1, 2), Tag::Exit(0, 2),
|
||||||
|
Tag::Exit(1, 2), Tag::Exit(1, 3), Tag::Exit(0, 2),
|
||||||
|
Tag::Exit(1, 0), Tag::Exit(0, 1), Tag::Exit(0, 0),
|
||||||
|
Tag::Exit(1, 1), Tag::Exit(1, 0), Tag::Exit(0, 0),
|
||||||
|
// The above is connecting group 0 to group 1,
|
||||||
|
// straight across + with diagonal - but with group 1
|
||||||
|
// being flipped 180, so we remap vertices (0,1,2,3)
|
||||||
|
// to (1,0,3,2) and then flip winding order.
|
||||||
|
],
|
||||||
|
exit_groups: vec![4, 4],
|
||||||
|
},
|
||||||
final_geom: empty_mesh(),
|
final_geom: empty_mesh(),
|
||||||
children: vec![
|
children: vec![
|
||||||
(Rule::Recurse(curve_horn_thing_rule), id),
|
(Rule::Recurse(curve_horn_thing_rule), id), // exit group 0
|
||||||
(Rule::Recurse(curve_horn_thing_rule), flip180),
|
(Rule::Recurse(curve_horn_thing_rule), flip180), // exit group 1
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
// TODO: This has duplicate geometry in the middle because four
|
// TODO: The starting vertices above are duplicated because I
|
||||||
// vertices of each start point never technically connect.
|
// don't have any way for an exit vertex to stand in for multiple
|
||||||
|
// child vertices that happen to share the same location. I don't
|
||||||
|
// yet know a good way around this, so I am duplicating vertices.
|
||||||
}
|
}
|
||||||
|
|
||||||
fn curve_horn_thing_rule() -> RuleStep {
|
fn curve_horn_thing_rule() -> RuleStep {
|
||||||
@ -311,8 +309,10 @@ fn curve_horn_thing_rule() -> RuleStep {
|
|||||||
let geom = OpenMesh {
|
let geom = OpenMesh {
|
||||||
verts: verts,
|
verts: verts,
|
||||||
faces: vec![
|
faces: vec![
|
||||||
// Endcaps purposely left off for now.
|
// The below is just connecting two groups of 4 vertices
|
||||||
// TODO: I should really generate these, not hard-code them.
|
// each, straight across and then to the next. Note that
|
||||||
|
// since 'verts' doesn't go in a circle, it will look a
|
||||||
|
// little strange.
|
||||||
Tag::Body(1), Tag::Exit(0, 3), Tag::Exit(0, 1),
|
Tag::Body(1), Tag::Exit(0, 3), Tag::Exit(0, 1),
|
||||||
Tag::Body(1), Tag::Body(3), Tag::Exit(0, 3),
|
Tag::Body(1), Tag::Body(3), Tag::Exit(0, 3),
|
||||||
Tag::Exit(0, 0), Tag::Body(2), Tag::Body(0),
|
Tag::Exit(0, 0), Tag::Body(2), Tag::Body(0),
|
||||||
@ -321,15 +321,19 @@ fn curve_horn_thing_rule() -> RuleStep {
|
|||||||
Tag::Body(2), Tag::Exit(0, 2), Tag::Exit(0, 3),
|
Tag::Body(2), Tag::Exit(0, 2), Tag::Exit(0, 3),
|
||||||
Tag::Body(0), Tag::Body(1), Tag::Exit(0, 1),
|
Tag::Body(0), Tag::Body(1), Tag::Exit(0, 1),
|
||||||
Tag::Body(0), Tag::Exit(0, 1), Tag::Exit(0, 0),
|
Tag::Body(0), Tag::Exit(0, 1), Tag::Exit(0, 0),
|
||||||
|
// TODO: I should really generate these, not hard-code them.
|
||||||
],
|
],
|
||||||
exit_groups: vec![4],
|
exit_groups: vec![4],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: This could be made slightly nicer by taking it to a peak
|
||||||
|
// instead of just flattening it in XY, but this is a pretty minor
|
||||||
|
// change.
|
||||||
let final_geom = OpenMesh {
|
let final_geom = OpenMesh {
|
||||||
verts: final_verts,
|
verts: final_verts,
|
||||||
faces: vec![
|
faces: vec![
|
||||||
Tag::Body(0), Tag::Body(3), Tag::Body(1),
|
Tag::Body(0), Tag::Body(1), Tag::Body(3),
|
||||||
Tag::Body(0), Tag::Body(2), Tag::Body(3),
|
Tag::Body(0), Tag::Body(3), Tag::Body(2),
|
||||||
],
|
],
|
||||||
exit_groups: vec![],
|
exit_groups: vec![],
|
||||||
};
|
};
|
||||||
@ -338,33 +342,9 @@ fn curve_horn_thing_rule() -> RuleStep {
|
|||||||
geom: geom,
|
geom: geom,
|
||||||
final_geom: final_geom,
|
final_geom: final_geom,
|
||||||
children: vec![
|
children: vec![
|
||||||
(Rule::Recurse(curve_horn_thing_rule), m),
|
(Rule::Recurse(curve_horn_thing_rule), m), // exit group 0
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// We need 3 indices per face, 2 faces per (boundary) vertex:
|
|
||||||
let num_verts = seed.no_vertices();
|
|
||||||
let mut idxs: Vec<u32> = vec![0; 2 * num_verts * 3];
|
|
||||||
for i in 0..num_verts {
|
|
||||||
let a1: u32 = i as _;
|
|
||||||
let a2: u32 = ((i + 1) % num_verts) as _;
|
|
||||||
let b1: u32 = (i + num_verts) as _;
|
|
||||||
let b2: u32 = (((i + 1) % num_verts) + num_verts) as _;
|
|
||||||
// Connect vertices into faces with a zig-zag pattern
|
|
||||||
// (mind the winding order). First face:
|
|
||||||
|
|
||||||
idxs[6*i + 0] = a1;
|
|
||||||
idxs[6*i + 1] = a2;
|
|
||||||
idxs[6*i + 2] = b1;
|
|
||||||
//println!("connect vert {}, face 1: ({}, {}, {}) = {}, {}, {}", i, a1, a2, b1, vert2str(a1), vert2str(a2), vert2str(b1));
|
|
||||||
// Second face:
|
|
||||||
idxs[6*i + 3] = b1;
|
|
||||||
idxs[6*i + 4] = a2;
|
|
||||||
idxs[6*i + 5] = b2;
|
|
||||||
//println!("connect vert {}, face 2: ({}, {}, {}) = {}, {}, {}", i, b1, a2, b2, vert2str(b1), vert2str(a2), vert2str(b2));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cube_thing_rule() -> RuleStep {
|
fn cube_thing_rule() -> RuleStep {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user