mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-05 03:25:58 +00:00
Clippy and rustfmt on the merged tree
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MNXLXkZLQ6T7TSi4wswcmk
This commit is contained in:
@@ -1345,7 +1345,7 @@ fn surface_facing(m: &Mesh, t: &[u32; 3], flat: Vec3) -> Vec3 {
|
||||
let mut sum = Vec3::ZERO;
|
||||
for i in t {
|
||||
match m.normals.get(*i as usize).and_then(|v| v.normalized()) {
|
||||
Some(v) if v.dot(flat) >= AGREES => sum = sum + v,
|
||||
Some(v) if v.dot(flat) >= AGREES => sum += v,
|
||||
_ => return flat,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1961,8 +1961,9 @@ mod tests {
|
||||
assert_eq!((stepped.path.as_deref(), stepped.read_only), (Some(path.as_str()), true));
|
||||
let summary = |s: &Session| -> Vec<(u64, bool, bool)> { s.model.results.iter().map(|r| (r.id, r.skipped, r.error.is_some())).collect() };
|
||||
assert_eq!(summary(&stepped), summary(&whole));
|
||||
let bodies =
|
||||
|s: &Session| -> Vec<(String, usize)> { s.world_state().unwrap().bodies.iter().map(|b| (b.name.clone(), b.mesh().triangles.len())).collect() };
|
||||
let bodies = |s: &Session| -> Vec<(String, usize)> {
|
||||
s.world_state().unwrap().bodies.iter().map(|b| (b.name.clone(), b.mesh().triangles.len())).collect()
|
||||
};
|
||||
assert_eq!(bodies(&stepped), bodies(&whole));
|
||||
assert_eq!(stepped.world_state().unwrap().bodies.len(), 3, "the box, the cylinder and the box before the marker");
|
||||
assert!(stepped.model.is_current(&stepped.doc));
|
||||
|
||||
@@ -2240,7 +2240,7 @@ fn sketch_curve_edge(s: &Session, sel: &Sel) -> Option<Sel> {
|
||||
Sel::ExternalSketchCurve { sketch, id } => (*sketch, id),
|
||||
_ => return None,
|
||||
};
|
||||
let st = crate::open_meshing::session_world(&s);
|
||||
let st = crate::open_meshing::session_world(s);
|
||||
let ss = st.sketch(sketch)?;
|
||||
let segs = ss.sketch.segs(ss.sketch.curve_index(id)?);
|
||||
let (a, b) = (ss.plane.to_world(segs.first()?.start()), ss.plane.to_world(segs.last()?.end()));
|
||||
@@ -2652,7 +2652,7 @@ fn placement_row(d: &mut Dialog, ui: &mut egui::Ui, app: &SolveApp) {
|
||||
/// active a part inside a subassembly picks the subassembly; with the subassembly (or the part)
|
||||
/// active it picks the part. A body outside the active component picks its top-level placement.
|
||||
pub(crate) fn occurrence_path_of_body(s: &Session, body: &str) -> Option<Vec<u64>> {
|
||||
let st = crate::open_meshing::session_world(&s);
|
||||
let st = crate::open_meshing::session_world(s);
|
||||
let b = st.body(body)?;
|
||||
if s.doc.model_body_component(b) == 0 {
|
||||
return None;
|
||||
|
||||
@@ -345,7 +345,7 @@ fn side_pick(app: &SolveApp, o: &JointOrigin) -> Option<Sel> {
|
||||
let at =
|
||||
if o.occurrence == 0 { solidcraft_engine::doc::IDENTITY } else { solidcraft_engine::doc::joints::occurrence_world(&s.doc, o.occurrence) };
|
||||
let p = solidcraft_engine::doc::apply_point(&at, pick);
|
||||
let st = crate::open_meshing::session_world(&s);
|
||||
let st = crate::open_meshing::session_world(s);
|
||||
let own: Vec<&solidcraft_engine::doc::ModelBody> = st.bodies.iter().filter(|b| occurrence_of_body(s, &b.name) == Some(o.occurrence)).collect();
|
||||
let named = match (face, edge) {
|
||||
(Some(name), _) => own.iter().filter_map(|b| named_face(b, name, p)).min_by(|a, b| a.0.total_cmp(&b.0)),
|
||||
|
||||
@@ -165,7 +165,7 @@ fn working(app: &SolveApp) -> bool {
|
||||
/// at `placement`: how many, their triangles and their extent. `None` when the placement is gone.
|
||||
fn snapshot(session: &Session, component: u64, placement: &[u64]) -> Option<(usize, Vec<([f32; 3], [f32; 3])>, Aabb3)> {
|
||||
let frame = session.occurrence_placement(placement).ok().and_then(|p| mat_inverse(&p.world))?;
|
||||
let world = crate::open_meshing::session_world(&session);
|
||||
let world = crate::open_meshing::session_world(session);
|
||||
let (mut bodies, mut triangles, mut bounds) = (0, Vec::new(), Aabb3::default());
|
||||
for b in world.bodies.iter().filter(|b| b.component != component && session.body_visible(&b.name)) {
|
||||
let (mesh, placed) = b.mesh_in_place();
|
||||
|
||||
@@ -315,7 +315,7 @@ pub fn candidate(d: &Dialog, session: &solidcraft_engine::Session, hit: &Hit) ->
|
||||
match hit {
|
||||
Hit::SketchCurve { sketch, .. } | Hit::SketchPoint { sketch, .. } | Hit::Profile { sketch, .. } if *sketch != active => None,
|
||||
Hit::SketchCurve { id, .. } if matches!(d.kind, Kind::SketchModify(Mod::Corner { .. })) => {
|
||||
let state = crate::open_meshing::session_world(&session);
|
||||
let state = crate::open_meshing::session_world(session);
|
||||
let sk = &state.sketch(active)?.sketch;
|
||||
if sk.is_spatial_corner_curve(id) {
|
||||
return None;
|
||||
@@ -726,7 +726,7 @@ fn entity_ids(session: &solidcraft_engine::Session, inputs: &[SelInput], i: usiz
|
||||
Sel::SketchCurve { id, .. } => out.push(id.clone()),
|
||||
Sel::Profile { sketch, index } => {
|
||||
if let Some(ids) =
|
||||
crate::open_meshing::session_world(&session).sketch(*sketch).and_then(|ss| ss.profiles.get(*index)).map(|p| p.curve_ids())
|
||||
crate::open_meshing::session_world(session).sketch(*sketch).and_then(|ss| ss.profiles.get(*index)).map(|p| p.curve_ids())
|
||||
{
|
||||
out.extend(ids);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user