Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checks from append_subpath #2190

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions node-graph/gcore/src/vector/vector_data/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ impl PointDomain {
}

pub fn push(&mut self, id: PointId, position: DVec2) {
if self.id.contains(&id) {
warn!("Duplicate point");
return;
}
debug_assert!(!self.id.contains(&id));
self.id.push(id);
self.positions.push(position);
}
Expand Down Expand Up @@ -291,22 +288,13 @@ impl SegmentDomain {
}

pub(crate) fn push(&mut self, id: SegmentId, start: usize, end: usize, handles: bezier_rs::BezierHandles, stroke: StrokeId) {
if self.ids.contains(&id) {
return;
}
// Attempt to keep line joins?
let after = self.end_point.iter().copied().position(|other_end| other_end == start);
let before = self.start_point.iter().copied().position(|other_start| other_start == end);
let index = match (before, after) {
(_, Some(after)) => after + 1,
(Some(before), _) => before,
(None, None) => self.ids.len(),
};
self.ids.insert(index, id);
self.start_point.insert(index, start);
self.end_point.insert(index, end);
self.handles.insert(index, handles);
self.stroke.insert(index, stroke);
debug_assert!(!self.ids.contains(&id), "Tried to push an existing point to a point domain");

self.ids.push(id);
self.start_point.push(start);
self.end_point.push(end);
self.handles.push(handles);
self.stroke.push(stroke);
}

pub(crate) fn start_point_mut(&mut self) -> impl Iterator<Item = (SegmentId, &mut usize)> {
Expand Down
Loading