forked from 1b-agent/opencadstudio-upstream
Keep opposite line endpoint fixed during grip edits
This commit is contained in:
1 parent
08bb17b0b8
commit
07d8d7eb00
3 files changed
+18
-22
No files matched your search
@@ -83,17 +83,17 @@ impl ParametricRef {
|
||||
}
|
||||
}
|
||||
|
||||
/// Point reference driven by a native entity grip. Segment midpoint and
|
||||
/// scalar radius grips deliberately return None because they do not identify
|
||||
/// one stored point parameter.
|
||||
pub(crate) fn driven_ref_for_grip(
|
||||
/// Point reference temporarily pinned while solving a native grip edit.
|
||||
/// A line endpoint anchors its opposite endpoint so the grabbed endpoint is
|
||||
/// projected onto the constraint solution instead of moving the whole line.
|
||||
pub(crate) fn grip_solve_anchor_ref(
|
||||
entity: &acadrust::EntityType,
|
||||
handle: Handle,
|
||||
grip_id: usize,
|
||||
) -> Option<ParametricRef> {
|
||||
match entity {
|
||||
acadrust::EntityType::Line(_) if grip_id <= 1 => {
|
||||
Some(ParametricRef::point(handle, grip_id as i32))
|
||||
Some(ParametricRef::point(handle, 1 - grip_id as i32))
|
||||
}
|
||||
acadrust::EntityType::LwPolyline(polyline) if grip_id < polyline.vertices.len() => {
|
||||
Some(ParametricRef::point(handle, grip_id as i32))
|
||||
@@ -1888,18 +1888,18 @@ mod tests {
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
driven_ref_for_grip(&arc, handle, 0),
|
||||
grip_solve_anchor_ref(&arc, handle, 0),
|
||||
Some(ParametricRef::center(handle))
|
||||
);
|
||||
assert_eq!(
|
||||
driven_ref_for_grip(&arc, handle, 1),
|
||||
grip_solve_anchor_ref(&arc, handle, 1),
|
||||
Some(ParametricRef::point(handle, 0))
|
||||
);
|
||||
assert_eq!(
|
||||
driven_ref_for_grip(&arc, handle, 2),
|
||||
grip_solve_anchor_ref(&arc, handle, 2),
|
||||
Some(ParametricRef::point(handle, 1))
|
||||
);
|
||||
assert_eq!(driven_ref_for_grip(&arc, handle, 3), None);
|
||||
assert_eq!(grip_solve_anchor_ref(&arc, handle, 3), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1942,10 +1942,10 @@ fn solve_scope(
|
||||
sys.add_constraint(Rc::new(Difference::new(el.center.y, el.focus1.y, dy)));
|
||||
}
|
||||
|
||||
// The first ordered Coincident selection is the anchor for this solve.
|
||||
// Pin either its addressed point or every defining parameter of its whole
|
||||
// curve temporarily; the relation remains persistent, while these pins do
|
||||
// not enter the drawing's constraint graph.
|
||||
// Temporarily make each requested anchor a fixed kernel input. Marking the
|
||||
// geometry parameters as driven keeps them exact and out of the solver's
|
||||
// free-variable list; an approximate equality equation would still allow
|
||||
// visible drift after repeated grip frames.
|
||||
for reference in driven_refs {
|
||||
if !set
|
||||
.constraints
|
||||
@@ -1996,9 +1996,7 @@ fn solve_scope(
|
||||
}
|
||||
};
|
||||
for parameter in params_to_pin {
|
||||
let value = sys.store().get(parameter);
|
||||
let target = sys.add_param(value, true);
|
||||
sys.add_constraint(Rc::new(Equal::new(parameter, target, 1.0)));
|
||||
sys.store_mut().set_driven(parameter, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user