mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Sort atoms by plane, then layer
This commit is contained in:
parent
d2770a035c
commit
4f9bab6a43
2 changed files with 18 additions and 1 deletions
|
|
@ -112,7 +112,13 @@ impl MapRenderer {
|
|||
let midpoint = ::std::time::Instant::now();
|
||||
|
||||
// z sort - TODO: use depth buffer instead?
|
||||
atoms.sort_by_key(|a| minimap::layer_of(objtree, a));
|
||||
|
||||
atoms.sort_by(|a, b| {
|
||||
match minimap::plane_of(objtree, a).cmp(&minimap::plane_of(objtree, b)) {
|
||||
::std::cmp::Ordering::Equal => minimap::layer_of(objtree, a).cmp(&minimap::layer_of(objtree, b)),
|
||||
other => other
|
||||
}
|
||||
});
|
||||
|
||||
// render atoms
|
||||
let mut vertices = Vec::new();
|
||||
|
|
|
|||
|
|
@ -400,6 +400,17 @@ fn fancy_layer_of(objtree: &ObjectTree, atom: &Atom) -> i32 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn plane_of(objtree: &ObjectTree, atom: &Atom) -> i32 {
|
||||
match atom.get_var("plane", objtree) {
|
||||
&Constant::Int(i) => (i % 1000) * 1000,
|
||||
&Constant::Float(f) => ((f % 1000.) * 1000.) as i32,
|
||||
other => {
|
||||
eprintln!("not a plane: {:?} on {:?}", other, atom.type_.path);
|
||||
2_000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layer_of(objtree: &ObjectTree, atom: &Atom) -> i32 {
|
||||
match atom.get_var("layer", objtree) {
|
||||
&Constant::Int(i) => (i % 1000) * 1000,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue