From e71b0944f63bd7e9bfac98afd4cdeec9fd18eabe Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 24 Nov 2025 16:31:05 -0800 Subject: [PATCH] chore: further reformatting per review --- app-proto/src/assembly.rs | 10 +++--- app-proto/src/components/display.rs | 36 +++++++++---------- app-proto/src/components/outline.rs | 5 ++- .../src/components/test_assembly_chooser.rs | 6 ++-- app-proto/src/engine.rs | 21 ++++++----- 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 2552d04..d13d598 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -587,7 +587,7 @@ impl ProblemPoser for PointCoordinateRegulator { problem.frozen.push( Point::NORM_COMPONENT, col, - point(x,y,z)[Point::NORM_COMPONENT] + point(x,y,z)[Point::NORM_COMPONENT], ); } } @@ -938,7 +938,7 @@ impl Assembly { None => { console_log!( "No velocity to unpack for fresh element \"{}\"", - elt.id() + elt.id(), ) }, }; @@ -973,9 +973,9 @@ mod tests { inversive distance regulator writes problem data")] fn unindexed_subject_test_inversive_distance() { let _ = create_root(|| { - let subjects = [0, 1] - .map(|k| Rc::new(Sphere::default(format!("sphere{k}"), k)) - as Rc); + let subjects = [0, 1].map( + |k| Rc::new(Sphere::default(format!("sphere{k}"), k)) as Rc + ); subjects[0].set_column_index(0); InversiveDistanceRegulator { subjects: subjects, diff --git a/app-proto/src/components/display.rs b/app-proto/src/components/display.rs index 38ae9d0..afe6e56 100644 --- a/app-proto/src/components/display.rs +++ b/app-proto/src/components/display.rs @@ -128,14 +128,10 @@ impl DisplayItem for Sphere { const HIGHLIGHT: f32 = 0.2; let representation = self.representation.get_clone_untracked(); - let color = if selected { - self.color.map(|channel| 0.2 + 0.8*channel) - } else { - self.color - }; - let opacity = if self.ghost.get() { - GHOST_OPACITY - } else { DEFAULT_OPACITY }; + let color = if selected { self.color.map(|channel| 0.2 + 0.8*channel) } + else { self.color }; + let opacity = if self.ghost.get() { GHOST_OPACITY } + else { DEFAULT_OPACITY }; let highlight = if selected { 1.0 } else { HIGHLIGHT }; scene.spheres.push(representation, color, opacity, highlight); } @@ -194,9 +190,8 @@ impl DisplayItem for Point { const HIGHLIGHT: f32 = 0.5; let representation = self.representation.get_clone_untracked(); - let color = if selected { - self.color.map(|channel| 0.2 + 0.8*channel) - } else { self.color }; + let color = if selected { self.color.map(|channel| 0.2 + 0.8*channel) } + else { self.color }; let opacity = if self.ghost.get() { GHOST_OPACITY } else { 1.0 }; let highlight = if selected { 1.0 } else { HIGHLIGHT }; scene.points.push(representation, color, opacity, highlight, selected); @@ -637,7 +632,7 @@ pub fn Display() -> View { !realization_successful && on_init_step || realization_successful && on_last_step; if on_manipulable_step - && state.selection.with(|sel| sel.len() == 1) + && state.selection.with(|sel| sel.len() == 1) { let sel = state.selection.with( |sel| sel.into_iter().next().unwrap().clone() @@ -683,8 +678,8 @@ pub fn Display() -> View { // measure mean frame interval frames_since_last_sample += 1; if frames_since_last_sample >= SAMPLE_PERIOD { - let SP64 = SAMPLE_PERIOD as f64; - mean_frame_interval.set((time - last_sample_time) / SP64); + mean_frame_interval + .set((time - last_sample_time) / SAMPLE_PERIOD as f64); last_sample_time = time; frames_since_last_sample = 0; } @@ -726,9 +721,9 @@ pub fn Display() -> View { // write the spheres in world coordinates let sphere_reps_world: Vec<_> = scene.spheres.representations - .into_iter().map( - |rep| (&asm_to_world * rep).cast::() - ).collect(); + .into_iter() + .map(|rep| (&asm_to_world * rep).cast::()) + .collect(); // set the resolution let width = canvas.width() as f32; @@ -803,7 +798,8 @@ pub fn Display() -> View { &ctx, point_position_attr, SPACE_DIM as i32, point_positions.as_slice(), ); - bind_new_buffer_to_attribute(&ctx, point_color_attr, + bind_new_buffer_to_attribute( + &ctx, point_color_attr, (COLOR_SIZE + 1) as i32, scene.points.colors_with_opacity.concat().as_slice()); bind_new_buffer_to_attribute( @@ -969,9 +965,9 @@ pub fn Display() -> View { .into_iter() .filter(|elt| !elt.ghost().get()); for elt in tangible_elts { - let hit = assembly_to_world.with( + let cast = assembly_to_world.with( |asm_to_world| elt.cast(dir, asm_to_world, pixel_size)); - match hit { + match cast { Some(depth) => match clicked { Some((_, best_depth)) => { if depth < best_depth { diff --git a/app-proto/src/components/outline.rs b/app-proto/src/components/outline.rs index 1f16f01..03272f2 100644 --- a/app-proto/src/components/outline.rs +++ b/app-proto/src/components/outline.rs @@ -63,10 +63,9 @@ fn RegulatorInput(regulator: Rc) -> View { placeholder = measurement.with(|result| result.to_string()), bind:value = value, on:change = move |_| { - let specification - = SpecifiedValue::try_from(value.get_clone_untracked()); + let val = SpecifiedValue::try_from(value.get_clone_untracked()); valid.set( - match specification { + match val { Ok(set_pt) => { set_point.set(set_pt); true diff --git a/app-proto/src/components/test_assembly_chooser.rs b/app-proto/src/components/test_assembly_chooser.rs index a65003e..736a079 100644 --- a/app-proto/src/components/test_assembly_chooser.rs +++ b/app-proto/src/components/test_assembly_chooser.rs @@ -333,7 +333,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) { COLOR_FACE, engine::sphere_with_offset( frac_2_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6, - -frac_1_sqrt_6, 0.0 + -frac_1_sqrt_6, 0.0, ), ), Sphere::new( @@ -342,7 +342,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) { COLOR_FACE, engine::sphere_with_offset( -frac_1_sqrt_6, frac_2_sqrt_6, -frac_1_sqrt_6, - -frac_1_sqrt_6, 0.0 + -frac_1_sqrt_6, 0.0, ), ), Sphere::new( @@ -351,7 +351,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) { COLOR_FACE, engine::sphere_with_offset( -frac_1_sqrt_6, -frac_1_sqrt_6, frac_2_sqrt_6, - -frac_1_sqrt_6, 0.0 + -frac_1_sqrt_6, 0.0, ), ), ]; diff --git a/app-proto/src/engine.rs b/app-proto/src/engine.rs index d2fa3eb..5defa31 100644 --- a/app-proto/src/engine.rs +++ b/app-proto/src/engine.rs @@ -9,8 +9,8 @@ pub fn point(x: f64, y: f64, z: f64) -> DVector { } // the sphere with the given center and radius, with inward-pointing normals -pub fn sphere(center_x: f64, center_y: f64, center_z: f64, radius: f64) --> DVector { +pub fn sphere(center_x: f64, center_y: f64, center_z: f64, radius: f64 +) -> DVector { let center_norm_sq = center_x * center_x + center_y * center_y + center_z * center_z; DVector::from_column_slice(&[ @@ -202,8 +202,8 @@ impl ConfigSubspace { // with the given column index has velocity `v`. the velocity is given in // projection coordinates, and the projection is done with respect to the // projection inner product - pub fn proj(&self, v: &DVectorView, column_index: usize) - -> DMatrix { + pub fn proj(&self, v: &DVectorView, column_index: usize + ) -> DMatrix { if self.dim() == 0 { const ELEMENT_DIM: usize = 5; DMatrix::zeros(ELEMENT_DIM, self.assembly_dim) @@ -294,9 +294,8 @@ impl SearchState { } } -fn basis_matrix(index: (usize, usize), nrows: usize, ncols: usize) - -> DMatrix -{ +fn basis_matrix(index: (usize, usize), nrows: usize, ncols: usize +) -> DMatrix { let mut result = DMatrix::::zeros(nrows, ncols); result[index] = 1.0; result @@ -624,7 +623,7 @@ pub mod examples { problem.gram.push_sym( block + j, block + k, - if j == k { 0.0 } else { -0.5 } + if j == k { 0.0 } else { -0.5 }, ); } @@ -721,7 +720,7 @@ mod tests { for k in j..2 { problem.gram.push_sym( j, k, - if (j, k) == (1, 1) { 1.0 } else { 0.0 } + if (j, k) == (1, 1) { 1.0 } else { 0.0 }, ); } } @@ -829,8 +828,8 @@ mod tests { } } - fn translation_motion_unif(vel: &Vector3, assembly_dim: usize) - -> Vec> { + fn translation_motion_unif(vel: &Vector3, assembly_dim: usize + ) -> Vec> { let mut elt_motion = DVector::zeros(4); elt_motion.fixed_rows_mut::<3>(0).copy_from(vel); iter::repeat(elt_motion).take(assembly_dim).collect()