Fix perpendicular constraint behavior

This commit is contained in:
ramox81 committed 2026-09-17 10:48:44 +03:00
1 parent a27545c379
commit cbf1e76c69
8 files changed
+216 -16

No files matched your search

+80 -1
View File
@@ -161,6 +161,80 @@ impl Scene {
.filter(|&h| !self.is_layer_locked(h))
.collect();
let handles = &handles[..];
let retained_originals: Vec<(Handle, EntityType)> = handles
.iter()
.filter_map(|handle| {
self.document
.get_entity(*handle)
.cloned()
.map(|entity| (*handle, entity))
})
.collect();
let transformed_refs: Vec<_> = handles
.iter()
.copied()
.map(parametric_constraints::ParametricRef::whole)
.collect();
let mut driven_refs = Vec::new();
if !matches!(t, EntityTransform::Translate(_)) {
for set in &self.parametric_constraints {
for constraint in &set.constraints {
if !constraint.enabled
|| !matches!(
constraint.kind,
parametric_constraints::ConstraintKind::Parallel
| parametric_constraints::ConstraintKind::Perpendicular
| parametric_constraints::ConstraintKind::Colinear
)
{
continue;
}
let selected_refs = constraint
.refs
.iter()
.filter(|reference| handles.contains(&reference.entity))
.count();
if selected_refs == 0 || selected_refs == constraint.refs.len() {
continue;
}
for reference in constraint
.refs
.iter()
.copied()
.filter(|reference| !handles.contains(&reference.entity))
{
let anchor = if let Some(index) = reference.segment_index() {
parametric_constraints::ParametricRef::point(
reference.entity,
index as i32,
)
} else if reference.directional_axis().is_some()
&& matches!(
self.document.get_entity(reference.entity),
Some(EntityType::Ellipse(_))
)
{
parametric_constraints::ParametricRef::center(reference.entity)
} else {
parametric_constraints::ParametricRef::point(reference.entity, 0)
};
let follows_selected_point = set.constraints.iter().any(|link| {
link.enabled
&& link.kind
== parametric_constraints::ConstraintKind::Coincident
&& link.refs.contains(&anchor)
&& link
.refs
.iter()
.any(|item| handles.contains(&item.entity))
});
if !follows_selected_point && !driven_refs.contains(&anchor) {
driven_refs.push(anchor);
}
}
}
}
}
// Preserve readable text orientation when MIRRTEXT is disabled.
let preserve_text_orientation =
matches!(t, EntityTransform::Mirror { .. }) && !self.document.header.mirror_text;
@@ -290,7 +364,12 @@ impl Scene {
// per-handle, keeping the block cache + all other memoized wires.
let changes: Vec<(Handle, ChangeKind)> =
handles.iter().map(|&h| (h, ChangeKind::Modified)).collect();
self.bump_entities(&changes);
self.bump_entities_with_parametric_transform_policy(
&changes,
&driven_refs,
&transformed_refs,
&retained_originals,
);
self.refresh_meshes_for_handles(&refresh_solid_handles);
}