Store elements and regulators without keys

Since we're no longer using storage keys to refer to elements and
regulators, we don't need to store these items in keyed collections
anymore.

To keep element and regulator pointers in `BTreeSet` collections, we
implement `Ord` for `Serial` trait objects. As a bonus, this lets us
turn the element-wise regulator collections back into `BTreeSet`.
This commit is contained in:
Aaron Fenyes 2025-05-04 12:24:17 -07:00
parent 8a86038de0
commit c6b628d424
5 changed files with 74 additions and 50 deletions

View file

@ -363,7 +363,7 @@ pub fn Display() -> View {
let scene_changed = create_signal(true);
create_effect(move || {
state.assembly.elements.with(|elts| {
for (_, elt) in elts {
for elt in elts {
elt.representation().track();
}
});
@ -616,7 +616,7 @@ pub fn Display() -> View {
// set up the scene
state.assembly.elements.with_untracked(
|elts| for (_, elt) in elts {
|elts| for elt in elts {
let selected = state.selection.with(|sel| sel.contains(elt));
elt.show(&mut scene, selected);
}
@ -851,7 +851,7 @@ pub fn Display() -> View {
let (dir, pixel_size) = event_dir(&event);
console::log_1(&JsValue::from(dir.to_string()));
let mut clicked: Option<(Rc<dyn Element>, f64)> = None;
for (_, elt) in state.assembly.elements.get_clone_untracked() {
for elt in state.assembly.elements.get_clone_untracked() {
match assembly_to_world.with(|asm_to_world| elt.cast(dir, asm_to_world, pixel_size)) {
Some(depth) => match clicked {
Some((_, best_depth)) => {