diff --git a/src/editor/map_renderer.rs b/src/editor/map_renderer.rs index b8df35e9..6fb220f0 100644 --- a/src/editor/map_renderer.rs +++ b/src/editor/map_renderer.rs @@ -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(); diff --git a/src/tools/minimap.rs b/src/tools/minimap.rs index bd0cfd21..4cd1d261 100644 --- a/src/tools/minimap.rs +++ b/src/tools/minimap.rs @@ -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,