Mesh connection bug fixed! Just need to say why...
This commit is contained in:
parent
313aa6203f
commit
2fe37fc569
@ -99,7 +99,7 @@ impl OpenMesh {
|
|||||||
/// Treat this mesh as a 'parent' mesh to connect with any number
|
/// Treat this mesh as a 'parent' mesh to connect with any number
|
||||||
/// of 'child' meshes, all of them paired with their respective
|
/// of 'child' meshes, all of them paired with their respective
|
||||||
/// parent vertex mappings. This returns a new mesh.
|
/// parent vertex mappings. This returns a new mesh.
|
||||||
pub fn connect(&self, children: &Vec<(OpenMesh, &Vec<usize>)>) -> OpenMesh {
|
pub fn connect(&self, children: &Vec<(OpenMesh, &Vec<usize>)>) -> (OpenMesh, Vec<usize>) {
|
||||||
// TODO: Clean up this description a bit
|
// TODO: Clean up this description a bit
|
||||||
// TODO: Clean up Vec<usize> stuff
|
// TODO: Clean up Vec<usize> stuff
|
||||||
|
|
||||||
@ -107,6 +107,8 @@ impl OpenMesh {
|
|||||||
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();
|
||||||
|
|
||||||
|
let mut offsets: Vec<usize> = vec![];
|
||||||
|
|
||||||
for (child,mapping) in children {
|
for (child,mapping) in children {
|
||||||
|
|
||||||
// body_offset corresponds to the position in 'verts' at
|
// body_offset corresponds to the position in 'verts' at
|
||||||
@ -127,11 +129,14 @@ impl OpenMesh {
|
|||||||
Tag::Parent(n) => Tag::Body(mapping[*n]),
|
Tag::Parent(n) => Tag::Body(mapping[*n]),
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
offsets.push(body_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenMesh {
|
let m = OpenMesh {
|
||||||
verts: verts,
|
verts: verts,
|
||||||
faces: faces,
|
faces: faces,
|
||||||
}
|
};
|
||||||
|
(m, offsets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/rule.rs
17
src/rule.rs
@ -114,7 +114,7 @@ impl<A> Rule<A> {
|
|||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// Connect geometry from this rule (not child rules):
|
// Connect geometry from this rule (not child rules):
|
||||||
return (rs.geom.connect(&subgeom), evals);
|
return (rs.geom.connect(&subgeom).0, evals);
|
||||||
}
|
}
|
||||||
Rule::EmptyRule => {
|
Rule::EmptyRule => {
|
||||||
return (prim::empty_mesh(), evals);
|
return (prim::empty_mesh(), evals);
|
||||||
@ -193,15 +193,22 @@ impl<A> Rule<A> {
|
|||||||
match child.rule {
|
match child.rule {
|
||||||
Rule::Recurse(f) => {
|
Rule::Recurse(f) => {
|
||||||
// Evaluate the rule:
|
// Evaluate the rule:
|
||||||
let eval = f(arg);
|
let mut eval = f(arg);
|
||||||
|
|
||||||
// Compose child transform to new world transform:
|
// Compose child transform to new world transform:
|
||||||
let xf = s.xf * child.xf; // TODO: Check order on this
|
let xf = s.xf * child.xf; // TODO: Check order on this
|
||||||
|
|
||||||
let new_geom = eval.geom.transform(&xf);
|
let new_geom = eval.geom.transform(&xf);
|
||||||
println!("DEBUG: Connecting {} faces, faces={:?}",
|
println!("DEBUG: Connecting {} faces, vmap={:?}, faces={:?}",
|
||||||
new_geom.verts.len(), new_geom.faces);
|
new_geom.verts.len(), child.vmap, new_geom.faces);
|
||||||
geom = geom.connect(&vec![(new_geom, &child.vmap)]);
|
let (g, offsets) = geom.connect(&vec![(new_geom, &child.vmap)]);
|
||||||
|
geom = g;
|
||||||
|
|
||||||
|
// Adjust vmap in all of eval.children:
|
||||||
|
for (i,offset) in offsets.iter().enumerate() {
|
||||||
|
eval.children[i].vmap = eval.children[i].vmap.iter().map(|n| n + offset).collect();
|
||||||
|
}
|
||||||
|
// TODO: Explain this better
|
||||||
|
|
||||||
// Recurse further (i.e. put more onto stack):
|
// Recurse further (i.e. put more onto stack):
|
||||||
let s2 = State {
|
let s2 = State {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user