Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved rendering (And documentation) for 2d and 3d Lines #5619

Closed
jgrey8504 opened this issue Aug 8, 2022 · 0 comments · Fixed by #6529
Closed

Improved rendering (And documentation) for 2d and 3d Lines #5619

jgrey8504 opened this issue Aug 8, 2022 · 0 comments · Fixed by #6529
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation C-Feature A new feature, making something new possible

Comments

@jgrey8504
Copy link

The Problem:

Currently, it is difficult to utilize basic lines in your bevy project. The best 2 options are to use bevy polyline, or to import the shader assets from bevy main into your project, neither of which are very obvious or clear to beginners, and it is not very clean or straightforward to have to either import new dependencies or shaders into your project.

Additionally, they only work with 3d, being incompatible with 2d cameras. They also are incredibly difficult and unintuitive to work with, (With Bevy main's line shader) it is a challenge to even be able to move the lines during run time, and it has a lot of overhead, which makes it extremely difficult to even get to use without copying and pasting from this one example.

Solution:

It would be immensely helpful to have functions built-in that allow spawning bundles for lines in both 3d and 2d, which work 'out of the box' without needing to import/copy+paste a bunch of things, with documentation to make it more intuitive to use, implemented similarly to the shapes geometry bundles, which you can easily spawn with a spawn_bundle (The attributes all labeled), and then very simply edit on the fly with just a simple mutable query, as opposed to the lines right now, which... I'm not quite sure how it is intended to be edited??.. uh.. or the bevy polylines which require all sorts of handles and assets, which you get_mut another handle then unwrap and it's a whole difficult process.

Thanks in advance!

@jgrey8504 jgrey8504 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Aug 8, 2022
@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Aug 9, 2022
cart added a commit that referenced this issue Mar 20, 2023
# 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 <felipe.jorge.pereira@gmail.com>
Co-Authored By: @The5-1 <agaku@hotmail.de> 
Co-Authored By: @Toqozz <toqoz@hotmail.com>
Co-Authored By: @nicopap <nico@nicopap.ch>

---------

Co-authored-by: Robert Swain <robert.swain@gmail.com>
Co-authored-by: IceSentry <c.giguere42@gmail.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants