178 } |
178 } |
179 } |
179 } |
180 |
180 |
181 // now go through all other segments |
181 // now go through all other segments |
182 for s in self.segments_iter() { |
182 for s in self.segments_iter() { |
183 if s != segment { |
183 if s != segment && intersects(&normal_ray, &s) { |
184 if intersects(&normal_ray, &s) { |
184 if let Some((t, d)) = solve_intersection(&self.intersections_box, &normal_ray, &s) { |
185 if let Some((t, d)) = |
185 if t > 0 { |
186 solve_intersection(&self.intersections_box, &normal_ray, &s) |
186 dist_right = min(dist_right, d); |
187 { |
187 } else { |
188 if t > 0 { |
188 dist_left = min(dist_left, d); |
189 dist_right = min(dist_right, d); |
|
190 } else { |
|
191 dist_left = min(dist_left, d); |
|
192 } |
|
193 } |
189 } |
194 } |
190 } |
195 } |
191 } |
196 } |
192 } |
197 |
193 |
198 // go through all points, including fill points |
194 // go through all points, including fill points |
199 for pi in self.iter().cloned() { |
195 for pi in self.iter().cloned() { |
200 if pi != segment.start && pi != segment.end { |
196 if pi != segment.start |
201 if intersects(&pi.ray_with_dir(normal), &segment) { |
197 && pi != segment.end |
202 // ray from segment.start |
198 && intersects(&pi.ray_with_dir(normal), &segment) |
203 if let Some((t, d)) = solve_intersection( |
199 { |
204 &self.intersections_box, |
200 // ray from segment.start |
205 &normal_ray, |
201 if let Some((t, d)) = solve_intersection( |
206 &segment.start.line_to(pi), |
202 &self.intersections_box, |
207 ) { |
203 &normal_ray, |
208 if t > 0 { |
204 &segment.start.line_to(pi), |
209 dist_right = min(dist_right, d); |
205 ) { |
210 } else { |
206 if t > 0 { |
211 dist_left = min(dist_left, d); |
207 dist_right = min(dist_right, d); |
212 } |
208 } else { |
|
209 dist_left = min(dist_left, d); |
213 } |
210 } |
214 |
211 } |
215 // ray from segment.end |
212 |
216 if let Some((t, d)) = solve_intersection( |
213 // ray from segment.end |
217 &self.intersections_box, |
214 if let Some((t, d)) = solve_intersection( |
218 &normal_ray, |
215 &self.intersections_box, |
219 &segment.end.line_to(pi), |
216 &normal_ray, |
220 ) { |
217 &segment.end.line_to(pi), |
221 if t > 0 { |
218 ) { |
222 dist_right = min(dist_right, d); |
219 if t > 0 { |
223 } else { |
220 dist_right = min(dist_right, d); |
224 dist_left = min(dist_left, d); |
221 } else { |
225 } |
222 dist_left = min(dist_left, d); |
226 } |
223 } |
227 } |
224 } |
228 } |
225 } |
229 } |
226 } |
230 |
227 |