@@ -868,6 +868,109 @@ TODO.
868868
869869TODO.
870870
871+ ## Multiple gizmo configurations
872+
873+ <div class =" release-feature-authors " >authors: @jeliag</div >
874+
875+ Since [ the 0.11 release] , Bevy supports gizmos. Gizmos allow drawing shapes using
876+ an immediate mode API. Here is how you use them:
877+
878+ ``` rust
879+ // bevy 0.12.1
880+ fn set_gizmo_width (mut config : ResMut <GizmoConfig >) {
881+ // set the line width of every gizmos with this global configuration resource.
882+ config . line_width = 5.0 ;
883+ }
884+
885+ fn draw_circles (mut gizmos : Gizmos ) {
886+ // Draw two circles with a 5 pixels outline
887+ gizmos . circle_2d (vec2 (100 . , 0 . ), 120 . , Color :: NAVY );
888+ gizmos . circle_2d (vec2 (- 100 . , 0 . ), 120 . , Color :: ORANGE );
889+ }
890+ ```
891+
892+ Add a [ ` Gizmos ` ] system param and call a few methods, nothing more. Cool!
893+
894+ Gizmos are also great for crate authors, they can use the same API.
895+ For example, the [ ` oxidized_navigation ` ] navmesh library uses gizmos for its debug overlay.
896+ Great!
897+
898+
899+ But after quick adoption, the community quickly found their limitations.
900+
901+ Remember: crate authors, as well as game devs, can use gizmos and set their config globally.
902+ However, there is only one global configuration. Therefore,
903+ a dependency could very well affect the game's gizmos.
904+ It could even make them completely unusable.
905+
906+ Not so great.
907+
908+ How to solve this? Gizmo groups.
909+
910+ Now, [ ` Gizmos ` ] comes with an optional parameter.
911+ By default, it uses a global configuration:
912+
913+ ``` rust
914+ fn draw_circles (mut default_gizmos : Gizmos ) {
915+ default_gizmos . circle_2d (vec2 (100 . , 0 . ), 120 . , Color :: NAVY );
916+ }
917+ ```
918+
919+ But with a [ ` GizmoConfigGroup ` ] parameter, ` Gizmos ` can choose a distinct configuration:
920+
921+ ``` rust
922+ fn draw_circles (
923+ mut default_gizmos : Gizmos ,
924+ // this uses a distinct configvvvvvvvvvvvvvvv
925+ mut navigation_gizmos : Gizmos <NavigationGroup >,
926+ ) {
927+ // Two circles with different outline width
928+ default_gizmos . circle_2d (vec2 (100 . , 0 . ), 120 . , Color :: NAVY );
929+ navigation_gizmos . circle_2d (vec2 (- 100 . , 0 . ), 120 . , Color :: ORANGE );
930+ }
931+ ```
932+
933+ Create your own gizmo config group by deriving ` GizmoConfigGroup ` ,
934+ and registering it to the ` App ` :
935+
936+ ``` rust
937+ #[derive(Default , Reflect , GizmoConfigGroup )]
938+ pub struct NavigationGroup ;
939+
940+ impl Plugin for NavigationPlugin {
941+ fn build (& mut self , app : & mut App ) {
942+ app
943+ . init_gizmo_group :: <NavigationGroup >()
944+ // ... rest of plugin initialization.
945+ }
946+ }
947+ ```
948+
949+ And this is how you set the configuration of gizmo groups to different values:
950+
951+ ``` rust
952+ // bevy 0.13.0
953+ set_gizmo_width (mut config_store : ResMut <GizmoConfigStore >) {
954+ let config = config_store . config_mut :: <DefaultGizmoConfigGroup >(). 0 ;
955+ config . line_width = 20.0 ;
956+
957+ let navigation_config = config_store . config_mut :: <NavigationGroup >(). 0 ;
958+ navigation_config . line_width = 10.0 ;
959+ }
960+ ```
961+
962+ Now, the navigation gizmos have a fully separate configuration and don't conflict
963+ with the game's gizmos.
964+
965+ Not only that, but the game dev can integrate the navigation gizmos with their
966+ own debug tools however they wish. Be it a hotkey, a debug overlay UI button,
967+ an RPC call. The world is your oyster.
968+
969+ [ `oxidized_navigation` ] : https://crates.io/crates/oxidized_navigation
970+ [ `Gizmos` ] : https://dev-docs.bevyengine.org/bevy/gizmos/gizmos/struct.Gizmos.html
971+ [ the 0.11 release ] : https://bevyengine.org/news/bevy-0-11/#gizmos
972+ [ `GizmoConfigGroup` ] : https://dev-docs.bevyengine.org/bevy/gizmos/config/trait.GizmoConfigGroup.html
973+ =======
871974## glTF Extensions
872975
873976## Extensionless Asset Support
@@ -999,12 +1102,6 @@ The [`custom_asset` example] has been updated to demonstrate these new features.
9991102[ turbofish ] : https://turbo.fish/
10001103[ `custom_asset` example ] : https://bevyengine.org/examples/Assets/custom-asset/
10011104
1002- ## Gizmo Configuration
1003-
1004- <div class =" release-feature-authors " >authors: @TODO</div >
1005-
1006- TODO.
1007-
10081105## <a name =" what-s-next " ></a >What's Next?
10091106
10101107We have plenty of work in progress! Some of this will likely land in ** Bevy 0.14** .
0 commit comments