Skip to content

Commit 6a85eb3

Browse files
tim-blackbirdsuperdumpIceSentrycart
authored
Immediate Mode Line/Gizmo Drawing (#6529)
# Objective Add a convenient immediate mode drawing API for visual debugging. Fixes #5619 Alternative to #1625 Partial alternative to #5734 Based off https://github.com/Toqozz/bevy_debug_lines with some changes: * Simultaneous support for 2D and 3D. * Methods for basic shapes; circles, spheres, rectangles, boxes, etc. * 2D methods. * Removed durations. Seemed niche, and can be handled by users. <details> <summary>Performance</summary> Stress tested using Bevy's recommended optimization settings for the dev profile with the following command. ```bash cargo run --example many_debug_lines \ --config "profile.dev.package.\"*\".opt-level=3" \ --config "profile.dev.opt-level=1" ``` I dipped to 65-70 FPS at 300,000 lines CPU: 3700x RAM Speed: 3200 Mhz GPU: 2070 super - probably not very relevant, mostly cpu/memory bound </details> <details> <summary>Fancy bloom screenshot</summary> ![Screenshot_20230207_155033](https://user-images.githubusercontent.com/29694403/217291980-f1e0500e-7a14-4131-8c96-eaaaf52596ae.png) </details> ## Changelog * Added `GizmoPlugin` * Added `Gizmos` system parameter for drawing lines and wireshapes. ### TODO - [ ] Update changelog - [x] Update performance numbers - [x] Add credit to PR description ### Future work - Cache rendering primitives instead of constructing them out of line segments each frame. - Support for drawing solid meshes - Interactions. (See [bevy_mod_gizmos](https://github.com/LiamGallagher737/bevy_mod_gizmos)) - Fancier line drawing. (See [bevy_polyline](https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline)) - Support for `RenderLayers` - Display gizmos for a certain duration. Currently everything displays for one frame (ie. immediate mode) - Changing settings per drawn item like drawing on top or drawing to different `RenderLayers` Co-Authored By: @lassade <[email protected]> Co-Authored By: @The5-1 <[email protected]> Co-Authored By: @Toqozz <[email protected]> Co-Authored By: @nicopap <[email protected]> --------- Co-authored-by: Robert Swain <[email protected]> Co-authored-by: IceSentry <[email protected]> Co-authored-by: Carter Anderson <[email protected]>
1 parent d58ed67 commit 6a85eb3

File tree

17 files changed

+1205
-1
lines changed

17 files changed

+1205
-1
lines changed

Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ default = [
4949
"vorbis",
5050
"x11",
5151
"filesystem_watcher",
52+
"bevy_gizmos",
5253
"android_shared_stdcxx",
5354
"tonemapping_luts",
5455
]
@@ -98,6 +99,9 @@ bevy_ui = ["bevy_internal/bevy_ui", "bevy_core_pipeline", "bevy_text", "bevy_spr
9899
# winit window and input backend
99100
bevy_winit = ["bevy_internal/bevy_winit"]
100101

102+
# Adds support for rendering gizmos
103+
bevy_gizmos = ["bevy_internal/bevy_gizmos"]
104+
101105
# Tracing support, saving a file in Chrome Tracing format
102106
trace_chrome = ["trace", "bevy_internal/trace_chrome"]
103107

@@ -309,6 +313,16 @@ description = "Renders a rectangle, circle, and hexagon"
309313
category = "2D Rendering"
310314
wasm = true
311315

316+
[[example]]
317+
name = "2d_gizmos"
318+
path = "examples/2d/2d_gizmos.rs"
319+
320+
[package.metadata.example.2d_gizmos]
321+
name = "2D Gizmos"
322+
description = "A scene showcasing 2D gizmos"
323+
category = "2D Rendering"
324+
wasm = true
325+
312326
[[example]]
313327
name = "sprite"
314328
path = "examples/2d/sprite.rs"
@@ -400,6 +414,16 @@ description = "A scene showcasing the built-in 3D shapes"
400414
category = "3D Rendering"
401415
wasm = true
402416

417+
[[example]]
418+
name = "3d_gizmos"
419+
path = "examples/3d/3d_gizmos.rs"
420+
421+
[package.metadata.example.3d_gizmos]
422+
name = "3D Gizmos"
423+
description = "A scene showcasing 3D gizmos"
424+
category = "3D Rendering"
425+
wasm = true
426+
403427
[[example]]
404428
name = "atmospheric_fog"
405429
path = "examples/3d/atmospheric_fog.rs"
@@ -1553,6 +1577,16 @@ description = "Simple benchmark to test per-entity draw overhead. Run with the `
15531577
category = "Stress Tests"
15541578
wasm = true
15551579

1580+
[[example]]
1581+
name = "many_gizmos"
1582+
path = "examples/stress_tests/many_gizmos.rs"
1583+
1584+
[package.metadata.example.many_gizmos]
1585+
name = "Many Gizmos"
1586+
description = "Test rendering of many gizmos"
1587+
category = "Stress Tests"
1588+
wasm = true
1589+
15561590
[[example]]
15571591
name = "many_foxes"
15581592
path = "examples/stress_tests/many_foxes.rs"

crates/bevy_gizmos/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "bevy_gizmos"
3+
version = "0.11.0-dev"
4+
edition = "2021"
5+
description = "Provides gizmos for Bevy Engine"
6+
homepage = "https://bevyengine.org"
7+
repository = "https://github.com/bevyengine/bevy"
8+
license = "MIT OR Apache-2.0"
9+
keywords = ["bevy"]
10+
11+
[dependencies]
12+
# Bevy
13+
bevy_pbr = { path = "../bevy_pbr", version = "0.11.0-dev", optional = true }
14+
bevy_sprite = { path = "../bevy_sprite", version = "0.11.0-dev", optional = true }
15+
bevy_app = { path = "../bevy_app", version = "0.11.0-dev" }
16+
bevy_ecs = { path = "../bevy_ecs", version = "0.11.0-dev" }
17+
bevy_math = { path = "../bevy_math", version = "0.11.0-dev" }
18+
bevy_asset = { path = "../bevy_asset", version = "0.11.0-dev" }
19+
bevy_render = { path = "../bevy_render", version = "0.11.0-dev" }
20+
bevy_utils = { path = "../bevy_utils", version = "0.11.0-dev" }
21+
bevy_core = { path = "../bevy_core", version = "0.11.0-dev" }
22+
bevy_reflect = { path = "../bevy_reflect", version = "0.11.0-dev" }
23+
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.11.0-dev" }

0 commit comments

Comments
 (0)