Make the Path tool's segment drag molding work with linear segments (#2838)
Some checks are pending
Editor: Dev & CI / build (push) Waiting to run
Editor: Dev & CI / cargo-deny (push) Waiting to run

Fix path tool molding
This commit is contained in:
Adesh Gupta 2025-07-06 16:50:06 +05:30 committed by GitHub
parent 2b380cec3a
commit ce605acf3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,7 +16,7 @@ use crate::messages::tool::common_functionality::shape_editor::{
}; };
use crate::messages::tool::common_functionality::snapping::{SnapCache, SnapCandidatePoint, SnapConstraint, SnapData, SnapManager}; use crate::messages::tool::common_functionality::snapping::{SnapCache, SnapCandidatePoint, SnapConstraint, SnapData, SnapManager};
use crate::messages::tool::common_functionality::utility_functions::{calculate_segment_angle, find_two_param_best_approximate}; use crate::messages::tool::common_functionality::utility_functions::{calculate_segment_angle, find_two_param_best_approximate};
use bezier_rs::{Bezier, TValue}; use bezier_rs::{Bezier, BezierHandles, TValue};
use graphene_std::renderer::Quad; use graphene_std::renderer::Quad;
use graphene_std::vector::{HandleExt, HandleId, NoHashBuilder, SegmentId, VectorData}; use graphene_std::vector::{HandleExt, HandleId, NoHashBuilder, SegmentId, VectorData};
use graphene_std::vector::{ManipulatorPointId, PointId, VectorModificationType}; use graphene_std::vector::{ManipulatorPointId, PointId, VectorModificationType};
@ -674,13 +674,15 @@ impl PathToolData {
responses.add(OverlaysMessage::Draw); responses.add(OverlaysMessage::Draw);
PathToolFsmState::Dragging(self.dragging_state) PathToolFsmState::Dragging(self.dragging_state)
} else { } else {
let handle1 = ManipulatorPointId::PrimaryHandle(segment.segment()); let start_pos = segment.bezier().start;
let handle2 = ManipulatorPointId::EndHandle(segment.segment()); let end_pos = segment.bezier().end;
if let Some(vector_data) = document.network_interface.compute_modified_vector(segment.layer()) {
if let (Some(pos1), Some(pos2)) = (handle1.get_position(&vector_data), handle2.get_position(&vector_data)) { let [pos1, pos2] = match segment.bezier().handles {
self.molding_info = Some((pos1, pos2)) BezierHandles::Cubic { handle_start, handle_end } => [handle_start, handle_end],
} BezierHandles::Quadratic { handle } => [handle, end_pos],
} BezierHandles::Linear => [start_pos + (end_pos - start_pos) / 3., end_pos + (start_pos - end_pos) / 3.],
};
self.molding_info = Some((pos1, pos2));
PathToolFsmState::Dragging(self.dragging_state) PathToolFsmState::Dragging(self.dragging_state)
} }
} }