Components are frames (user bug #4)
What a component holds moves with its occurrence, and picks in the world land in the
component's frame:
- Sketches and construction planes show where their component is placed (free move, joint
drive, Capture Position); sketch.inspect reports sketch points in the world.
- frames.rs maps a command's world picks into the frame of the body they lie on (through the
inverse of its placement: a moved component or a pasted instance), points that make new
geometry into the active component's frame, and directions with them; instance body names
("Body1 (Pin:2)") become the component's body. Fillet/chamfer edges, shell/offset/draft
faces, face extrude/revolve, sketch on face, holes, sheet metal and plastic picks, primitives,
appearance faces, analyses. Once per command (not again for commands run by commands); the
active-frame fallback stays for commands without a table. Nothing changes while every
placement is the identity.
- component.move_bodies keeps a body where it is in the world (Document.body_offsets: from the
new component's frame to the one it was made in; renames and deleted components follow).
- The UI reads the placed model (Session::world_state) for display, picking, sketch editing and
dialogs; live previews use it once anything is placed.
Tests (engine): sketches and construction planes move (and turn) with the component; world
picks fillet, sketch, hole and make boxes in a moved component; a pick on a pasted instance;
move_bodies keeps the world place there and back; a sketch on a face follows a Move feature.
QA's s34 now runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
c0725ebc86
commit
7a2eb059c4
30 files changed
+669
-72
No files matched your search
@@ -32,7 +32,7 @@ const ARROW: f32 = 60.0;
|
||||
|
||||
/// Is the sketch being edited a 3D sketch?
|
||||
pub fn active(app: &SolveApp) -> bool {
|
||||
let st = app.session.model.state();
|
||||
let st = app.session.world_state();
|
||||
app.session.active_sketch.and_then(|s| st.sketch(s)).is_some_and(|ss| ss.sketch.view.three_d)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ fn takes(cmd: &str) -> bool {
|
||||
|
||||
/// Points drawn in 3D: (wire id, fit index, point).
|
||||
fn drawn_points(app: &SolveApp) -> Vec<(String, usize, Vec3)> {
|
||||
let st = app.session.model.state();
|
||||
let st = app.session.world_state();
|
||||
let Some(ss) = app.session.active_sketch.and_then(|s| st.sketch(s)) else { return Vec::new() };
|
||||
ss.sketch.wires.iter().flat_map(|w| w.fit.iter().enumerate().map(|(i, p)| (w.id.clone(), i, *p))).collect()
|
||||
}
|
||||
@@ -66,7 +66,7 @@ pub fn point_at(app: &SolveApp, proj: &Proj, pos: Pos2) -> Option<(Vec3, &'stati
|
||||
return Some((p, "Pt"));
|
||||
}
|
||||
}
|
||||
let st = app.session.model.state();
|
||||
let st = app.session.world_state();
|
||||
let ss = app.session.active_sketch.and_then(|s| st.sketch(s))?;
|
||||
let (o, d) = proj.ray(pos);
|
||||
for h in pick(app, proj, pos) {
|
||||
@@ -92,7 +92,7 @@ pub fn point_at(app: &SolveApp, proj: &Proj, pos: Pos2) -> Option<(Vec3, &'stati
|
||||
|
||||
/// The sketch-plane coordinates of `p` when it lies on the plane.
|
||||
fn on_plane(app: &SolveApp, p: Vec3) -> Option<Vec2> {
|
||||
let st = app.session.model.state();
|
||||
let st = app.session.world_state();
|
||||
let ss = app.session.active_sketch.and_then(|s| st.sketch(s))?;
|
||||
let q = ss.plane.to_local(p);
|
||||
(ss.plane.to_world(q).dist(p) < 1e-6).then_some(q)
|
||||
@@ -305,7 +305,7 @@ fn target(app: &SolveApp, proj: &Proj, pos: Pos2, axis: Option<Vec3>, p: Vec3) -
|
||||
Some(p + u * ((b * d.dot(w0) - c * u.dot(w0)) / den))
|
||||
}
|
||||
None => {
|
||||
let st = app.session.model.state();
|
||||
let st = app.session.world_state();
|
||||
let n = app.session.active_sketch.and_then(|s| st.sketch(s))?.plane.normal();
|
||||
let den = d.dot(n);
|
||||
(den.abs() > 1e-12).then(|| o + d * ((p - o).dot(n) / den))
|
||||
|
||||
Reference in new issue
Block a user