2
2
3
3
use std:: { f32:: consts:: TAU , iter} ;
4
4
5
+ use crate :: circles:: DEFAULT_CIRCLE_SEGMENTS ;
5
6
use bevy_ecs:: {
6
7
system:: { Deferred , Resource , SystemBuffer , SystemMeta , SystemParam } ,
7
8
world:: World ,
@@ -13,8 +14,6 @@ use bevy_transform::TransformPoint;
13
14
type PositionItem = [ f32 ; 3 ] ;
14
15
type ColorItem = [ f32 ; 4 ] ;
15
16
16
- const DEFAULT_CIRCLE_SEGMENTS : usize = 32 ;
17
-
18
17
#[ derive( Resource , Default ) ]
19
18
pub ( crate ) struct GizmoStorage {
20
19
pub list_positions : Vec < PositionItem > ,
@@ -201,44 +200,6 @@ impl<'s> Gizmos<'s> {
201
200
strip_colors. push ( [ f32:: NAN ; 4 ] ) ;
202
201
}
203
202
204
- /// Draw a circle in 3D at `position` with the flat side facing `normal`.
205
- ///
206
- /// This should be called for each frame the circle needs to be rendered.
207
- ///
208
- /// # Example
209
- /// ```
210
- /// # use bevy_gizmos::prelude::*;
211
- /// # use bevy_render::prelude::*;
212
- /// # use bevy_math::prelude::*;
213
- /// fn system(mut gizmos: Gizmos) {
214
- /// gizmos.circle(Vec3::ZERO, Vec3::Z, 1., Color::GREEN);
215
- ///
216
- /// // Circles have 32 line-segments by default.
217
- /// // You may want to increase this for larger circles.
218
- /// gizmos
219
- /// .circle(Vec3::ZERO, Vec3::Z, 5., Color::RED)
220
- /// .segments(64);
221
- /// }
222
- /// # bevy_ecs::system::assert_is_system(system);
223
- /// ```
224
- #[ inline]
225
- pub fn circle (
226
- & mut self ,
227
- position : Vec3 ,
228
- normal : Vec3 ,
229
- radius : f32 ,
230
- color : Color ,
231
- ) -> CircleBuilder < ' _ , ' s > {
232
- CircleBuilder {
233
- gizmos : self ,
234
- position,
235
- normal,
236
- radius,
237
- color,
238
- segments : DEFAULT_CIRCLE_SEGMENTS ,
239
- }
240
- }
241
-
242
203
/// Draw a wireframe sphere in 3D made out of 3 circles around the axes.
243
204
///
244
205
/// This should be called for each frame the sphere needs to be rendered.
@@ -466,42 +427,6 @@ impl<'s> Gizmos<'s> {
466
427
self . line_gradient_2d ( start, start + vector, start_color, end_color) ;
467
428
}
468
429
469
- /// Draw a circle in 2D.
470
- ///
471
- /// This should be called for each frame the circle needs to be rendered.
472
- ///
473
- /// # Example
474
- /// ```
475
- /// # use bevy_gizmos::prelude::*;
476
- /// # use bevy_render::prelude::*;
477
- /// # use bevy_math::prelude::*;
478
- /// fn system(mut gizmos: Gizmos) {
479
- /// gizmos.circle_2d(Vec2::ZERO, 1., Color::GREEN);
480
- ///
481
- /// // Circles have 32 line-segments by default.
482
- /// // You may want to increase this for larger circles.
483
- /// gizmos
484
- /// .circle_2d(Vec2::ZERO, 5., Color::RED)
485
- /// .segments(64);
486
- /// }
487
- /// # bevy_ecs::system::assert_is_system(system);
488
- /// ```
489
- #[ inline]
490
- pub fn circle_2d (
491
- & mut self ,
492
- position : Vec2 ,
493
- radius : f32 ,
494
- color : Color ,
495
- ) -> Circle2dBuilder < ' _ , ' s > {
496
- Circle2dBuilder {
497
- gizmos : self ,
498
- position,
499
- radius,
500
- color,
501
- segments : DEFAULT_CIRCLE_SEGMENTS ,
502
- }
503
- }
504
-
505
430
/// Draw an arc, which is a part of the circumference of a circle, in 2D.
506
431
///
507
432
/// This should be called for each frame the arc needs to be rendered.
@@ -603,33 +528,6 @@ impl<'s> Gizmos<'s> {
603
528
}
604
529
}
605
530
606
- /// A builder returned by [`Gizmos::circle`].
607
- pub struct CircleBuilder < ' a , ' s > {
608
- gizmos : & ' a mut Gizmos < ' s > ,
609
- position : Vec3 ,
610
- normal : Vec3 ,
611
- radius : f32 ,
612
- color : Color ,
613
- segments : usize ,
614
- }
615
-
616
- impl CircleBuilder < ' _ , ' _ > {
617
- /// Set the number of line-segments for this circle.
618
- pub fn segments ( mut self , segments : usize ) -> Self {
619
- self . segments = segments;
620
- self
621
- }
622
- }
623
-
624
- impl Drop for CircleBuilder < ' _ , ' _ > {
625
- fn drop ( & mut self ) {
626
- let rotation = Quat :: from_rotation_arc ( Vec3 :: Z , self . normal ) ;
627
- let positions = circle_inner ( self . radius , self . segments )
628
- . map ( |vec2| ( self . position + rotation * vec2. extend ( 0. ) ) ) ;
629
- self . gizmos . linestrip ( positions, self . color ) ;
630
- }
631
- }
632
-
633
531
/// A builder returned by [`Gizmos::sphere`].
634
532
pub struct SphereBuilder < ' a , ' s > {
635
533
gizmos : & ' a mut Gizmos < ' s > ,
@@ -658,30 +556,6 @@ impl Drop for SphereBuilder<'_, '_> {
658
556
}
659
557
}
660
558
661
- /// A builder returned by [`Gizmos::circle_2d`].
662
- pub struct Circle2dBuilder < ' a , ' s > {
663
- gizmos : & ' a mut Gizmos < ' s > ,
664
- position : Vec2 ,
665
- radius : f32 ,
666
- color : Color ,
667
- segments : usize ,
668
- }
669
-
670
- impl Circle2dBuilder < ' _ , ' _ > {
671
- /// Set the number of line-segments for this circle.
672
- pub fn segments ( mut self , segments : usize ) -> Self {
673
- self . segments = segments;
674
- self
675
- }
676
- }
677
-
678
- impl Drop for Circle2dBuilder < ' _ , ' _ > {
679
- fn drop ( & mut self ) {
680
- let positions = circle_inner ( self . radius , self . segments ) . map ( |vec2| ( vec2 + self . position ) ) ;
681
- self . gizmos . linestrip_2d ( positions, self . color ) ;
682
- }
683
- }
684
-
685
559
/// A builder returned by [`Gizmos::arc_2d`].
686
560
pub struct Arc2dBuilder < ' a , ' s > {
687
561
gizmos : & ' a mut Gizmos < ' s > ,
@@ -730,13 +604,6 @@ fn arc_inner(
730
604
} )
731
605
}
732
606
733
- fn circle_inner ( radius : f32 , segments : usize ) -> impl Iterator < Item = Vec2 > {
734
- ( 0 ..segments + 1 ) . map ( move |i| {
735
- let angle = i as f32 * TAU / segments as f32 ;
736
- Vec2 :: from ( angle. sin_cos ( ) ) * radius
737
- } )
738
- }
739
-
740
607
fn rect_inner ( size : Vec2 ) -> [ Vec2 ; 4 ] {
741
608
let half_size = size / 2. ;
742
609
let tl = Vec2 :: new ( -half_size. x , half_size. y ) ;
0 commit comments