Dataset Viewer
Auto-converted to Parquet Duplicate
base_commit
stringlengths
40
40
patch
stringlengths
274
342k
instance_id
stringlengths
13
40
pull_number
int64
14
15.2k
hints_text
stringlengths
0
37.4k
issue_numbers
sequencelengths
1
3
version
stringlengths
3
5
repo
stringlengths
8
35
created_at
stringdate
2016-10-28 09:07:07
2025-01-01 11:25:06
test_patch
stringlengths
308
274k
problem_statement
stringlengths
25
44.3k
environment_setup_commit
stringlengths
40
40
FAIL_TO_PASS
sequencelengths
1
1.1k
PASS_TO_PASS
sequencelengths
0
7.38k
FAIL_TO_FAIL
sequencelengths
0
1.72k
PASS_TO_FAIL
sequencelengths
0
49
updated_at
stringdate
2016-10-29 01:18:22
2025-04-25 03:48:57
1beea8c3df2e44f6fa17b8f21ad57bf5a6e8b620
diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ categories = ["algorithms", "database-implementations"] [dependencies] log = "0.4.1" -protobuf = "1.2" +protobuf = "~1.5" quick-error = "1.2.1" rand = "0.4" fxhash = "0.2.1" diff --git a/src/raft.rs b/src/raft.rs --- a/src/raft.rs +++ b/src/raft.rs @@ -828,6 +828,7 @@ impl<T: Storage> Raft<T> { return; } + // Only send vote request to voters. let prs = self.take_prs(); prs.voters() .keys() diff --git a/src/raft.rs b/src/raft.rs --- a/src/raft.rs +++ b/src/raft.rs @@ -1016,24 +1017,6 @@ impl<T: Storage> Raft<T> { debug!("{} ignoring MsgHup because already leader", self.tag); }, MessageType::MsgRequestVote | MessageType::MsgRequestPreVote => { - if self.is_learner { - // TODO: learner may need to vote, in case of node down when confchange. - info!( - "{} [logterm: {}, index: {}, vote: {}] ignored {:?} from {} \ - [logterm: {}, index: {}] at term {}: learner can not vote", - self.tag, - self.raft_log.last_term(), - self.raft_log.last_index(), - self.vote, - m.get_msg_type(), - m.get_from(), - m.get_log_term(), - m.get_index(), - self.term, - ); - return Ok(()); - } - // We can vote if this is a repeat of a vote we've already cast... let can_vote = (self.vote == m.get_from()) || // ...we haven't voted and we don't think there's a leader yet in this term...
tikv__raft-rs-58
58
PTAL @xiang90 @Hoverbear
[ "57" ]
0.1
tikv/raft-rs
2018-05-09T08:12:10Z
diff --git a/tests/cases/test_raft.rs b/tests/cases/test_raft.rs --- a/tests/cases/test_raft.rs +++ b/tests/cases/test_raft.rs @@ -3784,21 +3784,6 @@ fn test_learner_promotion() { assert_eq!(network.peers[&2].state, StateRole::Leader); } -// TestLearnerCannotVote checks that a learner can't vote even it receives a valid Vote request. -#[test] -fn test_learner_cannot_vote() { - let mut n2 = new_test_learner_raft(2, vec![1], vec![2], 10, 1, new_storage()); - n2.become_follower(1, INVALID_ID); - - let mut msg_vote = new_message(1, 2, MessageType::MsgRequestVote, 0); - msg_vote.set_term(2); - msg_vote.set_log_term(11); - msg_vote.set_index(11); - n2.step(msg_vote).unwrap(); - - assert_eq!(n2.msgs.len(), 0); -} - // TestLearnerLogReplication tests that a learner can receive entries from the leader. #[test] fn test_learner_log_replication() { diff --git a/tests/cases/test_raft.rs b/tests/cases/test_raft.rs --- a/tests/cases/test_raft.rs +++ b/tests/cases/test_raft.rs @@ -3964,3 +3949,31 @@ fn test_remove_learner() { assert!(n1.prs().nodes().is_empty()); assert!(n1.prs().learner_nodes().is_empty()); } + +#[test] +fn test_learner_respond_vote() { + let mut n1 = new_test_learner_raft(1, vec![1, 2], vec![3], 10, 1, new_storage()); + n1.become_follower(1, INVALID_ID); + n1.reset_randomized_election_timeout(); + + let mut n3 = new_test_learner_raft(3, vec![1, 2], vec![3], 10, 1, new_storage()); + n3.become_follower(1, INVALID_ID); + n3.reset_randomized_election_timeout(); + + let do_campaign = |nw: &mut Network| { + let msg = new_message(1, 1, MessageType::MsgHup, 0); + nw.send(vec![msg]); + }; + + let mut network = Network::new(vec![Some(n1), None, Some(n3)]); + network.isolate(2); + + // Can't elect new leader because 1 won't send MsgRequestVote to 3. + do_campaign(&mut network); + assert_eq!(network.peers[&1].state, StateRole::Candidate); + + // After promote 3 to voter, election should success. + network.peers.get_mut(&1).unwrap().add_node(3); + do_campaign(&mut network); + assert_eq!(network.peers[&1].state, StateRole::Leader); +}
Learner should respond to request vote but don't accept votes Consider following case, a cluster has three nodes A, B, C, and A is Leader. And then add learner D, E to the cluster. D, E is promoted to voter then, but D is isolated from A, so D doesn't know himself is promoted. When A, B both crash, the cluster still has three voters C, D, E, which should be able to form a quorum. However, D can't vote in the current implementation, since it doesn't know it's not learner anymore. One solution to this problem is let learner respond to vote request and let candidate check if the response is from a valid peer. Because we won't let a voter step back as learner, so when candidate consider a node is a voter, then it's definitely a voter from that point to infinite future. So the candidate check should be safe. In the situation described above, the quorum can be formed again, and the cluster can recover automatically. /cc @xiang90 @siddontang any thoughts?
1beea8c3df2e44f6fa17b8f21ad57bf5a6e8b620
[ "cases::test_raft::test_learner_respond_vote" ]
[ "errors::tests::test_error_equal", "log_unstable::test::test_maybe_first_index", "log_unstable::test::test_maybe_last_index", "log_unstable::test::test_maybe_term", "errors::tests::test_storage_error_equal", "log_unstable::test::test_restore", "log_unstable::test::test_stable_to", "log_unstable::test::test_truncate_and_append", "progress::test::test_inflight_add", "progress::test::test_inflight_free_first_one", "progress::test::test_inflight_free_to", "raft_log::test::test_append", "raft_log::test::test_commit_to", "raft_log::test::test_has_next_ents", "raft_log::test::test_find_conflict", "raft_log::test::test_compaction_side_effects", "raft_log::test::test_is_outofbounds", "raft_log::test::test_log_restore", "raft_log::test::test_is_up_to_date", "raft_log::test::test_compaction", "raft_log::test::test_log_maybe_append", "raft_log::test::test_next_ents", "raft_log::test::test_slice", "raft_log::test::test_stable_to", "raft_log::test::test_stable_to_with_snap", "raft_log::test::test_term", "raft_log::test::test_term_with_unstable_snapshot", "raft_log::test::test_unstable_ents", "raw_node::test::test_is_local_msg", "storage::test::test_storage_apply_snapshot", "storage::test::test_storage_append", "storage::test::test_storage_compact", "storage::test::test_storage_create_snapshot", "storage::test::test_storage_first_index", "storage::test::test_storage_entries", "storage::test::test_storage_term", "storage::test::test_storage_last_index", "cases::test_raft::test_add_node", "cases::test_raft::test_add_learner", "cases::test_raft::test_add_node_check_quorum", "cases::test_raft::test_all_server_stepdown", "cases::test_raft::test_bcast_beat", "cases::test_raft::test_campaign_while_leader", "cases::test_raft::test_candidate_reset_term_msg_append", "cases::test_raft::test_candidate_reset_term_msg_heartbeat", "cases::test_raft::test_commit_after_remove_node", "cases::test_raft::test_commit_without_new_term_entry", "cases::test_raft::test_cannot_commit_without_new_term_entry", "cases::test_raft::test_commit", "cases::test_raft::test_candidate_concede", "cases::test_raft::test_disruptive_follower", "cases::test_raft::test_handle_heartbeat", "cases::test_raft::test_dueling_pre_candidates", "cases::test_raft::test_disruptive_follower_pre_vote", "cases::test_raft::test_handle_heartbeat_resp", "cases::test_raft::test_free_stuck_candidate_with_check_quorum", "cases::test_raft::test_leader_append_response", "cases::test_raft::test_leader_cycle", "cases::test_raft::test_handle_msg_append", "cases::test_raft::test_leader_cycle_pre_vote", "cases::test_raft::test_dueling_candidates", "cases::test_raft::test_leader_election_overwrite_newer_logs", "cases::test_raft::test_ignore_providing_snapshot", "cases::test_raft::test_leader_stepdown_when_quorum_active", "cases::test_raft::test_leader_increase_next", "cases::test_raft::test_leader_election_overwrite_newer_logs_pre_vote", "cases::test_raft::test_leader_transfer_ignore_proposal", "cases::test_raft::test_leader_transfer_receive_higher_term_vote", "cases::test_raft::test_leader_superseding_with_check_quorum", "cases::test_raft::test_learner_election_timeout", "cases::test_raft::test_leader_election_with_check_quorum", "cases::test_raft::test_leader_transfer_second_transfer_to_another_node", "cases::test_raft::test_progress_become_replicate", "cases::test_raft::test_msg_append_response_wait_reset", "cases::test_raft::test_progress_become_probe", "cases::test_raft::test_node_with_smaller_term_can_complete_election", "cases::test_raft::test_learner_receive_snapshot", "cases::test_raft::test_prevote_from_any_state", "cases::test_raft::test_new_leader_pending_config", "cases::test_raft::test_leader_transfer_to_uptodate_node", "cases::test_raft::test_learner_log_replication", "cases::test_raft::test_leader_transfer_remove_node", "cases::test_raft::test_leader_transfer_back", "cases::test_raft::test_leader_stepdown_when_quorum_lost", "cases::test_raft::test_leader_transfer_to_non_existing_node", "cases::test_raft::test_progress_become_snapshot", "cases::test_raft::test_leader_transfer_after_snapshot", "cases::test_raft::test_pre_campaign_while_leader", "cases::test_raft::test_old_messages", "cases::test_raft::test_leader_transfer_to_uptodate_node_from_follower", "cases::test_raft::test_leader_transfer_timeout", "cases::test_raft::test_progress_resume", "cases::test_raft::test_progress_paused", "cases::test_raft::test_progress_is_paused", "cases::test_raft::test_progress_update", "cases::test_raft::test_raft_nodes", "cases::test_raft::test_progress_maybe_decr", "cases::test_raft::test_remove_learner", "cases::test_raft::test_leader_transfer_to_slow_follower", "cases::test_raft::test_restore_from_snap_msg", "cases::test_raft::test_recv_msg_unreachable", "cases::test_raft::test_restore_learner_promotion", "cases::test_raft::test_leader_transfer_to_self", "cases::test_raft::test_leader_transfer_second_transfer_to_same_node", "cases::test_raft::test_learner_promotion", "cases::test_raft::test_leader_transfer_with_check_quorum", "cases::test_raft::test_remove_node", "cases::test_raft::test_recv_msg_request_vote", "cases::test_raft::test_send_append_for_progress_snapshot", "cases::test_raft::test_raft_frees_read_only_mem", "cases::test_raft::test_read_only_option_lease_without_check_quorum", "cases::test_raft::test_read_only_for_new_leader", "cases::test_raft::test_single_node_candidate", "cases::test_raft::test_progress_resume_by_heartbeat_resp", "cases::test_raft::test_recv_msg_beat", "cases::test_raft::test_sinle_node_pre_candidate", "cases::test_raft::test_step_ignore_config", "cases::test_raft::test_pass_election_timeout", "cases::test_raft::test_promotable", "cases::test_raft::test_provide_snap", "cases::test_raft::test_non_promotable_voter_which_check_quorum", "cases::test_raft::test_read_only_option_lease", "cases::test_raft::test_proposal_by_proxy", "cases::test_raft::test_vote_from_any_state", "cases::test_raft::test_step_config", "cases::test_raft::test_restore", "cases::test_raft::test_restore_ignore_snapshot", "cases::test_raft::test_restore_with_learner", "cases::test_raft::test_read_only_option_safe", "cases::test_raft::test_slow_node_restore", "cases::test_raft::test_send_append_for_progress_replicate", "cases::test_raft_paper::test_follower_update_term_from_message", "cases::test_raft::test_log_replicatioin", "cases::test_raft_paper::test_leader_bcast_beat", "cases::test_raft_paper::test_leader_commit_entry", "cases::test_raft::test_proposal", "cases::test_raft_flow_control::test_msg_app_flow_control_recv_heartbeat", "cases::test_raft::test_step_ignore_old_term_msg", "cases::test_raft_paper::test_follower_append_entries", "cases::test_raft::test_leader_election", "cases::test_raft::test_send_append_for_progress_probe", "cases::test_raft_paper::test_leader_acknowledge_commit", "cases::test_raft::test_leader_election_pre_vote", "cases::test_raft::test_single_node_commit", "cases::test_raft_paper::test_follower_commit_entry", "cases::test_raft::test_transfer_non_member", "cases::test_raft_paper::test_candidate_update_term_from_message", "cases::test_raft_paper::test_follower_start_election", "cases::test_raft_paper::test_follower_vote", "cases::test_raft_paper::test_leader_start_replication", "cases::test_raft_paper::test_leader_only_commits_log_from_current_term", "cases::test_raft::test_restore_invalid_learner", "cases::test_raft_paper::test_candidate_fallback", "cases::test_raft_paper::test_leader_commit_preceding_entries", "cases::test_raft_paper::test_candidate_start_new_election", "cases::test_raft_paper::test_leader_election_in_one_round_rpc", "cases::test_raft_paper::test_follower_check_msg_append", "cases::test_raft_flow_control::test_msg_app_flow_control_full", "cases::test_raft::test_state_transition", "cases::test_raft_paper::test_start_as_follower", "cases::test_raft_paper::test_leader_sync_follower_log", "cases::test_raw_node::test_raw_node_propose_and_conf_change", "cases::test_raft_snap::test_snapshot_abort", "cases::test_raw_node::test_raw_node_propose_add_duplicate_node", "cases::test_raw_node::test_raw_node_step", "cases::test_raw_node::test_skip_bcast_commit", "cases::test_raw_node::test_raw_node_restart_from_snapshot", "cases::test_raw_node::test_raw_node_restart", "cases::test_raw_node::test_raw_node_read_index", "cases::test_raw_node::test_raw_node_start", "cases::test_raft_snap::test_snapshot_failure", "cases::test_raft_paper::test_vote_request", "cases::test_raft_snap::test_snapshot_succeed", "cases::test_raft_paper::test_reject_stale_term_message", "cases::test_raft_paper::test_voter", "cases::test_raft_snap::test_sending_snapshot_set_pending_snapshot", "cases::test_raft_snap::test_pending_snapshot_pause_replication", "cases::test_raft_paper::test_leader_update_term_from_message", "cases::test_raw_node::test_raw_node_propose_add_learner_node", "cases::test_raw_node::test_raw_node_read_index_to_old_leader", "cases::test_raft_flow_control::test_msg_app_flow_control_move_forward", "cases::test_raft_paper::test_follower_election_timeout_nonconflict", "cases::test_raft_paper::test_acandidates_election_timeout_nonconf", "cases::test_raft_paper::test_follower_election_timeout_randomized", "cases::test_raft_paper::test_candidate_election_timeout_randomized", "src/lib.rs - prelude (line 70)" ]
[]
[]
2018-07-05T16:30:24Z
94f4ad731ffae32474ae4362c5f74507a86b564e
diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -140,10 +140,7 @@ impl Path { /// Reversed version of this path with edge loops are specified in the opposite /// order. pub fn reversed(&self) -> Self { - let mut builder = Path::builder(); - reverse_path(self.as_slice(), &mut builder); - - builder.build() + reverse_path(self.as_slice()) } fn apply_transform(&mut self, transform: &Transform2D) { diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -256,6 +253,12 @@ impl<'l> PathSlice<'l> { pub fn is_empty(&self) -> bool { self.verbs.is_empty() } + + /// Returns a slice over an endpoint's custom attributes. + #[inline] + pub fn attributes(&self, endpoint: EndpointId) -> &[f32] { + interpolated_attributes(self.num_attributes, &self.points, endpoint) + } } impl<'l> IntoIterator for PathSlice<'l> { diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -981,6 +984,10 @@ impl<'l> Iterator for IdIter<'l> { #[inline] fn interpolated_attributes(num_attributes: usize, points: &[Point], endpoint: EndpointId) -> &[f32] { + if num_attributes == 0 { + return &[]; + } + let idx = endpoint.0 as usize + 1; assert!(idx + (num_attributes + 1) / 2 <= points.len()); diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -990,8 +997,9 @@ fn interpolated_attributes(num_attributes: usize, points: &[Point], endpoint: En } } -// TODO: Handle custom attributes. -fn reverse_path(path: PathSlice, builder: &mut dyn PathBuilder) { +fn reverse_path(path: PathSlice) -> Path { + let mut builder = Path::builder_with_attributes(path.num_attributes()); + let attrib_stride = (path.num_attributes() + 1) / 2; let points = &path.points[..]; // At each iteration, p points to the first point after the current verb. diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1001,12 +1009,14 @@ fn reverse_path(path: PathSlice, builder: &mut dyn PathBuilder) { for v in path.verbs.iter().rev().cloned() { match v { Verb::Close => { + let idx = p - 1 - attrib_stride; need_close = true; - builder.move_to(points[p - 1]); + builder.move_to(points[idx], path.attributes(EndpointId(idx as u32))); } Verb::End => { + let idx = p - 1 - attrib_stride; need_close = false; - builder.move_to(points[p - 1]); + builder.move_to(points[idx], path.attributes(EndpointId(idx as u32))); } Verb::Begin => { if need_close { diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1015,17 +1025,25 @@ fn reverse_path(path: PathSlice, builder: &mut dyn PathBuilder) { } } Verb::LineTo => { - builder.line_to(points[p - 2]); + let idx = p - 2 - attrib_stride * 2; + builder.line_to(points[idx], path.attributes(EndpointId(idx as u32))); } Verb::QuadraticTo => { - builder.quadratic_bezier_to(points[p - 2], points[p - 3]); + let ctrl_idx = p - attrib_stride - 2; + let to_idx = ctrl_idx - attrib_stride - 1; + builder.quadratic_bezier_to(points[ctrl_idx], points[to_idx], path.attributes(EndpointId(to_idx as u32))); } Verb::CubicTo => { - builder.cubic_bezier_to(points[p - 2], points[p - 3], points[p - 4]); + let ctrl1_idx = p - attrib_stride - 2; + let ctrl2_idx = ctrl1_idx - 1; + let to_idx = ctrl2_idx - attrib_stride - 1; + builder.cubic_bezier_to(points[ctrl1_idx], points[ctrl2_idx], points[to_idx], path.attributes(EndpointId(to_idx as u32))); } } p -= n_stored_points(v, attrib_stride); } + + builder.build() } fn n_stored_points(verb: Verb, attrib_stride: usize) -> usize {
nical__lyon-503
503
[ "501" ]
0.14
nical/lyon
2019-12-25T11:52:19Z
diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1041,49 +1059,60 @@ fn n_stored_points(verb: Verb, attrib_stride: usize) -> usize { #[test] fn test_reverse_path() { - let mut builder = Path::builder(); - builder.move_to(point(0.0, 0.0)); - builder.line_to(point(1.0, 0.0)); - builder.line_to(point(1.0, 1.0)); - builder.line_to(point(0.0, 1.0)); - - builder.move_to(point(10.0, 0.0)); - builder.line_to(point(11.0, 0.0)); - builder.line_to(point(11.0, 1.0)); - builder.line_to(point(10.0, 1.0)); + let mut builder = Path::builder_with_attributes(1); + builder.move_to(point(0.0, 0.0), &[1.0]); + builder.line_to(point(1.0, 0.0), &[2.0]); + builder.line_to(point(1.0, 1.0), &[3.0]); + builder.line_to(point(0.0, 1.0), &[4.0]); + + builder.move_to(point(10.0, 0.0), &[5.0]); + builder.line_to(point(11.0, 0.0), &[6.0]); + builder.line_to(point(11.0, 1.0), &[7.0]); + builder.line_to(point(10.0, 1.0), &[8.0]); builder.close(); - builder.move_to(point(20.0, 0.0)); - builder.quadratic_bezier_to(point(21.0, 0.0), point(21.0, 1.0)); + builder.move_to(point(20.0, 0.0), &[9.0]); + builder.quadratic_bezier_to(point(21.0, 0.0), point(21.0, 1.0), &[10.0]); let p1 = builder.build(); - let mut builder = Path::builder(); - reverse_path(p1.as_slice(), &mut builder); - let p2 = builder.build(); + let p2 = p1.reversed(); + + let mut it = p2.iter_with_attributes(); + + // Using a function that explicits the argument types works around type inference issue. + fn check<'l>( + a: Option<Event<(Point, &'l[f32]), Point>>, + b: Option<Event<(Point, &'l[f32]), Point>>, + ) -> bool { + if a != b { + println!("left: {:?}", a); + println!("right: {:?}", b); + } - let mut it = p2.iter(); + a == b + } - assert_eq!(it.next(), Some(PathEvent::Begin { at: point(21.0, 1.0) })); - assert_eq!(it.next(), Some(PathEvent::Quadratic { - from: point(21.0, 1.0), + assert!(check(it.next(), Some(Event::Begin { at: (point(21.0, 1.0), &[10.0]) }))); + assert!(check(it.next(), Some(Event::Quadratic { + from: (point(21.0, 1.0), &[10.0]), ctrl: point(21.0, 0.0), - to: point(20.0, 0.0), - })); - assert_eq!(it.next(), Some(PathEvent::End { last: point(20.0, 0.0), first: point(21.0, 1.0), close: false })); - - assert_eq!(it.next(), Some(PathEvent::Begin { at: point(10.0, 1.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(10.0, 1.0), to: point(11.0, 1.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(11.0, 1.0), to: point(11.0, 0.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(11.0, 0.0), to: point(10.0, 0.0) })); - assert_eq!(it.next(), Some(PathEvent::End { last: point(10.0, 0.0), first: point(10.0, 1.0), close: true })); - - assert_eq!(it.next(), Some(PathEvent::Begin { at: point(0.0, 1.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(0.0, 1.0), to: point(1.0, 1.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(1.0, 1.0), to: point(1.0, 0.0) })); - assert_eq!(it.next(), Some(PathEvent::Line { from: point(1.0, 0.0), to: point(0.0, 0.0) })); - assert_eq!(it.next(), Some(PathEvent::End { last: point(0.0, 0.0), first: point(0.0, 1.0), close: false })); - - assert_eq!(it.next(), None); + to: (point(20.0, 0.0), &[9.0]), + }))); + assert!(check(it.next(), Some(Event::End { last: (point(20.0, 0.0), &[9.0]), first: (point(21.0, 1.0), &[10.0]), close: false }))); + + assert!(check(it.next(), Some(Event::Begin { at: (point(10.0, 1.0), &[8.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(10.0, 1.0), &[8.0]), to: (point(11.0, 1.0), &[7.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(11.0, 1.0), &[7.0]), to: (point(11.0, 0.0), &[6.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(11.0, 0.0), &[6.0]), to: (point(10.0, 0.0), &[5.0]) }))); + assert!(check(it.next(), Some(Event::End { last: (point(10.0, 0.0), &[5.0]), first: (point(10.0, 1.0), &[8.0]), close: true }))); + + assert!(check(it.next(), Some(Event::Begin { at: (point(0.0, 1.0), &[4.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(0.0, 1.0), &[4.0]), to: (point(1.0, 1.0), &[3.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(1.0, 1.0), &[3.0]), to: (point(1.0, 0.0), &[2.0]) }))); + assert!(check(it.next(), Some(Event::Line { from: (point(1.0, 0.0), &[2.0]), to: (point(0.0, 0.0), &[1.0]) }))); + assert!(check(it.next(), Some(Event::End { last: (point(0.0, 0.0), &[1.0]), first: (point(0.0, 1.0), &[4.0]), close: false }))); + + assert!(check(it.next(), None)); } #[test] diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1095,9 +1124,7 @@ fn test_reverse_path_no_close() { let p1 = builder.build(); - let mut builder = Path::builder(); - reverse_path(p1.as_slice(), &mut builder); - let p2 = builder.build(); + let p2 = p1.reversed(); let mut it = p2.iter(); diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1111,9 +1138,7 @@ fn test_reverse_path_no_close() { #[test] fn test_reverse_empty_path() { let p1 = Path::builder().build(); - let mut builder = Path::builder(); - reverse_path(p1.as_slice(), &mut builder); - let p2 = builder.build(); + let p2 = p1.reversed(); assert_eq!(p2.iter().next(), None); } diff --git a/path/src/path.rs b/path/src/path.rs --- a/path/src/path.rs +++ b/path/src/path.rs @@ -1122,9 +1147,7 @@ fn test_reverse_single_moveto() { let mut builder = Path::builder(); builder.move_to(point(0.0, 0.0)); let p1 = builder.build(); - let mut builder = Path::builder(); - reverse_path(p1.as_slice(), &mut builder); - let p2 = builder.build(); + let p2 = p1.reversed(); let mut it = p2.iter(); assert_eq!(it.next(), Some(PathEvent::Begin { at: point(0.0, 0.0) })); assert_eq!(it.next(), Some(PathEvent::End { last: point(0.0, 0.0), first: point(0.0, 0.0), close: false }));
Path::reversed should preserve custom attributes Currently the custom attributes aren't in the output path.
94f4ad731ffae32474ae4362c5f74507a86b564e
[ "path::test_reverse_path" ]
[ "commands::simple_path", "commands::next_event", "iterator::test_from_polyline_open", "path::test_merge_paths", "iterator::test_from_polyline_closed", "path::test_path_builder_empty", "path::test_path_builder_1", "path::test_reverse_empty_path", "path::test_reverse_path_no_close", "path::test_path_builder_empty_move_to", "path::test_path_builder_line_to_after_close", "path::test_reverse_single_moveto", "polygon::event_ids", "path/src/iterator.rs - iterator::FromPolyline (line 236)", "path/src/iterator.rs - iterator (line 69)", "path/src/commands.rs - commands (line 22)", "path/src/lib.rs - (line 13)", "path/src/iterator.rs - iterator (line 12)" ]
[]
[]
2019-12-25T11:58:15Z
525037751f50afd145131feded64156e79dfaaa9
diff --git a/tessellation/src/event_queue.rs b/tessellation/src/event_queue.rs --- a/tessellation/src/event_queue.rs +++ b/tessellation/src/event_queue.rs @@ -184,7 +184,7 @@ impl EventQueue { after: TessEventId, ) -> TessEventId { debug_assert!(self.sorted); - debug_assert!(is_after(data.to, position)); + debug_assert!(is_after(data.to, position), "{:?} should be after {:?}", data.to, position); let idx = self.events.len() as TessEventId; self.events.push(Event { diff --git a/tessellation/src/event_queue.rs b/tessellation/src/event_queue.rs --- a/tessellation/src/event_queue.rs +++ b/tessellation/src/event_queue.rs @@ -194,6 +194,49 @@ impl EventQueue { }); self.edge_data.push(data); + self.insert_into_sorted_list(idx, position, after); + + idx + } + + pub(crate) fn insert_sibling(&mut self, sibling: TessEventId, position: Point, data: EdgeData) { + debug_assert!(is_after(data.to, position)); + let idx = self.events.len() as TessEventId; + let next_sibling = self.events[sibling as usize].next_sibling; + + self.events.push(Event { + position, + next_event: INVALID_EVENT_ID, + next_sibling, + }); + + self.edge_data.push(data); + + self.events[sibling as usize].next_sibling = idx; + } + + pub(crate) fn vertex_event_sorted( + &mut self, + position: Point, + endpoint_id: EndpointId, + after: TessEventId, + ) { + let idx = self.events.len() as TessEventId; + + self.push_unsorted(position); + self.edge_data.push(EdgeData { + to: point(f32::NAN, f32::NAN), + range: 0.0..0.0, + winding: 0, + is_edge: false, + from_id: endpoint_id, + to_id: endpoint_id, + }); + + self.insert_into_sorted_list(idx, position, after); + } + + fn insert_into_sorted_list(&mut self, idx: TessEventId, position: Point, after: TessEventId) { let mut prev = after; let mut current = after; while self.valid_id(current) { diff --git a/tessellation/src/event_queue.rs b/tessellation/src/event_queue.rs --- a/tessellation/src/event_queue.rs +++ b/tessellation/src/event_queue.rs @@ -213,24 +256,6 @@ impl EventQueue { prev = current; current = self.next_id(current); } - - idx - } - - pub(crate) fn insert_sibling(&mut self, sibling: TessEventId, position: Point, data: EdgeData) { - debug_assert!(is_after(data.to, position)); - let idx = self.events.len() as TessEventId; - let next_sibling = self.events[sibling as usize].next_sibling; - - self.events.push(Event { - position, - next_event: INVALID_EVENT_ID, - next_sibling, - }); - - self.edge_data.push(data); - - self.events[sibling as usize].next_sibling = idx; } pub(crate) fn clear(&mut self) { diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -710,7 +710,13 @@ impl FillTessellator { /// Enable/disable some verbose logging during the tessellation, for /// debugging purposes. pub fn set_logging(&mut self, is_enabled: bool) { - self.log = is_enabled; + #[cfg(debug_assertions)] + let forced = env::var("LYON_FORCE_LOGGING").is_ok(); + + #[cfg(not(debug_assertions))] + let forced = false; + + self.log = is_enabled || forced; } fn tessellator_loop( diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -732,7 +738,7 @@ impl FillTessellator { if let Err(e) = self.process_events(&mut scan, output) { // Something went wrong, attempt to salvage the state of the sweep // line - self.recover_from_error(e); + self.recover_from_error(e, output); // ... and try again. self.process_events(&mut scan, output)? } diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -819,6 +825,8 @@ impl FillTessellator { self.edges_below.len(), ); + tess_log!(self, "edges below (initially): {:#?}", self.edges_below); + // Step 1 - Scan the active edge list, deferring processing and detecting potential // ordering issues in the active edges. self.scan_active_edges(scan)?; diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -862,7 +870,7 @@ impl FillTessellator { } else { tess_log!( self, - r#" <path d="M {} {} L {} {}" class="edge", winding="{}" sort_x="{:.}" min_x="{:.}"/>"#, + r#" <path d="M {:.5?} {:.5?} L {:.5?} {:.5?}" class="edge", winding="{:>2}" sort_x="{:.}" min_x="{:.}"/>"#, e.from.x, e.from.y, e.to.x, diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -879,16 +887,18 @@ impl FillTessellator { #[cfg(debug_assertions)] fn check_active_edges(&self) { - let mut winding = 0; - for edge in &self.active.edges { + let mut winding = WindingState::new(); + for (idx, edge) in self.active.edges.iter().enumerate() { + winding.update(self.fill_rule, edge.winding); if edge.is_merge { - assert!(self.fill_rule.is_in(winding)); + assert!(self.fill_rule.is_in(winding.number)); } else { - assert!(!is_after(self.current_position, edge.to)); - winding += edge.winding; + assert!(!is_after(self.current_position, edge.to), "error at edge {}, position {:?}", idx, edge.to); } } - assert_eq!(winding, 0); + assert_eq!(winding.number, 0); + let expected_span_count = (winding.span_index + 1) as usize; + assert_eq!(self.fill.spans.len(), expected_span_count); } /// Scan the active edges to find the information we will need for the tessellation, without diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1268,7 +1278,8 @@ impl FillTessellator { }); tess_log!( self, - "add edge below {:?} -> {:?} ({:?})", + "split {:?}, add edge below {:?} -> {:?} ({:?})", + edge_idx, self.current_position, self.edges_below.last().unwrap().to, active_edge.winding, diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1309,13 +1320,13 @@ impl FillTessellator { winding.is_in ); tess_log!(self, "winding state before point: {:?}", winding); - tess_log!(self, "edges below: {:?}", self.edges_below); + tess_log!(self, "edges below: {:#?}", self.edges_below); self.sort_edges_below(); - if scan.split_event { - debug_assert!(self.edges_below.len() >= 2); + self.handle_coincident_edges_below(); + if scan.split_event { // Split event. // // ........... diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1553,17 +1564,7 @@ impl FillTessellator { let active_edge = &mut self.active.edges[active_edge_idx]; - if is_near(self.current_position, intersection_position) { - tess_log!(self, "fix intersection position to current_position"); - intersection_position = self.current_position; - // We moved the intersection to the current position to avoid breaking ordering. - // This means we won't be adding an intersection event and we have to treat - // splitting the two edges in a special way: - // - the edge below does not need to be split. - // - the active edge is split so that it's upper part now ends at the current - // position which means it must be removed, however removing edges ending at - // the current position happens before the intersection checks. So instead we - // modify it in place and don't add a new event. + if self.current_position == intersection_position { active_edge.from = intersection_position; active_edge.min_x = active_edge.min_x.min(intersection_position.x); let src_range = &mut self.events.edge_data[active_edge.src_edge as usize].range; diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1588,7 +1589,7 @@ impl FillTessellator { tess_log!(self, "intersection near below.to"); intersection_position = edge_below.to; } else if is_near(intersection_position, active_edge.to) { - tess_log!(self, "intersection near below.to"); + tess_log!(self, "intersection near active_edge.to"); intersection_position = active_edge.to; } diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1596,6 +1597,7 @@ impl FillTessellator { let b_src_edge_data = self.events.edge_data[edge_below.src_edge as usize].clone(); let mut inserted_evt = None; + let mut flipped_active = false; if active_edge.to != intersection_position && active_edge.from != intersection_position diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1620,6 +1622,7 @@ impl FillTessellator { )); } else { tess_log!(self, "flip active edge after intersection"); + flipped_active = true; self.events.insert_sorted( active_edge.to, EdgeData { diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1682,11 +1685,25 @@ impl FillTessellator { }, self.current_event_id, ); - }; + + if flipped_active { + // It is extremely rare but if we end up flipping both of the + // edges that are inserted in the event queue, then we created a + // merge event which means we have to insert a vertex event into + // the queue, otherwise the tessellator will skip over the end of + // these two edges. + self.events.vertex_event_sorted( + intersection_position, + b_src_edge_data.to_id, + self.current_event_id, + ); + } + } edge_below.to = intersection_position; edge_below.range_end = remapped_tb; } + } } diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1789,7 +1806,7 @@ impl FillTessellator { } } - fn recover_from_error(&mut self, _error: InternalError) { + fn recover_from_error(&mut self, _error: InternalError, output: &mut dyn FillGeometryBuilder) { tess_log!(self, "Attempt to recover error {:?}", _error); self.sort_active_edges(); diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1829,6 +1846,11 @@ impl FillTessellator { } } + while self.fill.spans.len() > (winding.span_index + 1) as usize { + self.fill.spans.last_mut().unwrap().tess.flush(output); + self.fill.spans.pop(); + } + tess_log!(self, "-->"); #[cfg(debug_assertions)] diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1840,6 +1862,69 @@ impl FillTessellator { .sort_by(|a, b| b.angle.partial_cmp(&a.angle).unwrap_or(Ordering::Equal)); } + fn handle_coincident_edges_below(&mut self) { + if self.edges_below.len() < 2 { + return; + } + + for idx in (0..(self.edges_below.len() - 1)).rev() { + let a_idx = idx; + let b_idx = idx + 1; + let a_angle = self.edges_below[a_idx].angle; + let b_angle = self.edges_below[b_idx].angle; + if (a_angle - b_angle).abs() > 0.001 { + continue; + } + + let a_to = self.edges_below[a_idx].to; + let b_to = self.edges_below[b_idx].to; + let (lower_idx, upper_idx, split) = match compare_positions(a_to, b_to) { + Ordering::Greater => (a_idx, b_idx, true), + Ordering::Less => (b_idx, a_idx, true), + Ordering::Equal => (a_idx, b_idx, false), + }; + + tess_log!(self, "coincident edges {:?} -> {:?} / {:?}", self.current_position, a_to, b_to); + + tess_log!(self, "update winding: {:?} -> {:?}", self.edges_below[upper_idx].winding, self.edges_below[upper_idx].winding + self.edges_below[lower_idx].winding); + self.edges_below[upper_idx].winding += self.edges_below[lower_idx].winding; + let split_point = self.edges_below[upper_idx].to; + + tess_log!(self, "remove coincident edge {:?}, split:{:?}", idx, split); + let edge = self.edges_below.remove(lower_idx); + + if !split { + continue; + } + + let src_edge_data = self.events.edge_data[edge.src_edge as usize].clone(); + + let t = LineSegment { + from: self.current_position, + to: edge.to, + }.solve_t_for_y(split_point.y); + + let src_range = src_edge_data.range.start..edge.range_end; + let t_remapped = remap_t_in_range(t, src_range); + + let edge_data = EdgeData { + range: t_remapped..edge.range_end, + winding: edge.winding, + to: edge.to, + is_edge: true, + ..src_edge_data + }; + + self.events.insert_sorted( + split_point, + edge_data, + self.current_event_id, + ); + } + + } + + fn reset(&mut self) { self.current_position = point(f32::MIN, f32::MIN); self.current_vertex = VertexId::INVALID; diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1878,7 +1963,7 @@ pub(crate) fn is_after(a: Point, b: Point) -> bool { #[inline] pub(crate) fn is_near(a: Point, b: Point) -> bool { - (a - b).square_length() < 0.0001 + (a - b).square_length() < 0.000000001 } #[inline]
nical__lyon-570
570
Thanks for filing this, I'll have a look shortly. @yanchith I made a testcase from the one you provided, unfortunately it doesn't reproduce, which probably means the defaut formatting parameters arent printing enough decimals to represent the problematic case. could you copy-pase this code somehwere where you know the issue to be happening: ```rust pub struct PrintPath(pub Path); use std::fmt; impl fmt::Debug for PrintPath { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn write_point(formatter: &mut fmt::Formatter, point: Point) -> fmt::Result { write!(formatter, " ")?; fmt::Debug::fmt(&point.x, formatter)?; write!(formatter, " ")?; fmt::Debug::fmt(&point.y, formatter) } write!(formatter, "\"")?; for evt in &self.0 { match evt { PathEvent::Begin { at } => { write!(formatter, " M")?; write_point(formatter, at)?; } PathEvent::End { close, .. } => { if close { write!(formatter, " Z")?; } } PathEvent::Line { to, .. } => { write!(formatter, " L")?; write_point(formatter, to)?; } PathEvent::Quadratic { ctrl, to, .. } => { write!(formatter, " Q")?; write_point(formatter, ctrl)?; write_point(formatter, to)?; } PathEvent::Cubic { ctrl1, ctrl2, to, .. } => { write!(formatter, " C")?; write_point(formatter, ctrl1)?; write_point(formatter, ctrl2)?; write_point(formatter, to)?; } } } write!(formatter, "\"") } } ``` And then print the path like so: ```rust println!("teste case: {:.10?}", PrintPath(path)); ``` Where `path` is the path that is causing the bug and `{:.10}` asks the formatter to print 10 decimals in the hope that the extra precision will let us reproduce the issue. Thanks for looking into this :heart: I also managed to find a shorter path that triggers the debug assert. This is what it looks like when I disable debug assertions (I think this is very much a self-intersection stress test - but the original one looked much more reasonable). ![tests__multi_polygon_with_interior_rings_and_perpendicular_jitter snap-new](https://user-images.githubusercontent.com/1099245/79479635-59569c80-800d-11ea-8d9d-7919415bbb31.png) ```text test case: " M -0.8207679987 -0.8688971996 L -0.7742307782 -0.4698247313 L -0.9393702745 -0.7329606414 L -0.8874540329 -0.4791899323 L -0.6889821887 -0.3329083622 L -0.9466785192 -0.4303660095 L -0.9553674459 -0.4662885368 L -0.6109700203 -0.4329875708 L -0.8780106306 -0.2906790078 L -0.7089020014 -0.0037546456 L -0.9252399802 -0.3360545635 L -0.6019649506 -0.2058033347 L -0.9361810684 -0.2352166176 L -0.7691872716 0.0383807607 L -0.9362862706 0.1513814330 L -0.9839019179 0.1125854850 L -0.9825191498 0.2456643283 L -0.7321746945 0.4003376067 L -0.8890044689 0.1631975025 L -0.8380209208 0.4772368073 L -0.9701194763 0.5021913648 L -0.7367070913 0.2689037919 L -0.7358176112 0.6697905064 L -0.6914564967 0.3767231107 L -0.6123800278 0.5280315280 L -0.8706598878 0.6932309866 L -0.9071409106 0.6241128445 L -0.7203786969 0.6186348200 L -0.6145810485 0.9656302929 L -0.4690067768 0.9501831532 L -0.3469378054 0.7343682051 L -0.3069479465 0.9191360474 L -0.4034126699 0.6937038302 L -0.2330733687 0.6626541615 L -0.1501235664 0.9988733530 L -0.4087678790 0.6151789427 L 0.0327531993 0.6849809885 L -0.0281501785 0.7090716362 L -0.0062232986 0.9773678780 L -0.1278214604 0.8432378769 L 0.1939027905 0.8591585755 L 0.3300049901 0.8875733614 L 0.3639574349 0.6280845404 L 0.1604323387 0.7211027145 L 0.4273755550 0.6901011467 L 0.2191886604 0.9439773560 L 0.5304970741 0.7559456229 L 0.3243722022 0.8788009286 L 0.4153606594 0.7539806962 L 0.5388184190 0.6816532612 L 0.4902615249 0.9468226433 L 0.6173663735 0.7645685673 L 0.5697485209 0.8907170892 L 0.7220833898 0.9401075840 L 0.5721384883 0.9590278864 L 0.6159927249 0.8150777817 L 0.6281648874 0.6590110064 L 0.6916612983 0.9661321640 L 0.9044094682 0.8271411657 L 0.8482701778 0.7764627337 L 0.8773511648 0.6899036765 L 0.7063522935 0.5091397762 L 0.9860303402 0.5289094448 L 0.6892720461 0.4567596316 L 0.7256108522 0.6777729392 L 0.7977727652 0.3747999072 L 0.8892844319 0.6062116027 L 0.8649919033 0.5319378376 L 0.6517596245 0.3154333532 L 0.7493754625 0.3097154498 L 0.7621957660 0.1760187447 L 0.6630446315 0.0364976227 L 0.8375625610 0.2034847587 L 0.7190288305 0.1170381978 L 0.6663711071 0.0178340431 L 0.9843230247 -0.1750037372 L 0.7383416295 -0.0666050613 L 0.9314814806 -0.1724732071 L 0.7649849653 -0.1852992028 L 0.7282105684 -0.1020315737 L 0.6196770668 -0.2739042342 L 0.9452752471 -0.4432985783 L 0.9982362390 -0.3612855077 L 0.6540633440 -0.6645803452 L 0.8614879251 -0.5267579556 L 0.7629716992 -0.6080643535 L 0.9766238928 -0.8175441027 L 0.7646185160 -0.7051171660 L 0.7472760677 -0.6478849649 L 0.6498739719 -0.7323002815 L 0.8403692245 -0.8088044524 L 0.7439565659 -0.7405111790 L 0.7546553016 -0.7617247701 L 0.7539277077 -0.6317175627 L 0.6747937202 -0.9688835144 L 0.5831738114 -0.6822947264 L 0.2710255384 -0.9212602377 L 0.3769182265 -0.8479776978 L 0.2064074278 -0.7769882679 L 0.3313184381 -0.9860298038 L 0.3113351464 -0.6504784822 L 0.1898880303 -0.6752232313 L 0.1689367890 -0.7522631288 L -0.0547610596 -0.7867913246 L -0.2459574640 -0.6926927567 L -0.0004239529 -0.7583431602 L -0.3928295970 -0.8158227205 L -0.3479290307 -0.6722153425 L -0.1622253656 -0.7698250413 L -0.3365449607 -0.9790642262 L -0.3164364696 -0.9615324140 L -0.3415712714 -0.8687605858 L -0.4360900223 -0.7086173296 L -0.5481178761 -0.6680613160 L -0.4678017199 -0.6904769540 L -0.5304602981 -0.8362509608 L -0.7404142022 -0.7646956444 L -0.8207679987 -0.8688971996 Z M -0.6103347540 -0.4546403587 L -0.4373104274 -0.3770174384 L -0.5713154078 -0.4916919470 L -0.3022333384 -0.4247310460 L -0.5027727485 -0.4506492913 L -0.4841670394 -0.3679628372 L -0.1511912346 -0.6495994329 L -0.3456022739 -0.3601520061 L -0.3149848580 -0.5312928557 L -0.1873361766 -0.6391361952 L 0.0833640397 -0.4321969151 L 0.0316221789 -0.3349926174 L 0.0312347040 -0.6730831861 L -0.0483473241 -0.3870794177 L -0.0645213202 -0.5983390212 L 0.2230887264 -0.4881301820 L 0.0357133001 -0.4856303632 L 0.3644523025 -0.4373076558 L 0.2783037126 -0.5246815681 L 0.4604045451 -0.5858781934 L 0.4078963697 -0.3316536546 L 0.3179360330 -0.6173570752 L 0.3963582516 -0.4108166099 L 0.6719979644 -0.5660122037 L 0.3090577424 -0.2779315114 L 0.4112541080 -0.3650614917 L 0.4903442562 -0.2728729844 L 0.3085053563 -0.2772275507 L 0.4387947619 -0.2452066839 L 0.3409250975 -0.0901858956 L 0.3143540621 -0.0997110605 L 0.4798444808 -0.0653616861 L 0.4718981385 0.3133855462 L 0.6216366291 0.0191372037 L 0.3037990928 0.2022005916 L 0.4845580757 0.5250537395 L 0.4636508524 0.3209675848 L 0.5203218460 0.5389408469 L 0.6316121817 0.5669875145 L 0.4591632485 0.4284194708 L 0.3364180923 0.4508785903 L 0.0780621916 0.5582271218 L 0.2733506858 0.3093393445 L 0.2833133340 0.3918714225 L 0.1808252931 0.5302590132 L -0.1752744466 0.6364661455 L -0.2096720189 0.6507015228 L -0.0349738188 0.5706411600 L -0.1468322128 0.5691297650 L -0.1100965440 0.4844444990 L -0.2021583617 0.6087667942 L -0.2902344763 0.3073914051 L -0.5706925988 0.5832292438 L -0.5657762289 0.6442109346 L -0.3674018383 0.2772150040 L -0.5790590048 0.4808012247 L -0.3829382062 0.1518871486 L -0.3636212945 0.3996013403 L -0.3719620109 0.2713861763 L -0.4994530678 0.3044236898 L -0.3159398735 -0.0201248005 L -0.6898441911 0.0840430409 L -0.4843970239 0.0263934806 L -0.4314195812 -0.2985772491 L -0.4801315963 -0.3063287437 L -0.4526919425 -0.1820725948 L -0.4226042926 -0.2801684141 L -0.3453123569 -0.4942801595 L -0.5826355219 -0.4949773252 L -0.6211405993 -0.4299353957 L -0.6103347540 -0.4546403587 Z M -0.2373057455 0.0438369736 L -0.3063875139 0.1355578899 L -0.1638046205 -0.0154281883 L -0.4687410593 0.1082780659 L -0.3651874065 0.1854619980 L -0.4115832448 0.0232470036 L -0.2175029218 0.3421458006 L 0.0326723754 0.2507743537 L -0.1664895564 0.2789841294 L -0.1799614131 0.1784405708 L -0.0920714140 0.3760473430 L -0.0125246756 0.1361679435 L -0.1416051686 0.2236121595 L 0.1511402875 0.3379152119 L -0.0910345316 0.4289065599 L 0.1443543136 0.2934197485 L 0.0810062289 0.0438074544 L 0.3063925505 0.2821950614 L -0.0449981466 0.2581389546 L 0.0854395926 0.0528362431 L 0.2224378735 0.2352965772 L 0.3515253663 0.0874702781 L 0.4534252882 0.2636899948 L 0.2431462258 0.0001910098 L 0.1015618742 0.0539262220 L 0.3285050988 -0.1832991391 L 0.2987216711 -0.0286900848 L 0.2384124398 -0.0759301260 L -0.0812912881 -0.3276998997 L -0.0164258555 -0.3455935419 L -0.0946191996 -0.2891138494 L -0.0497247949 -0.3069086671 L -0.2603819370 -0.3634280264 L 0.0993251204 -0.2322873771 L 0.0176783651 -0.1744873524 L -0.4210351408 -0.0997784734 L -0.2239840627 0.0462330282 L -0.2231680155 0.0495854318 L -0.2760682106 -0.0637637079 L -0.2373057455 0.0438369736 Z" ``` Let me know, if you need more precision. I still can't reproduce with the new test case. Could you crank up the number of decimals to something ridiculous like 30? I also ran the fuzzer again on 6 cores of a rather beefy desktop computer for about 2 days without running into any assertion (turned the assertions into a release asserts to tessellate as fast as possible). Lyon's fuzzer is all about generating random self-intersecting torture cases, but it could mean that there is something specific about how you generate these paths that the fuzzer isn't running into, so I'm interested in any detail you can provide about how you make these paths. I notice that the coordinate range is within `[-1, 1]` in both test cases so I'll try to force that and see if it helps. If you have some code somewhere online I can look at it might help. > Could you crank up the number of decimals to something ridiculous like 30? Sure I can, but wouldn't it help if I serialized the f32s as bits instead? Don't know the internals of the float parsing code in std, but I can imagine the f32 you get after de-serializing could be different from the one I serialized. I quickly checked and the values matched for this test case so that shouldn't be the problem, but still... Output with 30 decimal places of precision: ```text test case (30 decimal places): " M -0.820767998695373535156250000000 -0.868897199630737304687500000000 L -0.774230778217315673828125000000 -0.469824731349945068359375000000 L -0.939370274543762207031250000000 -0.732960641384124755859375000000 L -0.887454032897949218750000000000 -0.479189932346343994140625000000 L -0.688982188701629638671875000000 -0.332908362150192260742187500000 L -0.946678519248962402343750000000 -0.430366009473800659179687500000 L -0.955367445945739746093750000000 -0.466288536787033081054687500000 L -0.610970020294189453125000000000 -0.432987570762634277343750000000 L -0.878010630607604980468750000000 -0.290679007768630981445312500000 L -0.708902001380920410156250000000 -0.003754645586013793945312500000 L -0.925239980220794677734375000000 -0.336054563522338867187500000000 L -0.601964950561523437500000000000 -0.205803334712982177734375000000 L -0.936181068420410156250000000000 -0.235216617584228515625000000000 L -0.769187271595001220703125000000 0.038380760699510574340820312500 L -0.936286270618438720703125000000 0.151381433010101318359375000000 L -0.983901917934417724609375000000 0.112585484981536865234375000000 L -0.982519149780273437500000000000 0.245664328336715698242187500000 L -0.732174694538116455078125000000 0.400337606668472290039062500000 L -0.889004468917846679687500000000 0.163197502493858337402343750000 L -0.838020920753479003906250000000 0.477236807346343994140625000000 L -0.970119476318359375000000000000 0.502191364765167236328125000000 L -0.736707091331481933593750000000 0.268903791904449462890625000000 L -0.735817611217498779296875000000 0.669790506362915039062500000000 L -0.691456496715545654296875000000 0.376723110675811767578125000000 L -0.612380027770996093750000000000 0.528031527996063232421875000000 L -0.870659887790679931640625000000 0.693230986595153808593750000000 L -0.907140910625457763671875000000 0.624112844467163085937500000000 L -0.720378696918487548828125000000 0.618634819984436035156250000000 L -0.614581048488616943359375000000 0.965630292892456054687500000000 L -0.469006776809692382812500000000 0.950183153152465820312500000000 L -0.346937805414199829101562500000 0.734368205070495605468750000000 L -0.306947946548461914062500000000 0.919136047363281250000000000000 L -0.403412669897079467773437500000 0.693703830242156982421875000000 L -0.233073368668556213378906250000 0.662654161453247070312500000000 L -0.150123566389083862304687500000 0.998873353004455566406250000000 L -0.408767879009246826171875000000 0.615178942680358886718750000000 L 0.032753199338912963867187500000 0.684980988502502441406250000000 L -0.028150178492069244384765625000 0.709071636199951171875000000000 L -0.006223298609256744384765625000 0.977367877960205078125000000000 L -0.127821460366249084472656250000 0.843237876892089843750000000000 L 0.193902790546417236328125000000 0.859158575534820556640625000000 L 0.330004990100860595703125000000 0.887573361396789550781250000000 L 0.363957434892654418945312500000 0.628084540367126464843750000000 L 0.160432338714599609375000000000 0.721102714538574218750000000000 L 0.427375555038452148437500000000 0.690101146697998046875000000000 L 0.219188660383224487304687500000 0.943977355957031250000000000000 L 0.530497074127197265625000000000 0.755945622920989990234375000000 L 0.324372202157974243164062500000 0.878800928592681884765625000000 L 0.415360659360885620117187500000 0.753980696201324462890625000000 L 0.538818418979644775390625000000 0.681653261184692382812500000000 L 0.490261524915695190429687500000 0.946822643280029296875000000000 L 0.617366373538970947265625000000 0.764568567276000976562500000000 L 0.569748520851135253906250000000 0.890717089176177978515625000000 L 0.722083389759063720703125000000 0.940107583999633789062500000000 L 0.572138488292694091796875000000 0.959027886390686035156250000000 L 0.615992724895477294921875000000 0.815077781677246093750000000000 L 0.628164887428283691406250000000 0.659011006355285644531250000000 L 0.691661298274993896484375000000 0.966132164001464843750000000000 L 0.904409468173980712890625000000 0.827141165733337402343750000000 L 0.848270177841186523437500000000 0.776462733745574951171875000000 L 0.877351164817810058593750000000 0.689903676509857177734375000000 L 0.706352293491363525390625000000 0.509139776229858398437500000000 L 0.986030340194702148437500000000 0.528909444808959960937500000000 L 0.689272046089172363281250000000 0.456759631633758544921875000000 L 0.725610852241516113281250000000 0.677772939205169677734375000000 L 0.797772765159606933593750000000 0.374799907207489013671875000000 L 0.889284431934356689453125000000 0.606211602687835693359375000000 L 0.864991903305053710937500000000 0.531937837600708007812500000000 L 0.651759624481201171875000000000 0.315433353185653686523437500000 L 0.749375462532043457031250000000 0.309715449810028076171875000000 L 0.762195765972137451171875000000 0.176018744707107543945312500000 L 0.663044631481170654296875000000 0.036497622728347778320312500000 L 0.837562561035156250000000000000 0.203484758734703063964843750000 L 0.719028830528259277343750000000 0.117038197815418243408203125000 L 0.666371107101440429687500000000 0.017834043130278587341308593750 L 0.984323024749755859375000000000 -0.175003737211227416992187500000 L 0.738341629505157470703125000000 -0.066605061292648315429687500000 L 0.931481480598449707031250000000 -0.172473207116127014160156250000 L 0.764984965324401855468750000000 -0.185299202799797058105468750000 L 0.728210568428039550781250000000 -0.102031573653221130371093750000 L 0.619677066802978515625000000000 -0.273904234170913696289062500000 L 0.945275247097015380859375000000 -0.443298578262329101562500000000 L 0.998236238956451416015625000000 -0.361285507678985595703125000000 L 0.654063344001770019531250000000 -0.664580345153808593750000000000 L 0.861487925052642822265625000000 -0.526757955551147460937500000000 L 0.762971699237823486328125000000 -0.608064353466033935546875000000 L 0.976623892784118652343750000000 -0.817544102668762207031250000000 L 0.764618515968322753906250000000 -0.705117166042327880859375000000 L 0.747276067733764648437500000000 -0.647884964942932128906250000000 L 0.649873971939086914062500000000 -0.732300281524658203125000000000 L 0.840369224548339843750000000000 -0.808804452419281005859375000000 L 0.743956565856933593750000000000 -0.740511178970336914062500000000 L 0.754655301570892333984375000000 -0.761724770069122314453125000000 L 0.753927707672119140625000000000 -0.631717562675476074218750000000 L 0.674793720245361328125000000000 -0.968883514404296875000000000000 L 0.583173811435699462890625000000 -0.682294726371765136718750000000 L 0.271025538444519042968750000000 -0.921260237693786621093750000000 L 0.376918226480484008789062500000 -0.847977697849273681640625000000 L 0.206407427787780761718750000000 -0.776988267898559570312500000000 L 0.331318438053131103515625000000 -0.986029803752899169921875000000 L 0.311335146427154541015625000000 -0.650478482246398925781250000000 L 0.189888030290603637695312500000 -0.675223231315612792968750000000 L 0.168936789035797119140625000000 -0.752263128757476806640625000000 L -0.054761059582233428955078125000 -0.786791324615478515625000000000 L -0.245957463979721069335937500000 -0.692692756652832031250000000000 L -0.000423952937126159667968750000 -0.758343160152435302734375000000 L -0.392829596996307373046875000000 -0.815822720527648925781250000000 L -0.347929030656814575195312500000 -0.672215342521667480468750000000 L -0.162225365638732910156250000000 -0.769825041294097900390625000000 L -0.336544960737228393554687500000 -0.979064226150512695312500000000 L -0.316436469554901123046875000000 -0.961532413959503173828125000000 L -0.341571271419525146484375000000 -0.868760585784912109375000000000 L -0.436090022325515747070312500000 -0.708617329597473144531250000000 L -0.548117876052856445312500000000 -0.668061316013336181640625000000 L -0.467801719903945922851562500000 -0.690476953983306884765625000000 L -0.530460298061370849609375000000 -0.836250960826873779296875000000 L -0.740414202213287353515625000000 -0.764695644378662109375000000000 L -0.820767998695373535156250000000 -0.868897199630737304687500000000 Z M -0.610334753990173339843750000000 -0.454640358686447143554687500000 L -0.437310427427291870117187500000 -0.377017438411712646484375000000 L -0.571315407752990722656250000000 -0.491691946983337402343750000000 L -0.302233338356018066406250000000 -0.424731045961380004882812500000 L -0.502772748470306396484375000000 -0.450649291276931762695312500000 L -0.484167039394378662109375000000 -0.367962837219238281250000000000 L -0.151191234588623046875000000000 -0.649599432945251464843750000000 L -0.345602273941040039062500000000 -0.360152006149291992187500000000 L -0.314984858036041259765625000000 -0.531292855739593505859375000000 L -0.187336176633834838867187500000 -0.639136195182800292968750000000 L 0.083364039659500122070312500000 -0.432196915149688720703125000000 L 0.031622178852558135986328125000 -0.334992617368698120117187500000 L 0.031234703958034515380859375000 -0.673083186149597167968750000000 L -0.048347324132919311523437500000 -0.387079417705535888671875000000 L -0.064521320164203643798828125000 -0.598339021205902099609375000000 L 0.223088726401329040527343750000 -0.488130182027816772460937500000 L 0.035713300108909606933593750000 -0.485630363225936889648437500000 L 0.364452302455902099609375000000 -0.437307655811309814453125000000 L 0.278303712606430053710937500000 -0.524681568145751953125000000000 L 0.460404545068740844726562500000 -0.585878193378448486328125000000 L 0.407896369695663452148437500000 -0.331653654575347900390625000000 L 0.317936033010482788085937500000 -0.617357075214385986328125000000 L 0.396358251571655273437500000000 -0.410816609859466552734375000000 L 0.671997964382171630859375000000 -0.566012203693389892578125000000 L 0.309057742357254028320312500000 -0.277931511402130126953125000000 L 0.411254107952117919921875000000 -0.365061491727828979492187500000 L 0.490344256162643432617187500000 -0.272872984409332275390625000000 L 0.308505356311798095703125000000 -0.277227550745010375976562500000 L 0.438794761896133422851562500000 -0.245206683874130249023437500000 L 0.340925097465515136718750000000 -0.090185895562171936035156250000 L 0.314354062080383300781250000000 -0.099711060523986816406250000000 L 0.479844480752944946289062500000 -0.065361686050891876220703125000 L 0.471898138523101806640625000000 0.313385546207427978515625000000 L 0.621636629104614257812500000000 0.019137203693389892578125000000 L 0.303799092769622802734375000000 0.202200591564178466796875000000 L 0.484558075666427612304687500000 0.525053739547729492187500000000 L 0.463650852441787719726562500000 0.320967584848403930664062500000 L 0.520321846008300781250000000000 0.538940846920013427734375000000 L 0.631612181663513183593750000000 0.566987514495849609375000000000 L 0.459163248538970947265625000000 0.428419470787048339843750000000 L 0.336418092250823974609375000000 0.450878590345382690429687500000 L 0.078062191605567932128906250000 0.558227121829986572265625000000 L 0.273350685834884643554687500000 0.309339344501495361328125000000 L 0.283313333988189697265625000000 0.391871422529220581054687500000 L 0.180825293064117431640625000000 0.530259013175964355468750000000 L -0.175274446606636047363281250000 0.636466145515441894531250000000 L -0.209672018885612487792968750000 0.650701522827148437500000000000 L -0.034973818808794021606445312500 0.570641160011291503906250000000 L -0.146832212805747985839843750000 0.569129765033721923828125000000 L -0.110096544027328491210937500000 0.484444499015808105468750000000 L -0.202158361673355102539062500000 0.608766794204711914062500000000 L -0.290234476327896118164062500000 0.307391405105590820312500000000 L -0.570692598819732666015625000000 0.583229243755340576171875000000 L -0.565776228904724121093750000000 0.644210934638977050781250000000 L -0.367401838302612304687500000000 0.277215003967285156250000000000 L -0.579059004783630371093750000000 0.480801224708557128906250000000 L -0.382938206195831298828125000000 0.151887148618698120117187500000 L -0.363621294498443603515625000000 0.399601340293884277343750000000 L -0.371962010860443115234375000000 0.271386176347732543945312500000 L -0.499453067779541015625000000000 0.304423689842224121093750000000 L -0.315939873456954956054687500000 -0.020124800503253936767578125000 L -0.689844191074371337890625000000 0.084043040871620178222656250000 L -0.484397023916244506835937500000 0.026393480598926544189453125000 L -0.431419581174850463867187500000 -0.298577249050140380859375000000 L -0.480131596326828002929687500000 -0.306328743696212768554687500000 L -0.452691942453384399414062500000 -0.182072594761848449707031250000 L -0.422604292631149291992187500000 -0.280168414115905761718750000000 L -0.345312356948852539062500000000 -0.494280159473419189453125000000 L -0.582635521888732910156250000000 -0.494977325201034545898437500000 L -0.621140599250793457031250000000 -0.429935395717620849609375000000 L -0.610334753990173339843750000000 -0.454640358686447143554687500000 Z M -0.237305745482444763183593750000 0.043836973607540130615234375000 L -0.306387513875961303710937500000 0.135557889938354492187500000000 L -0.163804620504379272460937500000 -0.015428188256919384002685546875 L -0.468741059303283691406250000000 0.108278065919876098632812500000 L -0.365187406539916992187500000000 0.185461997985839843750000000000 L -0.411583244800567626953125000000 0.023247003555297851562500000000 L -0.217502921819686889648437500000 0.342145800590515136718750000000 L 0.032672375440597534179687500000 0.250774353742599487304687500000 L -0.166489556431770324707031250000 0.278984129428863525390625000000 L -0.179961413145065307617187500000 0.178440570831298828125000000000 L -0.092071413993835449218750000000 0.376047343015670776367187500000 L -0.012524675577878952026367187500 0.136167943477630615234375000000 L -0.141605168581008911132812500000 0.223612159490585327148437500000 L 0.151140287518501281738281250000 0.337915211915969848632812500000 L -0.091034531593322753906250000000 0.428906559944152832031250000000 L 0.144354313611984252929687500000 0.293419748544692993164062500000 L 0.081006228923797607421875000000 0.043807454407215118408203125000 L 0.306392550468444824218750000000 0.282195061445236206054687500000 L -0.044998146593570709228515625000 0.258138954639434814453125000000 L 0.085439592599868774414062500000 0.052836243063211441040039062500 L 0.222437873482704162597656250000 0.235296577215194702148437500000 L 0.351525366306304931640625000000 0.087470278143882751464843750000 L 0.453425288200378417968750000000 0.263689994812011718750000000000 L 0.243146225810050964355468750000 0.000191009836271405220031738281 L 0.101561874151229858398437500000 0.053926222026348114013671875000 L 0.328505098819732666015625000000 -0.183299139142036437988281250000 L 0.298721671104431152343750000000 -0.028690084815025329589843750000 L 0.238412439823150634765625000000 -0.075930126011371612548828125000 L -0.081291288137435913085937500000 -0.327699899673461914062500000000 L -0.016425855457782745361328125000 -0.345593541860580444335937500000 L -0.094619199633598327636718750000 -0.289113849401473999023437500000 L -0.049724794924259185791015625000 -0.306908667087554931640625000000 L -0.260381937026977539062500000000 -0.363428026437759399414062500000 L 0.099325120449066162109375000000 -0.232287377119064331054687500000 L 0.017678365111351013183593750000 -0.174487352371215820312500000000 L -0.421035140752792358398437500000 -0.099778473377227783203125000000 L -0.223984062671661376953125000000 0.046233028173446655273437500000 L -0.223168015480041503906250000000 0.049585431814193725585937500000 L -0.276068210601806640625000000000 -0.063763707876205444335937500000 L -0.237305745482444763183593750000 0.043836973607540130615234375000 Z" ``` Output as bits as defined by https://doc.rust-lang.org/stable/std/primitive.f32.html#method.to_bits : ```text test case (u32 bits): " M 3209829850 3210637324 L 3209049085 3203435742 L 3211819666 3208356687 L 3210948656 3203749986 L 3207618851 3198841591 L 3211942278 3202111727 L 3212088054 3203317087 L 3206310024 3202199692 L 3210790222 3197424609 L 3207953050 3145076864 L 3211582599 3198947160 L 3206158944 3193093660 L 3211766160 3195067552 L 3208964469 1025324325 L 3211767925 1041957820 L 3212566783 1038521144 L 3212543584 1048285038 L 3208343501 1053620493 L 3210974668 1042750783 L 3210119306 1056200802 L 3212335552 1057001373 L 3208419542 1049210306 L 3208404619 1059813220 L 3207660363 1052828122 L 3206333680 1057434899 L 3210666897 1060206486 L 3211278947 1059046876 L 3208145597 1058954970 L 3206370607 1064776588 L 3203408296 1064517428 L 3199312341 1060896654 L 3197970504 1063996544 L 3201207323 1060214419 L 3194923721 1059693492 L 3189357054 1065334314 L 3201387014 1058896990 L 1023813688 1060068074 L 3169229620 1060472248 L 3150703824 1064973512 L 3187860385 1062723184 L 1044811380 1062990289 L 1051260522 1063467010 L 1052399777 1059113510 L 1042565216 1060674096 L 1054527736 1060153976 L 1046508286 1064413312 L 1057476264 1061258663 L 1051071517 1063319833 L 1054124583 1061225697 L 1057615873 1060012244 L 1056637839 1064461048 L 1058933689 1061403332 L 1058134794 1063519753 L 1060690549 1064348388 L 1058174891 1064665818 L 1058910643 1062250736 L 1059114858 1059632370 L 1060180151 1064785008 L 1063749473 1062453126 L 1062807612 1061602883 L 1063295510 1060150663 L 1060426625 1057117948 L 1065118844 1057449628 L 1060140066 1055513702 L 1060749730 1059947143 L 1061960406 1052763590 L 1063495717 1058746543 L 1063088156 1057500436 L 1059510712 1050771579 L 1061148434 1050579718 L 1061363523 1043611202 L 1059700043 1024818824 L 1062627968 1045454415 L 1060639302 1039118777 L 1059755852 1016207539 L 1065090200 3191026734 L 1060963317 3179833404 L 1064203666 3190856913 L 1061410318 3191717651 L 1060793346 3184588270 L 1058972456 3196861741 L 1064435087 3202545672 L 1065323625 3199793770 L 1059549362 3207209456 L 1063029369 3204897180 L 1061376541 3206261275 L 1064961030 3209775762 L 1061404170 3207889551 L 1061113212 3206929354 L 1059479076 3208345608 L 1062675056 3209629135 L 1061057520 3208483364 L 1061237015 3208839269 L 1061224808 3206658110 L 1059897160 3212314816 L 1058360033 3207506654 L 1049281500 3211515830 L 1052834669 3210286353 L 1045650552 3209095348 L 1051304594 3212602483 L 1050634066 3206972866 L 1044541954 3207388014 L 1043135940 3208680529 L 3177205026 3209259816 L 3195788358 3207681104 L 3118351872 3208782535 L 3200852214 3209746882 L 3199345601 3207337550 L 3190169192 3208975169 L 3198963615 3212485620 L 3198288886 3212191485 L 3199132270 3210635032 L 3202303793 3207948274 L 3205255540 3207267857 L 3203367861 3207643929 L 3204959295 3210089611 L 3208481737 3208889112 L 3209829850 3210637324 Z M 3206299366 3202926239 L 3202344743 3200321646 L 3205644730 3204169484 L 3197812308 3201922649 L 3204494775 3202792321 L 3203916990 3200017824 L 3189428704 3206958118 L 3199267528 3199755736 L 3198240178 3204973263 L 3191854350 3206782574 L 1034599108 3202173162 L 1023510082 3198911527 L 1023401964 3207352110 L 3175483352 3200659270 L 3179553729 3206098111 L 1046770015 3204049971 L 1024608284 3203966091 L 1052416382 3202344650 L 1049525715 3204862344 L 1055636005 3205889053 L 1053874123 3198799490 L 1050855555 3206417181 L 1053486968 3201455758 L 1059850255 3205555757 L 1050557649 3196996874 L 1053986790 3199920471 L 1056640615 3196827138 L 1050539114 3196973253 L 1054910901 3195737974 L 1051626940 3182998370 L 1050735364 3184276816 L 1056288301 3179666521 L 1056021666 1050702866 L 1059005332 1016907168 L 1050381198 1045368236 L 1056446463 1057384940 L 1055744933 1050957277 L 1057305552 1057617927 L 1059172694 1058088472 L 1055594354 1054562764 L 1051475710 1055316367 L 1033887506 1057941497 L 1049359519 1050567098 L 1049693810 1053336415 L 1043933764 1057472270 L 3191044901 1059254130 L 3193353283 1059492960 L 3171893429 1058149770 L 3189136175 1058124413 L 3185670732 1056442652 L 3192849050 1058789412 L 3197409693 1050501736 L 3205634281 1058360963 L 3205551798 1059384066 L 3199999000 1049489184 L 3205774646 1056320404 L 3200520314 1041991758 L 3199872146 1053595788 L 3200152014 1049293601 L 3204429904 1050402156 L 3198272223 3164921028 L 3207633313 1034690242 L 3203924707 1020802852 L 3202147079 3197689630 L 3203781583 3197949727 L 3202860861 3191501117 L 3201851287 3197071932 L 3199257800 3204256330 L 3205834650 3204279723 L 3206480658 3202097278 L 3206299366 3202926239 Z M 3195207751 1026788966 L 3197951699 1040895920 L 3190275174 3162293891 L 3203399380 1037943012 L 3199924696 1044244928 L 3201481482 1019113600 L 3193878806 1051667900 L 1023791992 1048601983 L 3190455357 1049548546 L 3191359438 1043773728 L 3183251440 1052805447 L 3159176268 1040936860 L 3188785394 1046805142 L 1041941637 1051525945 L 3183112272 1054579108 L 1041486238 1050032925 L 1034282648 1026781042 L 1050468220 1049656287 L 3174584314 1048849098 L 1034877684 1029204689 L 1046726337 1047589270 L 1051982626 1035150238 L 1055401820 1049035360 L 1048116051 961038800 L 1037041580 1029497278 L 1051210194 3191583429 L 1050210828 3169519480 L 1047798372 3181084993 L 3181804556 3198666824 L 3162935172 3199267235 L 3183593398 3197372091 L 3175853114 3197969186 L 3196408008 3199865661 L 1036741368 3194870974 L 1016123960 3190992080 L 3201798635 3184285864 L 3194313748 1027432152 L 3194258984 1028332056 L 3196934352 3179452044 L 3195207751 1026788966 Z" ``` Also, importantly: we use `lyon::tessellation::FillOptions::non_zero()`. I probably should have mentioned this :thinking: If this doesn't help reproducing, I'll try and debug the issue on my end. > If you have some code somewhere online I can look at it might help. Afraid I can't share the code that generated this path, but the rough idea is that we rebuild (via `walk_along_path`) an existing simpler path, and randomly offset points both along the tangent and the normal, while also randomly prolonging or shortening the interval between points. Damn. When I ran with `FillOptions::default()`, I didn't trigger the assertion either, only `FillOptions::non_zero()` triggers it. I should have noticed this sooner. Aha! Silly me, I should have tried this. With the non-zero fill rule I can reproduce the issue with all of the test cases you provided. I have to confess the non-zero fill rule is not as well tested as even-odd which needs to change. The upside is that I've been pushing the fuzzing parameters far enough that I managed to find another bug. > Afraid I can't share the code that generated this path, but the rough idea is that we rebuild (via walk_along_path) an existing simpler path, and randomly offset points both along the tangent and the normal, while also randomly prolonging or shortening the interval between points. Sound like fun!
[ "562" ]
0.15
nical/lyon
2020-04-23T21:45:52Z
diff --git a/tessellation/src/fill_tests.rs b/tessellation/src/fill_tests.rs --- a/tessellation/src/fill_tests.rs +++ b/tessellation/src/fill_tests.rs @@ -135,7 +135,7 @@ fn test_path_with_rotations(path: Path, step: f32, expected_triangle_count: Opti let mut angle = Angle::radians(0.0); while angle.radians < PI * 2.0 { - println!("\n\n ==================== angle = {:?}", angle); + //println!("\n\n ==================== angle = {:?}", angle); let tranformed_path = path.transformed(&Rotation::new(angle)); diff --git a/tessellation/src/fill_tests.rs b/tessellation/src/fill_tests.rs --- a/tessellation/src/fill_tests.rs +++ b/tessellation/src/fill_tests.rs @@ -2188,3 +2188,201 @@ fn issue_529() { // SVG path syntax: // "M 203.01 174.67 L 203.04 174.72 L 203 174.68 ZM 203 174.66 L 203.01 174.68 L 202.99 174.68 Z" } + +#[test] +fn issue_562_1() { + let mut builder = Path::builder(); + + builder.begin(point(757.26587, 494.72363)); + builder.line_to(point(833.3479, 885.81494)); + builder.line_to(point(342.08817, 855.6907)); + builder.close(); + + builder.begin(point(580.21893, 759.2482)); + builder.line_to(point(545.2758, 920.6801)); + builder.line_to(point(739.3726, 23.550331)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 757.26587 494.72363 L 833.3479 885.81494 L 342.08817 855.6907 ZM 580.21893 759.2482 L 545.2758 920.6801 L 739.3726 23.550331 Z" +} + +#[test] +fn issue_562_2() { + let mut builder = Path::builder(); + + builder.begin(point(3071.0, 737.0)); + builder.line_to(point(3071.0, 738.0)); + builder.line_to(point(3071.0, 738.0)); + builder.close(); + + builder.begin(point(3071.0, 3071.0)); + builder.line_to(point(3071.0, 703.0)); + builder.line_to(point(3071.0, 703.0)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 3071 737 L 3071 738 L 3071 738 ZM 3071 3071 L 3071 703 L 3071 703 Z" +} + +#[test] +fn issue_562_3() { + let mut builder = Path::builder(); + + builder.begin(point(4224.0, -128.0)); + builder.line_to(point(3903.0, 3615.0)); + builder.line_to(point(3903.0, 3590.0)); + builder.line_to(point(3893.0, 3583.0)); + builder.close(); + + builder.begin(point(3898.0, 3898.0)); + builder.line_to(point(3898.0, 3585.0)); + builder.line_to(point(3897.0, 3585.0)); + builder.close(); + + builder.begin(point(3899.0, 3899.0)); + builder.line_to(point(3899.0, 1252.0)); + builder.line_to(point(3899.0, 1252.0)); + builder.close(); + + builder.begin(point(3897.0, 3897.0)); + builder.line_to(point(3897.0, 3536.0)); + builder.line_to(point(3897.0, 3536.0)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 4224 -128 L 3903 3615 L 3903 3590 L 3893 3583 ZM 3898 3898 L 3898 3585 L 3897 3585 ZM 3899 3899 L 3899 1252 L 3899 1252 ZM 3897 3897 L 3897 3536 L 3897 3536 Z" +} + +#[test] +fn issue_562_4() { + let mut builder = Path::builder(); + + builder.begin(point(160.39546, 11.226683)); + builder.line_to(point(160.36594, 11.247373)); + builder.line_to(point(160.32234, 11.28461)); + builder.line_to(point(160.36172, 11.299779)); + builder.line_to(point(160.39265, 11.361827)); + builder.close(); + + builder.begin(point(160.36313, 160.36313)); + builder.line_to(point(160.36313, 11.14253)); + builder.line_to(point(160.36313, 11.14253)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 160.39546 11.226683 L 160.36594 11.247373 L 160.32234 11.28461 L 160.36172 11.299779 L 160.39265 11.361827 ZM 160.36313 160.36313 L 160.36313 11.14253 L 160.36313 11.14253 Z" +} + +#[test] +fn issue_562_5() { + let mut builder = Path::builder(); + + builder.begin(point(0.88427734, 0.2277832)); + builder.line_to(point(0.88671875, 0.22143555)); + builder.line_to(point(0.91259766, 0.23803711)); + builder.line_to(point(0.8869629, 0.22607422)); + builder.line_to(point(0.88793945, 0.22827148)); + builder.line_to(point(0.8869629, 0.22607422)); + builder.line_to(point(0.89453125, 0.2265625)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 0.88427734 0.2277832 L 0.88671875 0.22143555 L 0.91259766 0.23803711 L 0.8869629 0.22607422 L 0.88793945 0.22827148 L 0.8869629 0.22607422 L 0.89453125 0.2265625 Z" +} + +#[test] +fn issue_562_6() { + let mut builder = Path::builder(); + + builder.begin(point(-499.51904, 864.00793)); + builder.line_to(point(510.1705, -862.41235)); + builder.line_to(point(1005.31006, 6.4012146)); + builder.line_to(point(-994.65857, -4.8055725)); + builder.line_to(point(-489.81372, -868.01575)); + builder.line_to(point(500.4652, 869.6113)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M -499.51904 864.00793 L 510.1705 -862.41235 L 1005.31006 6.4012146 L -994.65857 -4.8055725 L -489.81372 -868.01575 L 500.4652 869.6113 Z" +} + +#[test] +fn issue_562_7() { + let mut builder = Path::builder(); + + builder.begin(point(-880.59766, -480.86603)); + builder.line_to(point(878.77014, 470.2519)); + builder.line_to(point(709.1563, 698.824)); + builder.line_to(point(-710.9838, -709.4381)); + builder.line_to(point(-483.84427, -880.9657)); + builder.line_to(point(482.01672, 870.35156)); + builder.line_to(point(215.75311, 970.9385)); + builder.line_to(point(-217.58063, -981.5527)); + builder.line_to(point(66.236084, -1003.05)); + builder.line_to(point(-68.063614, 992.4358)); + builder.line_to(point(-346.44025, 933.1019)); + builder.line_to(point(344.61273, -943.71606)); + builder.line_to(point(594.9969, -808.35785)); + builder.line_to(point(-596.8244, 797.7438)); + builder.line_to(point(934.5602, -358.7028)); + builder.line_to(point(-936.3877, 348.08868)); + builder.line_to(point(-998.05756, 70.22009)); + builder.line_to(point(996.23004, -80.83423)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M -880.59766 -480.86603 L 878.77014 470.2519 L 709.1563 698.824 L -710.9838 -709.4381 L -483.84427 -880.9657 L 482.01672 870.35156 L 215.75311 970.9385 L -217.58063 -981.5527 L 66.236084 -1003.05 L -68.063614 992.4358 L -346.44025 933.1019 L 344.61273 -943.71606 L 594.9969 -808.35785 L -596.8244 797.7438 L 934.5602 -358.7028 L -936.3877 348.08868 L -998.05756 70.22009 L 996.23004 -80.83423 Z" +} + +#[test] +fn issue_562_8() { + let mut builder = Path::builder(); + + builder.begin(point(997.84753, -18.145767)); + builder.line_to(point(-1001.9789, 8.1993265)); + builder.line_to(point(690.0551, 716.8084)); + builder.line_to(point(-694.1865, -726.7548)); + builder.line_to(point(-589.4575, -814.2759)); + builder.line_to(point(585.3262, 804.3294)); + builder.line_to(point(469.6551, 876.7747)); + builder.line_to(point(-473.78647, -886.7211)); + builder.line_to(point(-349.32822, -942.74115)); + builder.line_to(point(345.1968, 932.7947)); + builder.line_to(point(-218.4011, -981.2923)); + builder.line_to(point(-83.44396, -1001.6565)); + builder.line_to(point(-57.160374, 993.50793)); + builder.line_to(point(53.02899, -1003.4543)); + builder.line_to(point(188.47563, -986.65234)); + builder.line_to(point(-192.60701, 976.7059)); + builder.line_to(point(-324.50436, 941.61707)); + builder.line_to(point(320.37296, -951.56354)); + builder.line_to(point(446.26376, -898.84155)); + builder.line_to(point(-450.39514, 888.89514)); + builder.line_to(point(-567.9344, 819.52203)); + builder.line_to(point(563.80304, -829.4685)); + builder.line_to(point(670.8013, -744.73676)); + builder.line_to(point(-769.3966, 636.2781)); + builder.line_to(point(909.81805, -415.4218)); + builder.close(); + + test_path(builder.build().as_slice()); + + // SVG path syntax: + // "M 997.84753 -18.145767 L -1001.9789 8.1993265 L 690.0551 716.8084 L -694.1865 -726.7548 L -589.4575 -814.2759 L 585.3262 804.3294 L 469.6551 876.7747 L -473.78647 -886.7211 L -349.32822 -942.74115 L 345.1968 932.7947 L -218.4011 -981.2923 L -83.44396 -1001.6565 L -57.160374 993.50793 L 53.02899 -1003.4543 L 188.47563 -986.65234 L -192.60701 976.7059 L -324.50436 941.61707 L 320.37296 -951.56354 L 446.26376 -898.84155 L -450.39514 888.89514 L -567.9344 819.52203 L 563.80304 -829.4685 L 670.8013 -744.73676 L -769.3966 636.2781 L 909.81805 -415.4218 Z" +} +
FillTessellator with non-zero fill rule panics with 'assertion failed: self.fill.spans.is_empty()' Hello, First of all, really sorry that the bug reproduction is not as minimal as it could be (see attached `Path`). I can spend some more time on this later, if it helps. Version: `0.15.6` The panic is a `debug_assert!` in `FillTessellator::tessellate_impl` happening in the intersection handling mode: ```rust if !self.assume_no_intersection { debug_assert!(self.active.edges.is_empty()); debug_assert!(self.fill.spans.is_empty()); } // There shouldn't be any span left after the tessellation ends. // If for whatever reason (bug) there are, flush them so that we don't // miss the triangles they contain. for span in &mut self.fill.spans { if !span.remove { span.tess.flush(builder); } } ``` With debug assertions disabled, the panic doesn't happen, but the resulting geometry has missing sections. The path that produced the result: ``` [renderer\src\renderer.rs:1138] b.build() = Path { points: [ (-0.60259604,-0.58157045), (-0.59677887,-0.5092269), (-0.6174213,-0.5267591), (-0.61093175,-0.46566024), (-0.5861228,-0.41503733), (-0.61833483,-0.40764514), (-0.61942095,-0.3795996), (-0.57637125,-0.36358547), (-0.60975134,-0.3158738), (-0.5886128,-0.26188445), (-0.615655,-0.29995453), (-0.5752456,-0.27125803), (-0.61702263,-0.24840377), (-0.59614843,-0.18031535), (-0.6170358,-0.16135482), (-0.62298775,-0.1401929), (-0.6228149,-0.10120473), (-0.59152186,-0.050876297), (-0.6111256,-0.04873301), (-0.60475266,-0.0018536113), (-0.62126493,0.010817773), (-0.5920884,0.0062524937), (-0.59197724,0.06690842), (-0.5864321,0.052761808), (-0.5765475,0.105109796), (-0.6088325,0.15463106), (-0.61339265,0.17660378), (-0.5773294,0.23629637), (-0.6207038,0.28113014), (-0.6187729,0.32698315), (-0.59179604,0.35906404), (-0.614892,0.38619053), (-0.586713,0.38986617), (-0.5828318,0.42302912), (-0.6248592,0.46195307), (-0.5768974,0.45683885), (-0.58562267,0.54633164), (-0.58863395,0.55197126), (-0.622171,0.5798707), (-0.6041322,0.60540473), (-0.5428574,0.6073949), (-0.49670452,0.6109467), (-0.46826607,0.5785106), (-0.4918129,0.59013784), (-0.42939848,0.58626264), (-0.4484358,0.61799717), (-0.3978513,0.5944932), (-0.39727977,0.60985017), (-0.37688425,0.59424764), (-0.3527931,0.5852067), (-0.3457066,0.61835283), (-0.32513332,0.5955711), (-0.32902676,0.6113396), (-0.30619046,0.6175135), (-0.29688856,0.61987853), (-0.2844228,0.6018847), (-0.25545648,0.5823764), (-0.22642548,0.6207665), (-0.20151892,0.61305124), (-0.17513536,0.6060338), (-0.14052011,0.6096689), (-0.1033149,0.588294), (-0.10065438,0.6232538), (-0.07159888,0.58615905), (-0.09497244,0.5907014), (-0.033542663,0.5997216), (-0.03461238,0.6111606), (-0.016603516,0.608124), (0.03890508,0.58146995), (0.052306406,0.593672), (0.0832663,0.5952745), (0.122955725,0.5828806), (0.11377947,0.6046953), (0.15270458,0.5898786), (0.19612166,0.5832964), (0.24701829,0.6230404), (0.23935774,0.5922927), (0.27105954,0.6164352), (0.2878405,0.59562314), (0.31238535,0.59102637), (0.35035154,0.57745963), (0.39165956,0.6181594), (0.3967888,0.6247795), (0.4631457,0.58175796), (0.47948575,0.60768604), (0.5105501,0.5953715), (0.571468,0.622078), (0.56343484,0.59557736), (0.5667347,0.59340954), (0.58849484,0.5812343), (0.60110056,0.5824008), (0.5925639,0.554705), (0.5952156,0.52566063), (0.5789647,0.50823784), (0.62111044,0.48361027), (0.58528686,0.44653568), (0.61515754,0.4052647), (0.6059972,0.41006753), (0.59712356,0.35409263), (0.62325376,0.3479237), (0.58130985,0.3200769), (0.5844029,0.2710338), (0.5940329,0.24385622), (0.5983489,0.20151895), (0.5865866,0.14628445), (0.5947929,0.15216458), (0.6019779,0.068069965), (0.58402693,0.047285147), (0.5962282,0.06835826), (0.62238306,0.042473916), (0.6201916,0.032901905), (0.6085951,-0.0039572464), (0.5885772,-0.033157233), (0.58350766,-0.07931078), (0.5863097,-0.099550486), (0.6045314,-0.12336385), (0.59558696,-0.16949475), (0.5775068,-0.2037091), (0.6233757,-0.20333086), (0.6023864,-0.24556363), (0.6208509,-0.24487463), (0.6140979,-0.28466457), (0.5961493,-0.28554806), (0.59294146,-0.32766032), (0.6149322,-0.32879248), (0.5885359,-0.36302572), (0.60423875,-0.38484472), (0.60595775,-0.37690973), (0.61442167,-0.40872684), (0.59914464,-0.48643023), (0.57834053,-0.48027998), (0.6177974,-0.5173237), (0.6002402,-0.51034313), (0.59600747,-0.54360604), (0.60293674,-0.54362786), (0.6234776,-0.5925645), (0.57233346,-0.58652276), (0.5645269,-0.59446895), (0.50188154,-0.58349663), (0.5216614,-0.5906242), (0.4563698,-0.6070479), (0.49255794,-0.618665), (0.4400403,-0.592449), (0.40736714,-0.58600867), (0.40539715,-0.58021474), (0.3745325,-0.58631366), (0.37698188,-0.5758431), (0.3635959,-0.61922157), (0.32900646,-0.5905947), (0.3197619,-0.5760027), (0.2586821,-0.59875774), (0.2950288,-0.5802172), (0.25808737,-0.5807295), (0.2195605,-0.60770506), (0.19836077,-0.5873924), (0.16206777,-0.5862778), (0.17651996,-0.5773876), (0.16164728,-0.5796963), (0.1320911,-0.6059241), (0.12242479,-0.60222197), (0.09847601,-0.5968505), (0.07492885,-0.5978607), (0.049932566,-0.5947989), (0.0030497573,-0.608694), (-0.03205134,-0.5933147), (-0.05033874,-0.61138254), (-0.067493446,-0.579865), (-0.09693898,-0.57661176), (-0.07316814,-0.59106356), (-0.12402288,-0.5804932), (-0.16019267,-0.58088017), (-0.14007387,-0.58318055), (-0.2034651,-0.57595354), (-0.18248624,-0.60295117), (-0.21558326,-0.6036031), (-0.21937431,-0.6246258), (-0.2518451,-0.6065916), (-0.2374334,-0.5759969), (-0.31872496,-0.5990379), (-0.31005886,-0.5843345), (-0.3181398,-0.57603425), (-0.36501303,-0.6116566), (-0.39997482,-0.5873107), (-0.4124322,-0.6185696), (-0.42816016,-0.5950977), (-0.50068486,-0.57650554), (-0.5380531,-0.6035571), (-0.525106,-0.59686184), (-0.594949,-0.58061665), (-0.57879514,-0.5798233), (-0.29675782,-0.28452057), (-0.24763039,-0.3228382), (-0.20794387,-0.29842067), (-0.21426141,-0.29775405), (-0.14372064,-0.32083926), (-0.12067782,-0.2809099), (-0.08520027,-0.31095064), (-0.08751391,-0.3042702), (-0.036226794,-0.27863735), (-0.018205184,-0.31108704), (-0.025932608,-0.29662612), (-0.0027539898,-0.27848557), (0.020221405,-0.27980366), (0.07470769,-0.28136113), (0.076729596,-0.27798364), (0.1507279,-0.31309813), (0.16384159,-0.32452077), (0.15821922,-0.2813635), (0.17702198,-0.30820543), (0.1931788,-0.28837848), (0.22456959,-0.31963113), (0.26741686,-0.31262013), (0.24365339,-0.31195414), (0.28450483,-0.32311893), (0.2899769,-0.28927734), (0.3054002,-0.31149706), (0.32003966,-0.2669488), (0.3180658,-0.22617309), (0.2820771,-0.19516827), (0.31043264,-0.18790394), (0.31692246,-0.11270481), (0.31096938,-0.1102328), (0.28008324,-0.13458017), (0.28404975,-0.05718037), (0.28717384,-0.01619012), (0.2886603,0.0069112536), (0.3141475,0.025300987), (0.2969753,0.083431676), (0.3058953,0.07754997), (0.29735526,0.10121589), (0.30658162,0.18440203), (0.3178312,0.1805799), (0.3080364,0.20908354), (0.32325375,0.19740905), (0.3023612,0.2065191), (0.28636914,0.20976755), (0.28632414,0.25062406), (0.29063004,0.27398133), (0.30441955,0.2790809), (0.23388645,0.2829509), (0.24248835,0.3074875), (0.2093001,0.32283372), (0.18040219,0.3174637), (0.17111823,0.3044186), (0.12868175,0.3066763), (0.12107556,0.28109536), (0.08493749,0.31363815), (0.06621642,0.31911612), (0.014729233,0.29004174), (0.026758876,0.30046654), (-0.02744952,0.31654358), (-0.0680121,0.29293913), (-0.08377724,0.28104413), (-0.084302515,0.29465106), (-0.1326194,0.31418052), (-0.13527404,0.31053945), (-0.19256584,0.2789343), (-0.1866086,0.28764045), (-0.21125369,0.2797091), (-0.2446407,0.31787658), (-0.26799384,0.3168881), (-0.25821373,0.3002406), (-0.30369022,0.27710253), (-0.308262,0.30638203), (-0.304127,0.24392901), (-0.2844539,0.21547566), (-0.3179056,0.23636363), (-0.3031408,0.1879893), (-0.29248494,0.17064708), (-0.30521703,0.15191133), (-0.30163595,0.09261818), (-0.30107588,0.11501736), (-0.3237576,0.05002614), (-0.3193523,0.04355081), (-0.2817773,0.018528512), (-0.29315352,-0.015802464), (-0.2841787,-0.047852114), (-0.3200281,-0.08511352), (-0.27511322,-0.10760765), (-0.31292272,-0.17306928), (-0.32358846,-0.16101113), (-0.30491018,-0.21262279), (-0.29324737,-0.24626745), (-0.31967318,-0.25357124), (-0.1313625,-0.051560905), (-0.16452262,-0.045776214), (-0.14756282,0.008725138), (-0.15558232,0.031920042), (-0.15406884,0.07536536), (-0.11803106,0.061181977), (-0.13425447,0.09863065), (-0.07760243,0.09327083), (-0.10481052,0.10784877), (-0.12055813,0.108920015), (-0.066495314,0.12169065), (-0.07656256,0.14880407), (-0.07220844,0.15967748), (-0.057043646,0.12403247), (-0.07464621,0.14983201), (-0.057791688,0.16106145), (-0.0024733413,0.14846951), (0.044990394,0.13312174), (0.059183106,0.14213166), (0.06636514,0.14784311), (0.065392286,0.117277846), (0.07669962,0.100540005), (0.08542977,0.12089226), (0.10523389,0.12256271), (0.092723146,0.08747706), (0.110089995,0.061987936), (0.14387512,0.05746229), (0.14404552,0.034098938), (0.1374408,0.013244936), (0.14449653,-0.039051503), (0.15886287,-0.061389275), (0.14222021,-0.065283954), (0.14696278,-0.0639164), (0.11313941,-0.09705555), (0.10661489,-0.07139524), (0.09435058,-0.12477098), (0.04344476,-0.14646487), (0.023379706,-0.12777074), (0.01841465,-0.17299202), (-0.031268314,-0.12649246), (-0.06154371,-0.16749237), (-0.039286736,-0.14578591), (-0.08729143,-0.13973206), (-0.059731632,-0.107418336), (-0.057891134,-0.13353941), (-0.08053762,-0.10146829), (-0.07866131,-0.11454674), (-0.11223841,-0.10906139), ], verbs: [ Begin, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, Close, Begin, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, Close, Begin, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, LineTo, Close, ], num_attributes: 0, } ```
08cd4c3d8c1ef53fbbb1b702f655e26c6bd5cc03
[ "earcut_tests::self_touching", "fill_tests::issue_562_1", "fill_tests::issue_562_5", "earcut_tests::eberly_6", "fill_tests::issue_562_6", "fill_tests::issue_481_reduced", "fill_tests::issue_481_original", "fill_tests::issue_562_7", "fuzz_tests::fuzzing_test_case_16", "fuzz_tests::fuzzing_test_case_01", "earcut_tests::water_huge", "fill_tests::n_segments_intersecting" ]
[ "earcut_tests::bad_diagonal", "earcut_tests::building", "earcut_tests::degenerate", "earcut_tests::bad_hole", "earcut_tests::empty_square", "earcut_tests::eberly_3", "earcut_tests::dude", "earcut_tests::issue_16", "earcut_tests::hole_touching_outer", "earcut_tests::issue_17", "earcut_tests::issue_29", "earcut_tests::issue_45", "earcut_tests::outside_ring", "earcut_tests::issue_52", "earcut_tests::issue_34", "earcut_tests::shared_points", "earcut_tests::steiner", "earcut_tests::touching_holes", "earcut_tests::simplified_us_border", "earcut_tests::water_3", "earcut_tests::water_3b", "event_queue::test_event_queue_push_sorted", "event_queue::test_event_queue_sort_2", "event_queue::test_event_queue_sort_1", "event_queue::test_event_queue_sort_4", "fill::fill_vertex_source_02", "fill::fill_vertex_source_03", "fill_tests::back_along_previous_edge", "fill::fill_builder_vertex_source", "earcut_tests::hilbert", "event_queue::test_event_queue_sort_3", "fill_tests::issue_476_original", "fill_tests::issue_529", "event_queue::test_event_queue_sort_5", "fill_tests::issue_562_2", "fill::fill_vertex_source_01", "fill_tests::angle_precision", "fill_tests::issue_518_1", "fill_tests::issue_518_2", "fill_tests::issue_562_3", "fill_tests::issue_476_reduced", "fill_tests::issue_500", "fill_tests::new_tess_2", "fill_tests::issue_562_4", "fill_tests::new_tess_1", "fill_tests::new_tess_coincident_simple", "earcut_tests::water_2", "fill_tests::new_tess_overlapping_1", "fill_tests::new_tess_merge", "fill_tests::reduced_test_case_01", "fill_tests::new_tess_points_too_close", "fill_tests::reduced_test_case_06", "earcut_tests::issue_35", "fill_tests::overlapping_horizontal", "fill_tests::reduced_test_case_08", "fill_tests::reduced_test_case_07", "fill_tests::reduced_test_case_14", "fill_tests::test_auto_intersection_type1", "fill_tests::test_auto_intersection_type2", "fill_tests::reduced_test_case_03", "fill_tests::reduced_test_case_09", "fill_tests::reduced_test_case_11", "fill_tests::reduced_test_case_10", "fill_tests::reduced_test_case_12", "fill_tests::reduced_test_case_02", "fill_tests::reduced_test_case_13", "fill_tests::reduced_test_case_05", "fill_tests::issue_562_8", "fill_tests::reduced_test_case_04", "event_queue::test_logo", "fill_tests::test_chained_merge_end", "fill_tests::test_chained_merge_left", "fill_tests::test_chained_merge_merge", "fill_tests::test_coincident_simple_1", "fill_tests::test_close_at_first_position", "fill_tests::test_coincident_simple_2", "fill_tests::test_chained_merge_split", "fill_tests::test_colinear_3", "fill_tests::test_colinear_4", "earcut_tests::water_4", "fill_tests::test_colinear_touching_squares2", "fill_tests::test_colinear_touching_squares3", "fill_tests::test_colinear_touching_squares", "fill_tests::test_double_merge_with_intersection", "fill_tests::test_exp_no_intersection_01", "fill_tests::test_fixed_to_f32_precision", "fill_tests::test_intersecting_bow_tie", "fill_tests::test_identical_squares", "fill_tests::test_empty_path", "fill_tests::test_no_close", "fill_tests::test_point_on_edge2", "fill_tests::test_intersection_horizontal_precision", "fill_tests::test_point_on_edge_right", "fill_tests::test_intersection_1", "fill_tests::test_point_on_edge_left", "fill_tests::test_overlapping_with_intersection", "fill_tests::test_simple_double_merge", "fill_tests::test_simple_monotone", "fill_tests::test_unknown_issue_1", "fill_tests::three_edges_below", "fill_tests::triangle", "fill_tests::test_split_with_intersections", "fill_tests::test_colinear_2", "fuzz_tests::fuzzing_test_case_15", "fuzz_tests::fuzzing_test_case_12", "fuzz_tests::fuzzing_test_case_11", "fill_tests::test_colinear_1", "fuzz_tests::fuzzing_test_case_14", "fuzz_tests::fuzzing_test_case_18", "fuzz_tests::fuzzing_test_case_20", "fuzz_tests::fuzzing_test_case_10", "fuzz_tests::fuzzing_test_case_19", "fuzz_tests::fuzzing_test_case_17", "fuzz_tests::fuzzing_test_case_21", "fuzz_tests::fuzzing_test_case_13", "fuzz_tests::fuzzing_test_case_24", "fuzz_tests::fuzzing_test_case_22", "fuzz_tests::fuzzing_test_case_4", "fuzz_tests::fuzzing_test_case_6", "fill_tests::test_too_many_vertices", "fuzz_tests::fuzzing_test_case_23", "fuzz_tests::fuzzing_test_case_25", "fill_tests::test_rust_logo_scale_down2", "fill_tests::test_simple_triangle", "stroke::stroke_vertex_source_01", "fuzz_tests::fuzzing_test_case_8", "monotone::test_monotone_tess", "math_utils::test_compute_normal", "fuzz_tests::fuzzing_test_case_7", "fuzz_tests::fuzzing_test_case_9", "stroke::test_empty_caps", "stroke::test_square", "stroke::test_too_many_vertices", "fill_tests::test_coincident_simple_rotated", "stroke::test_empty_path", "fill_tests::test_rust_logo_scale_down", "test_without_miter_limit", "fuzz_tests::fuzzing_test_case_26", "test_with_invalid_miter_limit - should panic", "test_with_miter_limit", "fuzz_tests::fuzzing_test_case_5", "earcut_tests::water", "fill_tests::test_colinear_touching_squares_rotated", "fuzz_tests::fuzzing_test_case_3", "fuzz_tests::fuzzing_test_case_2", "fill_tests::test_degenerate_same_position", "fill_tests::test_intersecting_star_shape", "fill_tests::test_auto_intersection_multi", "fill_tests::test_rust_logo_scale_up", "fill_tests::test_simple_split", "fill_tests::test_simple_1", "fill_tests::test_simple_merge_split", "fill_tests::test_hole_1", "fill_tests::test_simple_aligned", "earcut_tests::water_huge_2", "fill_tests::test_simple_2", "fill_tests::very_large_path", "fill_tests::test_rust_logo_no_intersection", "fill_tests::test_rust_logo_with_intersection", "tessellation/src/geometry_builder.rs - geometry_builder (line 205)", "tessellation/src/geometry_builder.rs - geometry_builder (line 131)", "tessellation/src/stroke.rs - stroke::StrokeTessellator::builder (line 171)", "tessellation/src/fill.rs - fill::FillTessellator::builder (line 623)", "tessellation/src/stroke.rs - stroke::StrokeTessellator (line 47)", "tessellation/src/geometry_builder.rs - geometry_builder (line 72)", "tessellation/src/fill.rs - fill::FillTessellator (line 377)", "tessellation/src/fill.rs - fill::FillTessellator (line 335)" ]
[]
[]
2020-04-23T21:46:13Z
122ee5f0077fcf363745cb6ab1c4641545029efc
diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -432,7 +432,7 @@ name = "geom_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -781,13 +781,13 @@ dependencies = [ [[package]] name = "lyon" -version = "0.15.3" +version = "0.15.5" dependencies = [ "lyon_algorithms 0.15.0", "lyon_extra 0.15.0", "lyon_svg 0.15.0", "lyon_tess2 0.15.0", - "lyon_tessellation 0.15.4", + "lyon_tessellation 0.15.5", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -809,7 +809,7 @@ dependencies = [ "gfx_window_glutin 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -862,14 +862,14 @@ dependencies = [ name = "lyon_tess2" version = "0.15.0" dependencies = [ - "lyon_tessellation 0.15.4", + "lyon_tessellation 0.15.5", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "tess2-sys 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lyon_tessellation" -version = "0.15.4" +version = "0.15.5" dependencies = [ "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lyon_extra 0.15.0", diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,7 +1117,7 @@ dependencies = [ "gfx_device_gl 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_window_glutin 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1125,7 +1125,7 @@ name = "path_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1584,7 +1584,7 @@ name = "svg-rendering-example" version = "0.1.0" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", "usvg 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu-native 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1683,7 +1683,7 @@ name = "tess_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.3", + "lyon 0.15.5", "tess2-sys 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1930,7 +1930,7 @@ dependencies = [ name = "wgpu-example" version = "0.1.0" dependencies = [ - "lyon 0.15.3", + "lyon 0.15.5", "wgpu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu-native 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.20.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lyon" -version = "0.15.3" +version = "0.15.5" description = "2D Graphics rendering on the GPU using tessellation." authors = [ "Nicolas Silva <nical@fastmail.com>" ] repository = "https://github.com/nical/lyon" diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ libtess2 = ["lyon_tess2"] [dependencies] -lyon_tessellation = { version = "0.15.3", path = "tessellation/" } +lyon_tessellation = { version = "0.15.5", path = "tessellation/" } lyon_algorithms = { version = "0.15.0", path = "algorithms/" } lyon_extra = { version = "0.15.0", optional = true, path = "extra/" } lyon_svg = { version = "0.15.0", optional = true, path = "svg/" } diff --git a/tessellation/Cargo.toml b/tessellation/Cargo.toml --- a/tessellation/Cargo.toml +++ b/tessellation/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lyon_tessellation" -version = "0.15.4" +version = "0.15.5" description = "A low level path tessellation library." authors = [ "Nicolas Silva <nical@fastmail.com>" ] repository = "https://github.com/nical/lyon" diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1545,10 +1545,20 @@ impl FillTessellator { } else { debug_assert!(!is_after(self.current_position, edge.to)); - let x = if edge.to.y == y { - edge.to.x - } else if edge.from.y == y { + let eq_to = edge.to.y == y; + let eq_from = edge.from.y == y; + + let x = if eq_to && eq_from { + let current_x = self.current_position.x; + if edge.max_x >= current_x && edge.min_x <= current_x { + self.current_position.x + } else { + edge.min_x + } + } else if eq_from { edge.from.x + } else if eq_to { + edge.to.x } else { edge.solve_x_for_y(y) };
nical__lyon-530
530
Thanks for the report, unless the input data contains broken floats like NaNs or inifinity, and has fewer than u32::MAX vertices, it should definitely be considered as a bug in the tessellator which is the case here. I was able to reproduce this and reduce it to a small testcase. I'll look into it soon.
[ "529" ]
0.15
nical/lyon
2020-01-12T20:48:35Z
diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -882,7 +882,7 @@ dependencies = [ name = "lyon_wasm_test" version = "0.11.0" dependencies = [ - "lyon 0.15.3", + "lyon 0.15.5", ] [[package]] diff --git a/tessellation/src/fill_tests.rs b/tessellation/src/fill_tests.rs --- a/tessellation/src/fill_tests.rs +++ b/tessellation/src/fill_tests.rs @@ -2146,3 +2146,29 @@ fn very_large_path() { &mut NoOutput::new(), ).unwrap(); } + +#[test] +fn issue_529() { + let mut builder = Path::builder(); + + builder.move_to(point(203.01, 174.67)); + builder.line_to(point(203.04, 174.72)); + builder.line_to(point(203.0, 174.68)); + builder.close(); + + builder.move_to(point(203.0, 174.66)); + builder.line_to(point(203.01, 174.68)); + builder.line_to(point(202.99, 174.68)); + builder.close(); + + let mut tess = FillTessellator::new(); + + tess.tessellate( + &builder.build(), + &FillOptions::default(), + &mut NoOutput::new(), + ).unwrap(); + + // SVG path syntax: + // "M 203.01 174.67 L 203.04 174.72 L 203 174.68 ZM 203 174.66 L 203.01 174.68 L 202.99 174.68 Z" +}
Fill tessellation failure in 0.15.3 I'm tesselating a svg file that I simply pass from usvg to lyon fill tesselator. The svg file can be found at [0], I used `CNTR_RG_03M_2016_4326.svg` which used to work with 0.14, (but `CNTR_RG_01M_2016_4326.svg` did not). The error is simply `Internal(IncorrectActiveEdgeOrder(3))`, the node id seems to be "MX" (Mexico). I'm unable to discern if this is bad data or numerical issue or simply a bug in the tessellator. [0] https://ec.europa.eu/eurostat/cache/GISCO/distribution/v1/countries-2016.html
08cd4c3d8c1ef53fbbb1b702f655e26c6bd5cc03
[ "fill_tests::issue_529" ]
[ "basic_shapes::issue_366", "earcut_tests::bad_diagonal", "earcut_tests::bad_hole", "earcut_tests::building", "earcut_tests::degenerate", "earcut_tests::dude", "earcut_tests::eberly_3", "earcut_tests::empty_square", "earcut_tests::hole_touching_outer", "earcut_tests::issue_16", "earcut_tests::issue_29", "earcut_tests::issue_17", "earcut_tests::issue_45", "earcut_tests::outside_ring", "earcut_tests::issue_34", "earcut_tests::shared_points", "earcut_tests::simplified_us_border", "earcut_tests::issue_52", "earcut_tests::steiner", "earcut_tests::self_touching", "earcut_tests::touching_holes", "earcut_tests::water_3b", "earcut_tests::hilbert", "event_queue::test_event_queue_sort_1", "fill::fill_vertex_source_01", "event_queue::test_event_queue_push_sorted", "fill::fill_vertex_source_03", "fill::fill_vertex_source_02", "earcut_tests::water_3", "fill_tests::back_along_previous_edge", "event_queue::test_event_queue_sort_3", "fill_tests::angle_precision", "event_queue::test_event_queue_sort_5", "fill_tests::issue_476_reduced", "fill_tests::issue_481_reduced", "fill_tests::new_tess_1", "fill_tests::new_tess_2", "event_queue::test_event_queue_sort_2", "fill_tests::issue_476_original", "event_queue::test_event_queue_sort_4", "fill_tests::issue_518_2", "earcut_tests::issue_35", "fill_tests::reduced_test_case_04", "fill_tests::issue_518_1", "fill_tests::overlapping_horizontal", "earcut_tests::eberly_6", "fill_tests::new_tess_coincident_simple", "fill_tests::issue_500", "fill_tests::reduced_test_case_14", "fill_tests::new_tess_overlapping_1", "fill_tests::issue_481_original", "fill_tests::reduced_test_case_08", "fill_tests::reduced_test_case_11", "fill_tests::reduced_test_case_12", "fill_tests::reduced_test_case_07", "fill_tests::reduced_test_case_06", "fill_tests::reduced_test_case_01", "fill_tests::reduced_test_case_09", "fill_tests::reduced_test_case_05", "fill_tests::reduced_test_case_02", "fill_tests::test_chained_merge_left", "fill_tests::new_tess_merge", "fill_tests::new_tess_points_too_close", "fill_tests::reduced_test_case_10", "fill_tests::test_chained_merge_end", "fill_tests::test_auto_intersection_type1", "fill_tests::test_coincident_simple_2", "fill_tests::test_colinear_3", "fill_tests::test_colinear_touching_squares3", "fill_tests::test_chained_merge_split", "fill_tests::test_close_at_first_position", "fill_tests::test_coincident_simple_1", "fill_tests::test_chained_merge_merge", "fill_tests::reduced_test_case_03", "fill_tests::test_auto_intersection_type2", "fill_tests::test_colinear_4", "fill_tests::test_colinear_touching_squares", "fill_tests::test_colinear_touching_squares2", "fill_tests::test_double_merge_with_intersection", "fill_tests::test_exp_no_intersection_01", "fill_tests::test_empty_path", "fill_tests::test_fixed_to_f32_precision", "fill_tests::test_identical_squares", "fill_tests::reduced_test_case_13", "fill_tests::test_no_close", "fill_tests::test_intersection_horizontal_precision", "fill_tests::test_intersection_1", "fill_tests::test_overlapping_with_intersection", "fill_tests::test_point_on_edge_left", "fill_tests::test_intersecting_bow_tie", "earcut_tests::water_2", "fill_tests::test_rust_logo_scale_down2", "fill_tests::test_point_on_edge2", "fill_tests::test_simple_double_merge", "fill_tests::test_point_on_edge_right", "earcut_tests::water_4", "fill_tests::test_coincident_simple_rotated", "fill_tests::test_colinear_touching_squares_rotated", "fill_tests::test_intersecting_star_shape", "fill_tests::test_simple_monotone", "event_queue::test_logo", "fill_tests::test_colinear_2", "fill_tests::test_too_many_vertices", "fill_tests::test_split_with_intersections", "fuzz_tests::fuzzing_test_case_10", "fill_tests::three_edges_below", "fill_tests::triangle", "fill_tests::test_unknown_issue_1", "fill_tests::test_colinear_1", "fuzz_tests::fuzzing_test_case_11", "fill_tests::test_simple_triangle", "fuzz_tests::fuzzing_test_case_12", "fill_tests::test_rust_logo_scale_down", "fuzz_tests::fuzzing_test_case_15", "fuzz_tests::fuzzing_test_case_17", "fuzz_tests::fuzzing_test_case_18", "fuzz_tests::fuzzing_test_case_14", "fuzz_tests::fuzzing_test_case_20", "fuzz_tests::fuzzing_test_case_21", "fuzz_tests::fuzzing_test_case_13", "fuzz_tests::fuzzing_test_case_16", "earcut_tests::water", "fuzz_tests::fuzzing_test_case_19", "fuzz_tests::fuzzing_test_case_22", "fuzz_tests::fuzzing_test_case_23", "fuzz_tests::fuzzing_test_case_25", "fuzz_tests::fuzzing_test_case_4", "fuzz_tests::fuzzing_test_case_6", "fuzz_tests::fuzzing_test_case_7", "fuzz_tests::fuzzing_test_case_8", "fuzz_tests::fuzzing_test_case_5", "fill_tests::test_auto_intersection_multi", "fuzz_tests::fuzzing_test_case_3", "math_utils::test_compute_normal", "fuzz_tests::fuzzing_test_case_9", "monotone::test_monotone_tess", "stroke::test_empty_caps", "fuzz_tests::fuzzing_test_case_24", "stroke::stroke_vertex_source_01", "fuzz_tests::fuzzing_test_case_26", "stroke::test_square", "stroke::test_too_many_vertices", "stroke::test_empty_path", "test_with_miter_limit", "fill_tests::test_rust_logo_scale_up", "test_with_invalid_miter_limit - should panic", "test_without_miter_limit", "fuzz_tests::fuzzing_test_case_01", "fuzz_tests::fuzzing_test_case_2", "fill_tests::test_degenerate_same_position", "fill_tests::test_simple_1", "fill_tests::test_simple_split", "fill_tests::test_simple_merge_split", "fill_tests::test_simple_aligned", "fill_tests::test_hole_1", "fill_tests::test_simple_2", "earcut_tests::water_huge", "earcut_tests::water_huge_2", "fill_tests::n_segments_intersecting", "fill_tests::test_rust_logo_no_intersection", "fill_tests::test_rust_logo_with_intersection", "fill_tests::very_large_path", "tessellation/src/geometry_builder.rs - geometry_builder (line 202)", "tessellation/src/geometry_builder.rs - geometry_builder (line 131)", "tessellation/src/fill.rs - fill::FillTessellator (line 336)", "tessellation/src/fill.rs - fill::FillTessellator (line 378)", "tessellation/src/geometry_builder.rs - geometry_builder (line 72)", "tessellation/src/stroke.rs - stroke::StrokeTessellator (line 44)" ]
[]
[]
2020-01-12T20:54:59Z
4429c2aad3f900fd33a8a64e62e8e9da97ffaf1e
diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -7,7 +7,7 @@ use crate::path::builder::{Build, PathBuilder}; use crate::path::private::DebugValidator; use crate::path::{AttributeStore, EndpointId, IdEvent, PathEvent, PathSlice, PositionStore, Winding}; use crate::path::polygon::Polygon; -use crate::{GeometryBuilderError, StrokeGeometryBuilder, VertexId}; +use crate::{StrokeGeometryBuilder, VertexId}; use crate::{ LineCap, LineJoin, Order, Side, StrokeOptions, TessellationError, TessellationResult, VertexSource, diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -270,17 +270,10 @@ macro_rules! add_vertex { position += $builder.attributes.normal * $builder.options.line_width / 2.0; } - let res = $builder - .output - .add_stroke_vertex(position, StrokeAttributes(&mut $builder.attributes)); - - match res { - Ok(v) => v, - Err(e) => { - $builder.builder_error(e); - VertexId(0) - } - } + $builder.output.add_stroke_vertex( + position, + StrokeAttributes(&mut $builder.attributes) + ) }}; } diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -334,10 +327,14 @@ impl<'l> PathBuilder for StrokeBuilder<'l> { fn end(&mut self, close: bool) { self.validator.end(); + if self.error.is_some() { + return; + } + if close { self.close(); } else { - self.end_subpath(); + self.end(); } } diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -501,7 +498,7 @@ impl<'l> StrokeBuilder<'l> { } #[cold] - fn builder_error(&mut self, e: GeometryBuilderError) { + fn error<E: Into<TessellationError>>(&mut self, e: E) { if self.error.is_none() { self.error = Some(e.into()); } diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -570,10 +567,14 @@ impl<'l> StrokeBuilder<'l> { if close { self.close(); } else { - self.end_subpath(); + self.end(); } } } + + if self.error.is_some() { + return; + } } } diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -596,11 +597,17 @@ impl<'l> StrokeBuilder<'l> { if (self.first - self.current).square_length() > threshold { let first = self.first; self.edge_to(first, self.first_endpoint, 1.0, true); + if self.error.is_some() { + return; + } } if self.nth > 1 { let second = self.second; self.edge_to(second, self.second_endpoint, self.second_t, true); + if self.error.is_some() { + return; + } self.attributes.normal = self.previous_normal; self.attributes.side = Side::Left; diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -610,12 +617,24 @@ impl<'l> StrokeBuilder<'l> { self.attributes.advancement = self.sub_path_start_length; self.attributes.buffer_is_valid = false; - let first_left_id = add_vertex!(self, position: self.previous); + let first_left_id = match add_vertex!(self, position: self.previous) { + Ok(id) => id, + Err(e) => { + self.error(e); + return; + } + }; self.attributes.normal = -self.previous_normal; self.attributes.side = Side::Right; - let first_right_id = add_vertex!(self, position: self.previous); + let first_right_id = match add_vertex!(self, position: self.previous) { + Ok(id) => id, + Err(e) => { + self.error(e); + return; + } + }; self.output .add_triangle(first_right_id, first_left_id, self.second_right_id); diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -626,49 +645,57 @@ impl<'l> StrokeBuilder<'l> { self.sub_path_start_length = self.length; } - fn tessellate_empty_square_cap(&mut self) { + fn tessellate_empty_square_cap(&mut self) -> Result<(), TessellationError> { self.attributes.normal = vector(1.0, 1.0); self.attributes.side = Side::Right; - let a = add_vertex!(self, position: self.current); + let a = add_vertex!(self, position: self.current)?; self.attributes.normal = vector(1.0, -1.0); self.attributes.side = Side::Left; - let b = add_vertex!(self, position: self.current); + let b = add_vertex!(self, position: self.current)?; self.attributes.normal = vector(-1.0, -1.0); self.attributes.side = Side::Left; - let c = add_vertex!(self, position: self.current); + let c = add_vertex!(self, position: self.current)?; self.attributes.normal = vector(-1.0, 1.0); self.attributes.side = Side::Right; - let d = add_vertex!(self, position: self.current); + let d = add_vertex!(self, position: self.current)?; self.output.add_triangle(a, b, c); self.output.add_triangle(a, c, d); + + Ok(()) } - fn tessellate_empty_round_cap(&mut self) { + fn tessellate_empty_round_cap(&mut self) -> Result<(), TessellationError> { let center = self.current; self.attributes.normal = vector(-1.0, 0.0); self.attributes.side = Side::Left; - let left_id = add_vertex!(self, position: center); + let left_id = add_vertex!(self, position: center)?; self.attributes.normal = vector(1.0, 0.0); self.attributes.side = Side::Right; - let right_id = add_vertex!(self, position: center); + let right_id = add_vertex!(self, position: center)?; + + self.tessellate_round_cap(center, vector(0.0, -1.0), left_id, right_id, true)?; + self.tessellate_round_cap(center, vector(0.0, 1.0), left_id, right_id, false) + } - self.tessellate_round_cap(center, vector(0.0, -1.0), left_id, right_id, true); - self.tessellate_round_cap(center, vector(0.0, 1.0), left_id, right_id, false); + fn end(&mut self) { + if let Err(e) = self.end_subpath() { + self.error(e); + } } - fn end_subpath(&mut self) { + fn end_subpath(&mut self) -> Result<(), TessellationError> { self.attributes.src = VertexSource::Endpoint { id: self.current_endpoint, }; diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -681,11 +708,11 @@ impl<'l> StrokeBuilder<'l> { LineCap::Square => { // Even if there is no edge, if we are using square caps we have to place a square // at the current position. - self.tessellate_empty_square_cap(); + self.tessellate_empty_square_cap()?; } LineCap::Round => { // Same thing for round caps. - self.tessellate_empty_round_cap(); + self.tessellate_empty_round_cap()?; } _ => {} } diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -702,13 +729,17 @@ impl<'l> StrokeBuilder<'l> { } let p = self.current + d; self.edge_to(p, self.previous_endpoint, 1.0, true); + if let Some(e) = &self.error { + return Err(e.clone()); + } + // Restore the real current position. self.current = current; if self.options.end_cap == LineCap::Round { let left_id = self.previous_left_id; let right_id = self.previous_right_id; - self.tessellate_round_cap(current, d, left_id, right_id, false); + self.tessellate_round_cap(current, d, left_id, right_id, false)?; } } // first edge diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -728,15 +759,15 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = n1; self.attributes.side = Side::Left; - let first_left_id = add_vertex!(self, position: first); + let first_left_id = add_vertex!(self, position: first)?; self.attributes.normal = n2; self.attributes.side = Side::Right; - let first_right_id = add_vertex!(self, position: first); + let first_right_id = add_vertex!(self, position: first)?; if self.options.start_cap == LineCap::Round { - self.tessellate_round_cap(first, d, first_left_id, first_right_id, true); + self.tessellate_round_cap(first, d, first_left_id, first_right_id, true)?; } self.output diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -744,6 +775,8 @@ impl<'l> StrokeBuilder<'l> { self.output .add_triangle(first_left_id, self.second_left_id, self.second_right_id); } + + Ok(()) } fn edge_to(&mut self, to: Point, endpoint: EndpointId, t: f32, with_join: bool) { diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -751,6 +784,10 @@ impl<'l> StrokeBuilder<'l> { return; } + if self.error.is_some() { + return; + } + if self.nth == 0 { // We don't have enough information to compute the previous // vertices (and thus the current join) yet. diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -770,8 +807,19 @@ impl<'l> StrokeBuilder<'l> { LineJoin::Miter }; - let (start_left_id, start_right_id, end_left_id, end_right_id, front_side) = - self.tessellate_join(previous_edge, next_edge, join_type); + let ( + start_left_id, + start_right_id, + end_left_id, + end_right_id, + front_side + ) = match self.tessellate_join(previous_edge, next_edge, join_type) { + Ok(value) => value, + Err(e) => { + self.error(e); + return; + } + }; // Tessellate the edge if self.nth > 1 { diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -824,10 +872,10 @@ impl<'l> StrokeBuilder<'l> { left: VertexId, right: VertexId, is_start: bool, - ) { + ) -> Result<(), TessellationError> { let radius = self.options.line_width.abs(); if radius < 1e-4 { - return; + return Ok(()); } let arc_len = 0.5 * PI * radius; diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -845,7 +893,7 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = dir; self.attributes.side = Side::Left; - let mid_vertex = add_vertex!(self, position: center); + let mid_vertex = add_vertex!(self, position: center)?; let (v1, v2, v3) = if is_start { (left, right, mid_vertex) diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -860,7 +908,7 @@ impl<'l> StrokeBuilder<'l> { 0.0 }; - if let Err(e) = tess_round_cap( + tess_round_cap( center, (left_angle, mid_angle), radius, diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -872,10 +920,9 @@ impl<'l> StrokeBuilder<'l> { !is_start, &mut self.attributes, self.output, - ) { - self.builder_error(e); - } - if let Err(e) = tess_round_cap( + )?; + + tess_round_cap( center, (mid_angle, right_angle), radius, diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -887,9 +934,7 @@ impl<'l> StrokeBuilder<'l> { !is_start, &mut self.attributes, self.output, - ) { - self.builder_error(e); - } + ) } fn tessellate_back_join( diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -900,7 +945,7 @@ impl<'l> StrokeBuilder<'l> { next_length: f32, front_side: Side, front_normal: Vector, - ) -> (VertexId, VertexId, Option<Order>) { + ) -> Result<(VertexId, VertexId, Option<Order>), TessellationError> { // We must watch out for special cases where the previous or next edge is small relative // to the line width inducing an overlap of the stroke of both edges. diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -931,27 +976,28 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = back_start_vertex_normal; self.attributes.side = front_side.opposite(); - let back_start_vertex = add_vertex!(self, position: self.current); + let back_start_vertex = add_vertex!(self, position: self.current)?; self.attributes.normal = back_end_vertex_normal; self.attributes.side = front_side.opposite(); - let back_end_vertex = add_vertex!(self, position: self.current); - // return - return match order { + let back_end_vertex = add_vertex!(self, position: self.current)?; + + return Ok(match order { Order::Before => (back_start_vertex, back_end_vertex, Some(order)), Order::After => (back_end_vertex, back_start_vertex, Some(order)), - }; + }); } self.attributes.normal = -front_normal; self.attributes.side = front_side.opposite(); // Standard Case - let back_start_vertex = add_vertex!(self, position: self.current); + let back_start_vertex = add_vertex!(self, position: self.current)?; let back_end_vertex = back_start_vertex; - (back_start_vertex, back_end_vertex, None) + + Ok((back_start_vertex, back_end_vertex, None)) } fn tessellate_join( diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -959,7 +1005,7 @@ impl<'l> StrokeBuilder<'l> { previous_edge: Vector, next_edge: Vector, mut join_type: LineJoin, - ) -> (VertexId, VertexId, VertexId, VertexId, Side) { + ) -> Result<(VertexId, VertexId, VertexId, VertexId, Side), TessellationError> { // This function needs to differentiate the "front" of the join (aka. the pointy side) // from the back. The front is where subdivision or adjustments may be needed. let prev_tangent = previous_edge.normalize(); diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -999,7 +1045,7 @@ impl<'l> StrokeBuilder<'l> { next_edge_length, front_side, front_normal, - ); + )?; let threshold = 0.95; if prev_tangent.dot(next_tangent) >= threshold { diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1026,10 +1072,10 @@ impl<'l> StrokeBuilder<'l> { let (start_vertex, end_vertex) = match join_type { LineJoin::Round => { - self.tessellate_round_join(prev_tangent, next_tangent, front_side, back_join_vertex) + self.tessellate_round_join(prev_tangent, next_tangent, front_side, back_join_vertex)? } LineJoin::Bevel => { - self.tessellate_bevel_join(prev_tangent, next_tangent, front_side, back_join_vertex) + self.tessellate_bevel_join(prev_tangent, next_tangent, front_side, back_join_vertex)? } LineJoin::MiterClip => self.tessellate_miter_clip_join( prev_tangent, diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1037,12 +1083,12 @@ impl<'l> StrokeBuilder<'l> { front_side, back_join_vertex, normal, - ), + )?, // Fallback to Miter for unimplemented line joins _ => { self.attributes.normal = front_normal; self.attributes.side = front_side; - let end_vertex = add_vertex!(self, position: self.current); + let end_vertex = add_vertex!(self, position: self.current)?; self.previous_normal = normal; if let Some(_order) = order { diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1058,7 +1104,7 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = n1; self.attributes.side = front_side; - let start_vertex = add_vertex!(self, position: self.current); + let start_vertex = add_vertex!(self, position: self.current)?; self.output .add_triangle(start_vertex, end_vertex, back_join_vertex); diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1088,7 +1134,7 @@ impl<'l> StrokeBuilder<'l> { } } - match front_side { + Ok(match front_side { Side::Left => ( start_vertex, back_start_vertex, diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1103,7 +1149,7 @@ impl<'l> StrokeBuilder<'l> { end_vertex, front_side, ), - } + }) } fn tessellate_bevel_join( diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1112,7 +1158,7 @@ impl<'l> StrokeBuilder<'l> { next_tangent: Vector, front_side: Side, back_vertex: VertexId, - ) -> (VertexId, VertexId) { + ) -> Result<(VertexId, VertexId), TessellationError> { let neg_if_right = if front_side.is_left() { 1.0 } else { -1.0 }; let previous_normal = vector(-prev_tangent.y, prev_tangent.x); let next_normal = vector(-next_tangent.y, next_tangent.x); diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1120,12 +1166,12 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = previous_normal * neg_if_right; self.attributes.side = front_side; - let start_vertex = add_vertex!(self, position: self.current); + let start_vertex = add_vertex!(self, position: self.current)?; self.attributes.normal = next_normal * neg_if_right; self.attributes.side = front_side; - let last_vertex = add_vertex!(self, position: self.current); + let last_vertex = add_vertex!(self, position: self.current)?; self.previous_normal = next_normal; diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1136,7 +1182,7 @@ impl<'l> StrokeBuilder<'l> { }; self.output.add_triangle(v1, v2, v3); - (start_vertex, last_vertex) + Ok((start_vertex, last_vertex)) } fn tessellate_round_join( diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1145,7 +1191,7 @@ impl<'l> StrokeBuilder<'l> { next_tangent: Vector, front_side: Side, back_vertex: VertexId, - ) -> (VertexId, VertexId) { + ) -> Result<(VertexId, VertexId), TessellationError> { let join_angle = get_join_angle(prev_tangent, next_tangent); let max_radius_segment_angle = diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1163,7 +1209,7 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = initial_normal; self.attributes.side = front_side; - let mut last_vertex = add_vertex!(self, position: self.current); + let mut last_vertex = add_vertex!(self, position: self.current)?; let start_vertex = last_vertex; // Plot each point along the radius by using a matrix to diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1182,7 +1228,7 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = n; self.attributes.side = front_side; - let current_vertex = add_vertex!(self, position: self.current); + let current_vertex = add_vertex!(self, position: self.current)?; let (v1, v2, v3) = if front_side.is_left() { (back_vertex, last_vertex, current_vertex) diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1196,7 +1242,7 @@ impl<'l> StrokeBuilder<'l> { self.previous_normal = n * neg_if_right; - (start_vertex, last_vertex) + Ok((start_vertex, last_vertex)) } fn tessellate_miter_clip_join( diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1206,7 +1252,7 @@ impl<'l> StrokeBuilder<'l> { front_side: Side, back_vertex: VertexId, normal: Vector, - ) -> (VertexId, VertexId) { + ) -> Result<(VertexId, VertexId), TessellationError> { let neg_if_right = if front_side.is_left() { 1.0 } else { -1.0 }; let previous_normal: Vector = vector(-prev_tangent.y, prev_tangent.x); let next_normal: Vector = vector(-next_tangent.y, next_tangent.x); diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1216,12 +1262,12 @@ impl<'l> StrokeBuilder<'l> { self.attributes.normal = v1 * neg_if_right; self.attributes.side = front_side; - let start_vertex = add_vertex!(self, position: self.current); + let start_vertex = add_vertex!(self, position: self.current)?; self.attributes.normal = v2 * neg_if_right; self.attributes.side = front_side; - let last_vertex = add_vertex!(self, position: self.current); + let last_vertex = add_vertex!(self, position: self.current)?; self.previous_normal = normal; diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1232,7 +1278,7 @@ impl<'l> StrokeBuilder<'l> { }; self.output.add_triangle(v1, v2, v3); - (start_vertex, last_vertex) + Ok((start_vertex, last_vertex)) } fn miter_limit_is_exceeded(&self, normal: Vector) -> bool { diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1305,7 +1351,7 @@ fn tess_round_cap( invert_winding: bool, attributes: &mut StrokeAttributesData, output: &mut dyn StrokeGeometryBuilder, -) -> Result<(), GeometryBuilderError> { +) -> Result<(), TessellationError> { if num_recursions == 0 { return Ok(()); }
nical__lyon-579
579
I certainly am! Was it the stroke or fill tessellator? Pretty sure it was the stroke tesselator. It may be useful to know that there were only bezier curves imitating lines (i.e. the control points were identical to the corners) in the builder. There may however have been duplicate points in it. Some more info. I think this might be happening when the index type overflows. The reason is that the add_vertex! macro hides the actual overflow error and just returns a vertex with index 0. This will usually cause some other asserts to trip. ```rust macro_rules! add_vertex { ($builder: expr, position: $position: expr) => {{ let mut position = $position; if $builder.options.apply_line_width { position += $builder.attributes.normal * $builder.options.line_width / 2.0; } let res = $builder.output.add_stroke_vertex( position, StrokeAttributes(&mut $builder.attributes), ); match res { Ok(v) => v, Err(e) => { $builder.builder_error(e); VertexId(0) } } }} } ``` Ouch! The initial intention was to propagate the error but that apparently never materialize. nice catch!
[ "545" ]
0.15
nical/lyon
2020-04-27T22:00:28Z
diff --git a/tessellation/src/stroke.rs b/tessellation/src/stroke.rs --- a/tessellation/src/stroke.rs +++ b/tessellation/src/stroke.rs @@ -1665,12 +1711,14 @@ fn test_too_many_vertices() { } impl GeometryBuilder for Builder { fn begin_geometry(&mut self) {} - fn add_triangle(&mut self, _a: VertexId, _b: VertexId, _c: VertexId) {} + fn add_triangle(&mut self, a: VertexId, b: VertexId, c: VertexId) { + assert!(a != b); + assert!(a != c); + assert!(b != c); + } fn end_geometry(&mut self) -> Count { - Count { - vertices: 0, - indices: 0, - } + // Expected to abort the geometry. + panic!(); } fn abort_geometry(&mut self) {} }
The stroke tessellator does not propagate errors I cannot replicate this, but you might be interested in a panic that i found ``` thread 'main' panicked at 'assertion failed: b != c', tessellation/src/geometry_builder.rs:510:9 ```
08cd4c3d8c1ef53fbbb1b702f655e26c6bd5cc03
[ "stroke::test_too_many_vertices" ]
[ "earcut_tests::bad_diagonal", "earcut_tests::building", "earcut_tests::degenerate", "earcut_tests::bad_hole", "earcut_tests::empty_square", "earcut_tests::eberly_3", "earcut_tests::dude", "earcut_tests::issue_17", "earcut_tests::issue_16", "earcut_tests::hole_touching_outer", "earcut_tests::issue_29", "earcut_tests::issue_45", "earcut_tests::outside_ring", "earcut_tests::issue_34", "earcut_tests::issue_52", "earcut_tests::shared_points", "earcut_tests::self_touching", "earcut_tests::steiner", "earcut_tests::simplified_us_border", "earcut_tests::water_3b", "earcut_tests::touching_holes", "earcut_tests::water_3", "event_queue::test_event_queue_push_sorted", "event_queue::test_event_queue_sort_2", "event_queue::test_event_queue_sort_1", "event_queue::test_event_queue_sort_3", "event_queue::test_event_queue_sort_4", "fill::active_edge_size", "fill::fill_builder_vertex_source", "event_queue::test_event_queue_sort_5", "fill::fill_vertex_source_01", "earcut_tests::hilbert", "fill_tests::issue_529", "fill_tests::issue_562_2", "fill::fill_vertex_source_03", "fill::fill_vertex_source_02", "fill_tests::issue_562_1", "fill_tests::back_along_previous_edge", "fill_tests::new_tess_coincident_simple", "fill_tests::issue_481_reduced", "earcut_tests::eberly_6", "fill_tests::issue_476_reduced", "fill_tests::angle_precision", "fill_tests::issue_500", "fill_tests::new_tess_merge", "fill_tests::overlapping_horizontal", "fill_tests::issue_476_original", "fill_tests::new_tess_1", "fill_tests::issue_562_4", "fill_tests::issue_562_6", "fill_tests::issue_562_7", "fill_tests::new_tess_overlapping_1", "earcut_tests::water_4", "fill_tests::reduced_test_case_01", "fill_tests::reduced_test_case_03", "fill_tests::reduced_test_case_04", "fill_tests::issue_562_5", "fill_tests::new_tess_points_too_close", "fill_tests::reduced_test_case_11", "fill_tests::reduced_test_case_12", "fill_tests::reduced_test_case_06", "fill_tests::reduced_test_case_07", "fill_tests::reduced_test_case_08", "fill_tests::reduced_test_case_13", "fill_tests::reduced_test_case_14", "fill_tests::test_auto_intersection_type1", "fill_tests::new_tess_2", "fill_tests::issue_562_3", "fill_tests::reduced_test_case_02", "fill_tests::reduced_test_case_10", "fill_tests::reduced_test_case_09", "event_queue::test_logo", "fill_tests::issue_518_1", "earcut_tests::issue_35", "fill_tests::issue_481_original", "fill_tests::test_auto_intersection_type2", "fill_tests::test_chained_merge_end", "fill_tests::issue_518_2", "fill_tests::test_coincident_simple_1", "fill_tests::test_coincident_simple_2", "fill_tests::test_empty_path", "fill_tests::test_chained_merge_merge", "fill_tests::test_double_merge_with_intersection", "fill_tests::test_chained_merge_split", "fill_tests::test_exp_no_intersection_01", "fill_tests::test_chained_merge_left", "fill_tests::test_colinear_3", "fill_tests::test_colinear_4", "fill_tests::test_colinear_touching_squares", "fill_tests::test_colinear_touching_squares2", "fill_tests::test_colinear_touching_squares3", "fill_tests::reduced_test_case_05", "fill_tests::test_close_at_first_position", "earcut_tests::water_2", "fill_tests::test_identical_squares", "fill_tests::test_intersecting_bow_tie", "fill_tests::test_fixed_to_f32_precision", "fill_tests::test_intersection_1", "fill_tests::test_intersection_horizontal_precision", "fill_tests::test_point_on_edge_right", "fill_tests::test_overlapping_with_intersection", "fill_tests::test_point_on_edge2", "fill_tests::test_no_close", "fill_tests::test_point_on_edge_left", "fill_tests::test_colinear_1", "fill_tests::test_colinear_2", "fill_tests::issue_562_8", "fill_tests::test_simple_double_merge", "fill_tests::test_simple_monotone", "fill_tests::test_unknown_issue_1", "fuzz_tests::fuzzing_test_case_10", "fill_tests::triangle", "fill_tests::test_split_with_intersections", "fuzz_tests::fuzzing_test_case_11", "fuzz_tests::fuzzing_test_case_12", "fill_tests::test_too_many_vertices", "fill_tests::three_edges_below", "fuzz_tests::fuzzing_test_case_13", "fuzz_tests::fuzzing_test_case_17", "fuzz_tests::fuzzing_test_case_15", "fuzz_tests::fuzzing_test_case_18", "fuzz_tests::fuzzing_test_case_20", "fuzz_tests::fuzzing_test_case_19", "fuzz_tests::fuzzing_test_case_14", "fuzz_tests::fuzzing_test_case_22", "fuzz_tests::fuzzing_test_case_21", "fuzz_tests::fuzzing_test_case_24", "fuzz_tests::fuzzing_test_case_6", "fuzz_tests::fuzzing_test_case_4", "fuzz_tests::fuzzing_test_case_26", "fuzz_tests::fuzzing_test_case_25", "fuzz_tests::fuzzing_test_case_16", "fuzz_tests::fuzzing_test_case_7", "earcut_tests::water", "math_utils::test_compute_normal", "stroke::stroke_vertex_source_01", "fill_tests::test_coincident_simple_rotated", "monotone::test_monotone_tess", "fuzz_tests::fuzzing_test_case_9", "fuzz_tests::fuzzing_test_case_8", "stroke::test_empty_caps", "fuzz_tests::fuzzing_test_case_23", "stroke::test_empty_path", "fill_tests::test_simple_triangle", "test_with_miter_limit", "fuzz_tests::fuzzing_test_case_5", "stroke::test_square", "test_without_miter_limit", "test_with_invalid_miter_limit - should panic", "fill_tests::test_colinear_touching_squares_rotated", "fill_tests::test_rust_logo_scale_down", "fill_tests::test_rust_logo_scale_down2", "fuzz_tests::fuzzing_test_case_3", "fuzz_tests::fuzzing_test_case_2", "fill_tests::test_degenerate_same_position", "fuzz_tests::fuzzing_test_case_01", "fill_tests::test_auto_intersection_multi", "fill_tests::test_intersecting_star_shape", "fill_tests::test_rust_logo_scale_up", "fill_tests::test_simple_split", "earcut_tests::water_huge", "fill_tests::test_simple_merge_split", "fill_tests::test_hole_1", "fill_tests::test_simple_aligned", "fill_tests::test_simple_1", "earcut_tests::water_huge_2", "fill_tests::test_simple_2", "fill_tests::very_large_path", "fill_tests::n_segments_intersecting", "fill_tests::test_rust_logo_no_intersection", "fill_tests::test_rust_logo_with_intersection", "tessellation/src/geometry_builder.rs - geometry_builder (line 205)", "tessellation/src/stroke.rs - stroke::StrokeTessellator::builder (line 172)", "tessellation/src/geometry_builder.rs - geometry_builder (line 131)", "tessellation/src/fill.rs - fill::FillTessellator::builder (line 630)", "tessellation/src/stroke.rs - stroke::StrokeTessellator (line 48)", "tessellation/src/geometry_builder.rs - geometry_builder (line 72)", "tessellation/src/fill.rs - fill::FillTessellator (line 390)", "tessellation/src/fill.rs - fill::FillTessellator (line 348)" ]
[]
[]
2020-04-28T19:52:35Z
4651f1b20b508aeb3cd79e0d9252803e7325afa8
diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -432,7 +432,7 @@ name = "geom_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -781,13 +781,13 @@ dependencies = [ [[package]] name = "lyon" -version = "0.15.1" +version = "0.15.3" dependencies = [ "lyon_algorithms 0.15.0", "lyon_extra 0.15.0", "lyon_svg 0.15.0", "lyon_tess2 0.15.0", - "lyon_tessellation 0.15.2", + "lyon_tessellation 0.15.3", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -809,7 +809,7 @@ dependencies = [ "gfx_window_glutin 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -862,14 +862,14 @@ dependencies = [ name = "lyon_tess2" version = "0.15.0" dependencies = [ - "lyon_tessellation 0.15.2", + "lyon_tessellation 0.15.3", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "tess2-sys 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lyon_tessellation" -version = "0.15.2" +version = "0.15.3" dependencies = [ "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lyon_extra 0.15.0", diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,7 +1117,7 @@ dependencies = [ "gfx_device_gl 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_window_glutin 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1125,7 +1125,7 @@ name = "path_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", ] [[package]] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1584,7 +1584,7 @@ name = "svg-rendering-example" version = "0.1.0" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", "usvg 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu-native 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1683,7 +1683,7 @@ name = "tess_bench" version = "0.0.1" dependencies = [ "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon 0.15.1", + "lyon 0.15.3", "tess2-sys 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -1930,7 +1930,7 @@ dependencies = [ name = "wgpu-example" version = "0.1.0" dependencies = [ - "lyon 0.15.1", + "lyon 0.15.3", "wgpu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu-native 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.20.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lyon" -version = "0.15.1" +version = "0.15.3" description = "2D Graphics rendering on the GPU using tessellation." authors = [ "Nicolas Silva <nical@fastmail.com>" ] repository = "https://github.com/nical/lyon" diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ libtess2 = ["lyon_tess2"] [dependencies] -lyon_tessellation = { version = "0.15.0", path = "tessellation/" } +lyon_tessellation = { version = "0.15.3", path = "tessellation/" } lyon_algorithms = { version = "0.15.0", path = "algorithms/" } lyon_extra = { version = "0.15.0", optional = true, path = "extra/" } lyon_svg = { version = "0.15.0", optional = true, path = "svg/" } diff --git a/tessellation/Cargo.toml b/tessellation/Cargo.toml --- a/tessellation/Cargo.toml +++ b/tessellation/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lyon_tessellation" -version = "0.15.2" +version = "0.15.3" description = "A low level path tessellation library." authors = [ "Nicolas Silva <nical@fastmail.com>" ] repository = "https://github.com/nical/lyon" diff --git a/tessellation/Cargo.toml b/tessellation/Cargo.toml --- a/tessellation/Cargo.toml +++ b/tessellation/Cargo.toml @@ -22,7 +22,7 @@ experimental = [] [dependencies] -lyon_path = { version = "0.15.0", path = "../path" } +lyon_path = { version = "0.15.1", path = "../path" } sid = "0.6" serde = { version = "1.0", optional = true, features = ["serde_derive"] } arrayvec = "0.5" diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1723,6 +1723,7 @@ impl<'l> FillAttributes<'l> { VertexSourceIterator { events: self.events, id: self.current_event, + prev: None, } } diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1761,53 +1762,73 @@ impl<'l> FillAttributes<'l> { let store = self.attrib_store.unwrap(); - let second = self.events.next_sibling_id(self.current_event); - if !self.events.valid_id(second) { - let edge = &self.events.edge_data[self.current_event as usize]; - let t = edge.range.start; - if t == 0.0 { - return store.get(edge.from_id); - } - if t == 1.0 { - return store.get(edge.to_id); - } - } + let mut sources = VertexSourceIterator { + events: self.events, + id: self.current_event, + prev: None, + }; let num_attributes = store.num_attributes(); - assert!(self.attrib_buffer.len() == num_attributes); - // First source taken out of the loop to avoid initializing the buffer. - { - let edge = &self.events.edge_data[self.current_event as usize]; - let t = edge.range.start; + let first = sources.next().unwrap(); + let mut next = sources.next(); - let a = store.get(edge.from_id); - let b = store.get(edge.to_id); + // Fast path for the single-source-single-endpoint common case. + if next.is_none() { + if let VertexSource::Endpoint { id } = first { + return store.get(id); + } + } - assert!(a.len() == num_attributes); - assert!(b.len() == num_attributes); - for i in 0..num_attributes { - self.attrib_buffer[i] = a[i] * (1.0 - t) + b[i] * t; + // First source taken out of the loop to avoid initializing the buffer. + match first { + VertexSource::Endpoint { id } => { + let a = store.get(id); + assert!(a.len() == num_attributes); + assert!(self.attrib_buffer.len() == num_attributes); + for i in 0..num_attributes { + self.attrib_buffer[i] = a[i]; + } + } + VertexSource::Edge { from, to, t } => { + let a = store.get(from); + let b = store.get(to); + assert!(a.len() == num_attributes); + assert!(b.len() == num_attributes); + assert!(self.attrib_buffer.len() == num_attributes); + for i in 0..num_attributes { + self.attrib_buffer[i] = a[i] * (1.0 - t) + b[i] * t; + } } } let mut div = 1.0; - let mut current_sibling = second; - while self.events.valid_id(current_sibling) { - let edge = &self.events.edge_data[current_sibling as usize]; - let t = edge.range.start; - - let a = store.get(edge.from_id); - let b = store.get(edge.to_id); - - assert!(a.len() == num_attributes); - assert!(b.len() == num_attributes); - for i in 0..num_attributes { - self.attrib_buffer[i] += a[i] * (1.0 - t) + b[i] * t; + loop { + match next { + Some(VertexSource::Endpoint { id }) => { + let a = store.get(id); + assert!(a.len() == num_attributes); + assert!(self.attrib_buffer.len() == num_attributes); + for i in 0..num_attributes { + self.attrib_buffer[i] += a[i]; + } + } + Some(VertexSource::Edge { from, to, t }) => { + let a = store.get(from); + let b = store.get(to); + assert!(a.len() == num_attributes); + assert!(b.len() == num_attributes); + assert!(self.attrib_buffer.len() == num_attributes); + for i in 0..num_attributes { + self.attrib_buffer[i] += a[i] * (1.0 - t) + b[i] * t; + } + } + None => { + break; + } } - div += 1.0; - current_sibling = self.events.next_sibling_id(current_sibling); + next = sources.next(); } if div > 1.0 { diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -1825,32 +1846,44 @@ impl<'l> FillAttributes<'l> { pub struct VertexSourceIterator<'l> { events: &'l EventQueue, id: TessEventId, + prev: Option<VertexSource>, } impl<'l> Iterator for VertexSourceIterator<'l> { type Item = VertexSource; + #[inline] fn next(&mut self) -> Option<VertexSource> { - if self.id == INVALID_EVENT_ID { - return None; - } + let mut src; + loop { + if self.id == INVALID_EVENT_ID { + return None; + } - let edge = &self.events.edge_data[self.id as usize]; + let edge = &self.events.edge_data[self.id as usize]; - self.id = self.events.next_sibling_id(self.id); + self.id = self.events.next_sibling_id(self.id); - let t = edge.range.start; + let t = edge.range.start; - if t == 0.0 { - Some(VertexSource::Endpoint { id: edge.from_id }) - } else if t == 1.0 { - Some(VertexSource::Endpoint { id: edge.to_id }) - } else { - Some(VertexSource::Edge { - from: edge.from_id, - to: edge.to_id, - t, - }) + src = if t == 0.0 { + Some(VertexSource::Endpoint { id: edge.from_id }) + } else if t == 1.0 { + Some(VertexSource::Endpoint { id: edge.to_id }) + } else { + Some(VertexSource::Edge { + from: edge.from_id, + to: edge.to_id, + t, + }) + }; + + if src != self.prev { + break; + } } + + self.prev = src; + src } }
nical__lyon-520
520
[ "517" ]
0.15
nical/lyon
2019-12-28T12:17:48Z
diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -882,7 +882,7 @@ dependencies = [ name = "lyon_wasm_test" version = "0.11.0" dependencies = [ - "lyon 0.15.1", + "lyon 0.15.3", ] [[package]] diff --git a/tessellation/src/fill.rs b/tessellation/src/fill.rs --- a/tessellation/src/fill.rs +++ b/tessellation/src/fill.rs @@ -2122,3 +2155,86 @@ fn fill_vertex_source_02() { } } } + +#[test] +fn fill_vertex_source_03() { + use crate::path::commands::PathCommands; + use crate::path::AttributeSlice; + + // x---x + // \ / + // x <--- + // / \ + // x---x + // + // check that the attribute interpolation is weighted correctly at + // start events. + + let endpoints: &[Point] = &[ + point(0.0, 0.0), + point(2.0, 0.0), + point(1.0, 1.0), + point(0.0, 2.0), + point(2.0, 2.0), + point(1.0, 1.0), + ]; + + let attributes = &[0.0, 0.0, 1.0, 0.0, 0.0, 2.0]; + + let mut cmds = PathCommands::builder(); + cmds.move_to(EndpointId(0)); + cmds.line_to(EndpointId(1)); + cmds.line_to(EndpointId(2)); + cmds.close(); + cmds.move_to(EndpointId(3)); + cmds.line_to(EndpointId(4)); + cmds.line_to(EndpointId(5)); + cmds.close(); + + let cmds = cmds.build(); + + let mut queue = EventQueue::from_path_with_ids( + 0.1, + FillOptions::DEFAULT_SWEEP_ORIENTATION, + cmds.id_events(), + &(endpoints, endpoints), + ); + + let mut tess = FillTessellator::new(); + tess.tessellate_events( + &mut queue, + Some(&AttributeSlice::new(attributes, 1)), + &FillOptions::default(), + &mut CheckVertexSources { next_vertex: 0 }, + ).unwrap(); + + struct CheckVertexSources { + next_vertex: u32, + } + + impl GeometryBuilder for CheckVertexSources { + fn begin_geometry(&mut self) {} + fn end_geometry(&mut self) -> Count { Count { vertices: self.next_vertex, indices: 0 } } + fn abort_geometry(&mut self) {} + fn add_triangle(&mut self, _: VertexId, _: VertexId, _: VertexId) {} + } + + impl FillGeometryBuilder for CheckVertexSources { + fn add_fill_vertex(&mut self, v: Point, mut attr: FillAttributes) -> Result<VertexId, GeometryBuilderError> { + if eq(v, point(1.0, 1.0)) { + assert_eq!(attr.interpolated_attributes(), &[1.5]); + assert_eq!(attr.sources().count(), 2); + } + else { + assert_eq!(attr.interpolated_attributes(), &[0.0]); + assert_eq!(attr.sources().count(), 1); + } + + let id = self.next_vertex; + self.next_vertex += 1; + + Ok(VertexId(id)) + } + } +} +
The vertex source iterator can visit the same endpoint twice in some cases. For start events for example, it can happen for the endpoint to be visited once for each of its edges.
08cd4c3d8c1ef53fbbb1b702f655e26c6bd5cc03
[ "fill::fill_vertex_source_03" ]
[ "basic_shapes::issue_366", "earcut_tests::bad_diagonal", "earcut_tests::building", "earcut_tests::degenerate", "earcut_tests::bad_hole", "earcut_tests::eberly_3", "earcut_tests::dude", "earcut_tests::empty_square", "earcut_tests::hole_touching_outer", "earcut_tests::issue_16", "earcut_tests::issue_17", "earcut_tests::issue_29", "earcut_tests::issue_45", "earcut_tests::issue_52", "earcut_tests::issue_34", "earcut_tests::shared_points", "earcut_tests::outside_ring", "earcut_tests::hilbert", "earcut_tests::steiner", "earcut_tests::self_touching", "earcut_tests::touching_holes", "earcut_tests::simplified_us_border", "earcut_tests::water_3b", "earcut_tests::water_3", "earcut_tests::issue_35", "event_queue::test_event_queue_push_sorted", "earcut_tests::eberly_6", "event_queue::test_event_queue_sort_3", "event_queue::test_event_queue_sort_2", "event_queue::test_event_queue_sort_5", "event_queue::test_event_queue_sort_4", "fill::fill_vertex_source_01", "fill::fill_vertex_source_02", "event_queue::test_event_queue_sort_1", "fill_tests::issue_481_reduced", "event_queue::test_logo", "fill_tests::issue_500", "fill_tests::issue_518_1", "fill_tests::issue_518_2", "fill_tests::new_tess_1", "fill_tests::new_tess_points_too_close", "fill_tests::new_tess_2", "fill_tests::new_tess_coincident_simple", "fill_tests::angle_precision", "earcut_tests::water_2", "fill_tests::back_along_previous_edge", "fill_tests::issue_476_original", "earcut_tests::water_4", "fill_tests::issue_476_reduced", "fill_tests::new_tess_merge", "fill_tests::reduced_test_case_02", "fill_tests::reduced_test_case_01", "fill_tests::reduced_test_case_07", "fill_tests::reduced_test_case_06", "fill_tests::reduced_test_case_05", "fill_tests::issue_481_original", "fill_tests::reduced_test_case_03", "fill_tests::overlapping_horizontal", "fill_tests::reduced_test_case_08", "fill_tests::reduced_test_case_04", "fill_tests::new_tess_overlapping_1", "fill_tests::reduced_test_case_09", "fill_tests::reduced_test_case_11", "fill_tests::reduced_test_case_12", "fill_tests::test_auto_intersection_type1", "fill_tests::test_auto_intersection_type2", "fill_tests::test_chained_merge_end", "fill_tests::test_chained_merge_left", "fill_tests::test_chained_merge_merge", "fill_tests::reduced_test_case_13", "fill_tests::test_chained_merge_split", "fill_tests::reduced_test_case_14", "fill_tests::reduced_test_case_10", "fill_tests::test_close_at_first_position", "fill_tests::test_colinear_4", "fill_tests::test_colinear_touching_squares", "fill_tests::test_colinear_touching_squares2", "fill_tests::test_colinear_touching_squares3", "fill_tests::test_coincident_simple_1", "fill_tests::test_coincident_simple_2", "fill_tests::test_double_merge_with_intersection", "fill_tests::test_exp_no_intersection_01", "fill_tests::test_fixed_to_f32_precision", "fill_tests::test_colinear_3", "fill_tests::test_empty_path", "fill_tests::test_identical_squares", "fill_tests::test_intersection_1", "fill_tests::test_intersecting_bow_tie", "fill_tests::test_intersection_horizontal_precision", "fill_tests::test_overlapping_with_intersection", "fill_tests::test_point_on_edge_right", "fill_tests::test_point_on_edge2", "fill_tests::test_no_close", "fill_tests::test_simple_double_merge", "fill_tests::test_point_on_edge_left", "fill_tests::test_rust_logo_scale_down", "earcut_tests::water", "fuzz_tests::fuzzing_test_case_10", "fill_tests::test_simple_monotone", "fuzz_tests::fuzzing_test_case_11", "fill_tests::three_edges_below", "fill_tests::test_unknown_issue_1", "fill_tests::test_split_with_intersections", "fill_tests::test_colinear_1", "fill_tests::triangle", "fill_tests::test_colinear_2", "fuzz_tests::fuzzing_test_case_17", "fuzz_tests::fuzzing_test_case_18", "fuzz_tests::fuzzing_test_case_13", "fuzz_tests::fuzzing_test_case_12", "fuzz_tests::fuzzing_test_case_15", "fill_tests::test_too_many_vertices", "fuzz_tests::fuzzing_test_case_14", "fuzz_tests::fuzzing_test_case_16", "fill_tests::test_coincident_simple_rotated", "fill_tests::test_colinear_touching_squares_rotated", "fill_tests::test_rust_logo_scale_down2", "fuzz_tests::fuzzing_test_case_19", "fill_tests::test_simple_triangle", "fuzz_tests::fuzzing_test_case_20", "fuzz_tests::fuzzing_test_case_21", "fuzz_tests::fuzzing_test_case_4", "fuzz_tests::fuzzing_test_case_22", "fuzz_tests::fuzzing_test_case_23", "fuzz_tests::fuzzing_test_case_24", "fuzz_tests::fuzzing_test_case_26", "fill_tests::test_auto_intersection_multi", "fuzz_tests::fuzzing_test_case_25", "fuzz_tests::fuzzing_test_case_5", "fuzz_tests::fuzzing_test_case_7", "fuzz_tests::fuzzing_test_case_8", "fuzz_tests::fuzzing_test_case_6", "math_utils::test_compute_normal", "fill_tests::test_intersecting_star_shape", "stroke::stroke_vertex_source_01", "stroke::test_too_many_vertices", "fuzz_tests::fuzzing_test_case_9", "stroke::test_empty_path", "stroke::test_square", "monotone::test_monotone_tess", "stroke::test_empty_caps", "test_with_invalid_miter_limit - should panic", "test_with_miter_limit", "test_without_miter_limit", "fuzz_tests::fuzzing_test_case_01", "fuzz_tests::fuzzing_test_case_3", "fuzz_tests::fuzzing_test_case_2", "fill_tests::test_rust_logo_scale_up", "fill_tests::test_degenerate_same_position", "fill_tests::test_simple_split", "fill_tests::test_simple_1", "fill_tests::test_simple_merge_split", "fill_tests::test_hole_1", "fill_tests::test_simple_aligned", "earcut_tests::water_huge", "fill_tests::test_simple_2", "earcut_tests::water_huge_2", "fill_tests::n_segments_intersecting", "fill_tests::test_rust_logo_no_intersection", "fill_tests::test_rust_logo_with_intersection", "fill_tests::very_large_path", "tessellation/src/geometry_builder.rs - geometry_builder (line 202)", "tessellation/src/geometry_builder.rs - geometry_builder (line 131)", "tessellation/src/geometry_builder.rs - geometry_builder (line 72)", "tessellation/src/stroke.rs - stroke::StrokeTessellator (line 44)", "tessellation/src/fill.rs - fill::FillTessellator (line 378)", "tessellation/src/fill.rs - fill::FillTessellator (line 336)" ]
[]
[]
2021-09-29T20:59:52Z
17b0ce8c74a2bb917de85f99428886ca8445ac3b
"diff --git a/Cargo.lock b/Cargo.lock\n--- a/Cargo.lock\n+++ b/Cargo.lock\n@@ -787,7 +787,7 @@ depen(...TRUNCATED)
nical__lyon-519
519
"The above example will work successfully if I omit the last `line_to` and let it close via `close`,(...TRUNCATED)
[ "518" ]
0.15
nical/lyon
2019-12-27T22:28:12Z
"diff --git a/tessellation/src/fill_tests.rs b/tessellation/src/fill_tests.rs\n--- a/tessellation/sr(...TRUNCATED)
"Path hits `is_after(to, self.current_position)` assert\nThe following path hit an assert in the fil(...TRUNCATED)
08cd4c3d8c1ef53fbbb1b702f655e26c6bd5cc03
[ "fill_tests::issue_518_2", "fill_tests::issue_518_1" ]
["basic_shapes::issue_366","earcut_tests::bad_diagonal","earcut_tests::bad_hole","earcut_tests::eber(...TRUNCATED)
[]
[]
2019-12-28T00:17:29Z
fcb9841a744543b993eb1645db35dbda541e9a30
"diff --git a/strum_macros/src/helpers/type_props.rs b/strum_macros/src/helpers/type_props.rs\n--- a(...TRUNCATED)
Peternator7__strum-288
288
"It's a breaking change, but I agree it's certainly more inline with what would be expected. Happy t(...TRUNCATED)
[ "283" ]
0.25
Peternator7/strum
2023-08-01T22:43:37Z
"diff --git a/strum_tests/tests/enum_discriminants.rs b/strum_tests/tests/enum_discriminants.rs\n---(...TRUNCATED)
"EnumDiscriminants should inherit the repr of the enum they are derived from\nThe below example code(...TRUNCATED)
597f8e941fb9dec5603f6892df4109b50f615160
[ "with_explicit_discriminant_value", "with_repr_uint", "with_repr_align" ]
["arbitrary_attributes_pass_through","complicated_test","crate_module_path_test","from_ref_test","fi(...TRUNCATED)
[]
[]
2024-01-28T01:13:46Z
025b1b5687d061bc4116f77578fa9fc2b3fc1f26
"diff --git a/strum_macros/src/macros/enum_count.rs b/strum_macros/src/macros/enum_count.rs\n--- a/s(...TRUNCATED)
Peternator7__strum-268
268
[ "267" ]
0.24
Peternator7/strum
2023-04-26T18:46:25Z
"diff --git a/strum_tests/tests/enum_count.rs b/strum_tests/tests/enum_count.rs\n--- a/strum_tests/t(...TRUNCATED)
"Disabled variant still included in Count\nThe [additional attributes docs](https://docs.rs/strum/la(...TRUNCATED)
025b1b5687d061bc4116f77578fa9fc2b3fc1f26
[ "disabled_test" ]
[ "crate_module_path_test", "simple_test" ]
[]
[]
2023-06-18T22:54:11Z
c6c78a16c59af13a6bf6d35ed859618033a61768
"diff --git a/Cargo.lock b/Cargo.lock\n--- a/Cargo.lock\n+++ b/Cargo.lock\n@@ -277,6 +277,15 @@ depe(...TRUNCATED)
sigoden__dufs-179
179
[ "172" ]
0.31
sigoden/dufs
2023-02-20T14:35:53Z
"diff --git a/tests/fixtures.rs b/tests/fixtures.rs\n--- a/tests/fixtures.rs\n+++ b/tests/fixtures.r(...TRUNCATED)
"[Feature Request] Edit files\nThe ability to edit and save files on the server. txt, yaml, php etc.(...TRUNCATED)
a61fda6e80d70e5cd7ded9a9b33a9ca373c2b239
[ "get_file_edit_bin", "get_file_edit" ]
["utils::test_glob_key","default_not_exist_dir","allow_delete_no_override","allow_upload_no_override(...TRUNCATED)
[ "bind_ipv4_ipv6::case_2", "validate_printed_urls::case_2", "validate_printed_urls::case_1" ]
[]
2023-03-05T03:12:08Z
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
1