draw arc by lines instead of arc_2d
This commit is contained in:
parent
a1180ea769
commit
0c7ceb5d8d
1 changed files with 22 additions and 7 deletions
|
|
@ -23,12 +23,27 @@ pub fn draw_track_gizmos(track: Res<Track>, mut gizmos: Gizmos) {
|
|||
// вычисляем нормаль, центр, угол поворота арки и знак
|
||||
let arc = helper_arc_calculator(current_pos, current_dir, *left, *radius);
|
||||
|
||||
gizmos.arc_2d(
|
||||
Isometry2d::new(arc.center, Rot2::radians(arc.start_angle)),
|
||||
FRAC_PI_2,
|
||||
*radius,
|
||||
GREEN,
|
||||
);
|
||||
// арки никак не хотели вставать на свои места
|
||||
// gizmos.arc_2d(
|
||||
// Isometry2d::new(arc.center, Rot2::degrees(current_angle)),
|
||||
// FRAC_PI_2 * arc.sweep_sign,
|
||||
// *radius,
|
||||
// GREEN,
|
||||
// );
|
||||
|
||||
// поэтому отрисовка поворота через линии
|
||||
let steps = 16;
|
||||
let mut prev_point = current_pos;
|
||||
|
||||
for i in 1..=steps {
|
||||
let t = i as f32 / steps as f32;
|
||||
let angle = arc.start_angle + arc.sweep_sign * FRAC_PI_2 * t;
|
||||
let point = arc.center + Vec2::from_angle(angle) * *radius;
|
||||
|
||||
gizmos.line_2d(prev_point, point, GREEN);
|
||||
prev_point = point;
|
||||
}
|
||||
|
||||
current_pos = arc.end_pos;
|
||||
current_dir = arc.normal;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue