#debug #line #graphics #bevy #drawing

bevy_prototype_debug_lines

A prototype plugin providing a simple line drawing API for bevy

7 releases

0.3.1 Apr 14, 2021
0.3.0 Apr 14, 2021
0.2.2 Apr 9, 2021
0.2.0 Mar 5, 2021
0.1.1-alpha Feb 26, 2021

#17 in Rendering

Download history 59/week @ 2021-02-26 37/week @ 2021-03-05 7/week @ 2021-03-12 20/week @ 2021-03-19 12/week @ 2021-03-26 10/week @ 2021-04-02 58/week @ 2021-04-09 48/week @ 2021-04-16 16/week @ 2021-04-23 15/week @ 2021-04-30

59 downloads per month

MIT license

25KB
204 lines

bevy_debug_lines

A prototype plugin providing a simple line drawing api for bevy.

See docs.rs for documentation. See crates.io for crates.io.

Expect breakage on master.

demo demo_2 Click on the above demo to play it.

About

This plugin uses a shader and sends individual points to the GPU, which then moves geometry to make a line. This is quite fast with a significant number of lines, and there is no added cost to moving lines around.

Usage

Add bevy_prototype_debug_lines to your Cargo.toml:

[dependencies]
bevy_prototype_debug_lines = "0.3.1"

Add the plugin in your App::build() phase:

use bevy::prelude::*;
use bevy_prototype_debug_lines::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(DebugLinesPlugin)
        ...
        .run();
}

Draw a line in whatever system you have using the DebugLines resource:

fn some_system(
    ...
    mut lines: ResMut<DebugLines>
) {
    let start = Vec3::splat(-1.0);
    let end = Vec3::splat(1.0);
    let duration = 0.0;     // Duration of 0 will show the line for 1 frame.
    lines.line(start, end, duration);
}

See the examples for more complete usage examples.

Running Examples

You can run the examples like so:

cargo run --example 3d --features="example_deps"

Where 3d is one of the files in the examples

Changes in 0.3.0

In 0.3.0, the thickness parameter has been removed. I don't believe it provides enough value for the performance, time, or issues. However, if you feel differently, let me know in this issue.

This is technically a non-breaking change (i.e. your code will still compile) because duration was added which takes the same spot, but beware that your code still needs to be updated (probably just set old thickness values to 0, if you don't care about duration stuff.).


Please do not hesitate to let me know if you have any requests, improvements, or suggestions on how to make this crate more ergonomic or otherwise.

Dependencies

~11–26MB
~440K SLoC