bevyengine / bevyengine/bevy

Add a "path strip" primitive for 2d and 3d.

Open
#14,133 0 comments 1 reaction 0 assignees View on GitHub
A-Editor A-Math C-Feature
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

This is a generalization of the "linestrip" concept which is currently supported in Gizmos, but not as a primitive. The use case I'm thinking about is a Blender-style shader editor with connecting wires, but there are potentially other use cases as well.

## What solution would you like?

What you would have is an array of SVG-like path elements:

```rust
#[derive(Debug, Copy, Clone)]
pub enum DrawablePathSegment {
/// Move to a new position.
Move(Vec2),
/// Draw a straight line to a new position.
Line(Vec2),
/// Draw a quadratic curve to a new position.
Quadratic((Vec2, Vec2)),
}
```
The primitive would convert this into line segments at some level of granularity so that the curves don't look jagged.

There should also be a "gradient" version, similar to `linestrip_gradient`.

## What alternative(s) have you considered?

There are several alternatives, but none of them completely satisfactory:
* Doing my own linestrips is possible, but that work should be shared.
* Gizmos are problematic in UI contexts since you can't control what UI layer they appear on.
* Using an SDF-based shader is also possible but not terribly efficient since you have to render the whole bounding box of the path.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing Gizmos linestrip and linestrip_gradient implementations, then compare them with the proposed DrawablePathSegment API. Determine how a 2D and 3D primitive should represent Move, Line, and Quadratic segments and how curve subdivision granularity should work. Done means path strips render without jagged curves and include a gradient variant.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.