forked from StudioInfinity/dyna3
refactor: Code formatting (#108)
Primarily, switch to using trailing commas. Also uniformizes commas with respect to switch branches, makes function call layout more consistent, line breaking more consistent, alphabetizes imports, uses the field init shorthand when possible, etc. Resolves #99. Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo> Reviewed-on: StudioInfinity/dyna3#108 Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net> Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
This commit is contained in:
parent
2eba80fb69
commit
ef1a579ac0
12 changed files with 310 additions and 297 deletions
|
@ -1,13 +1,13 @@
|
|||
use nalgebra::{DMatrix, DVector, DVectorView};
|
||||
use std::{
|
||||
cell::Cell,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
cmp::Ordering,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
fmt,
|
||||
fmt::{Debug, Formatter},
|
||||
hash::{Hash, Hasher},
|
||||
rc::Rc,
|
||||
sync::{atomic, atomic::AtomicU64}
|
||||
sync::{atomic, atomic::AtomicU64},
|
||||
};
|
||||
use sycamore::prelude::*;
|
||||
use web_sys::{console, wasm_bindgen::JsValue}; /* DEBUG */
|
||||
|
@ -26,9 +26,9 @@ use crate::{
|
|||
ConfigSubspace,
|
||||
ConstraintProblem,
|
||||
DescentHistory,
|
||||
Realization
|
||||
Realization,
|
||||
},
|
||||
specified::SpecifiedValue
|
||||
specified::SpecifiedValue,
|
||||
};
|
||||
|
||||
pub type ElementColor = [f32; 3];
|
||||
|
@ -164,7 +164,7 @@ pub struct Sphere {
|
|||
pub ghost: Signal<bool>,
|
||||
pub regulators: Signal<BTreeSet<Rc<dyn Regulator>>>,
|
||||
serial: u64,
|
||||
column_index: Cell<Option<usize>>
|
||||
column_index: Cell<Option<usize>>,
|
||||
}
|
||||
|
||||
impl Sphere {
|
||||
|
@ -174,17 +174,17 @@ impl Sphere {
|
|||
id: String,
|
||||
label: String,
|
||||
color: ElementColor,
|
||||
representation: DVector<f64>
|
||||
representation: DVector<f64>,
|
||||
) -> Sphere {
|
||||
Sphere {
|
||||
id: id,
|
||||
label: label,
|
||||
color: color,
|
||||
id,
|
||||
label,
|
||||
color,
|
||||
representation: create_signal(representation),
|
||||
ghost: create_signal(false),
|
||||
regulators: create_signal(BTreeSet::new()),
|
||||
serial: Self::next_serial(),
|
||||
column_index: None.into()
|
||||
column_index: None.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ impl Element for Sphere {
|
|||
id,
|
||||
format!("Sphere {id_num}"),
|
||||
[0.75_f32, 0.75_f32, 0.75_f32],
|
||||
sphere(0.0, 0.0, 0.0, 1.0)
|
||||
sphere(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ pub struct Point {
|
|||
pub ghost: Signal<bool>,
|
||||
pub regulators: Signal<BTreeSet<Rc<dyn Regulator>>>,
|
||||
serial: u64,
|
||||
column_index: Cell<Option<usize>>
|
||||
column_index: Cell<Option<usize>>,
|
||||
}
|
||||
|
||||
impl Point {
|
||||
|
@ -274,7 +274,7 @@ impl Point {
|
|||
id: String,
|
||||
label: String,
|
||||
color: ElementColor,
|
||||
representation: DVector<f64>
|
||||
representation: DVector<f64>,
|
||||
) -> Point {
|
||||
Point {
|
||||
id,
|
||||
|
@ -284,7 +284,7 @@ impl Point {
|
|||
ghost: create_signal(false),
|
||||
regulators: create_signal(BTreeSet::new()),
|
||||
serial: Self::next_serial(),
|
||||
column_index: None.into()
|
||||
column_index: None.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ impl Element for Point {
|
|||
id,
|
||||
format!("Point {id_num}"),
|
||||
[0.75_f32, 0.75_f32, 0.75_f32],
|
||||
point(0.0, 0.0, 0.0)
|
||||
point(0.0, 0.0, 0.0),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ pub struct InversiveDistanceRegulator {
|
|||
pub subjects: [Rc<dyn Element>; 2],
|
||||
pub measurement: ReadSignal<f64>,
|
||||
pub set_point: Signal<SpecifiedValue>,
|
||||
serial: u64
|
||||
serial: u64,
|
||||
}
|
||||
|
||||
impl InversiveDistanceRegulator {
|
||||
|
@ -449,7 +449,7 @@ pub struct HalfCurvatureRegulator {
|
|||
pub subject: Rc<dyn Element>,
|
||||
pub measurement: ReadSignal<f64>,
|
||||
pub set_point: Signal<SpecifiedValue>,
|
||||
serial: u64
|
||||
serial: u64,
|
||||
}
|
||||
|
||||
impl HalfCurvatureRegulator {
|
||||
|
@ -501,7 +501,7 @@ impl ProblemPoser for HalfCurvatureRegulator {
|
|||
// the velocity is expressed in uniform coordinates
|
||||
pub struct ElementMotion<'a> {
|
||||
pub element: Rc<dyn Element>,
|
||||
pub velocity: DVectorView<'a, f64>
|
||||
pub velocity: DVectorView<'a, f64>,
|
||||
}
|
||||
|
||||
type AssemblyMotion<'a> = Vec<ElementMotion<'a>>;
|
||||
|
@ -533,7 +533,7 @@ pub struct Assembly {
|
|||
|
||||
// realization diagnostics
|
||||
pub realization_status: Signal<Result<(), String>>,
|
||||
pub descent_history: Signal<DescentHistory>
|
||||
pub descent_history: Signal<DescentHistory>,
|
||||
}
|
||||
|
||||
impl Assembly {
|
||||
|
@ -546,7 +546,7 @@ impl Assembly {
|
|||
elements_by_id: create_signal(BTreeMap::default()),
|
||||
realization_trigger: create_signal(()),
|
||||
realization_status: create_signal(Ok(())),
|
||||
descent_history: create_signal(DescentHistory::new())
|
||||
descent_history: create_signal(DescentHistory::new()),
|
||||
};
|
||||
|
||||
// realize the assembly whenever the element list, the regulator list,
|
||||
|
@ -724,7 +724,7 @@ impl Assembly {
|
|||
// `Err(message)` we received from the match: we're changing the
|
||||
// `Ok` type from `Realization` to `()`
|
||||
self.realization_status.set(Err(message))
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ impl Assembly {
|
|||
},
|
||||
None => {
|
||||
console_log!("No velocity to unpack for fresh element \"{}\"", elt.id())
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ mod tests {
|
|||
String::from(sphere_id),
|
||||
String::from("Sphere 0"),
|
||||
[0.75_f32, 0.75_f32, 0.75_f32],
|
||||
engine::sphere(0.0, 0.0, 0.0, INITIAL_RADIUS)
|
||||
engine::sphere(0.0, 0.0, 0.0, INITIAL_RADIUS),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -881,7 +881,7 @@ mod tests {
|
|||
vec![
|
||||
ElementMotion {
|
||||
element: sphere.clone(),
|
||||
velocity: velocity.as_view()
|
||||
velocity: velocity.as_view(),
|
||||
}
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue