bevyengine / bevyengine/bevy

Enhance 2D Transform/Vec2 Quality of Life

Open
#2,548 4 comments 10 reactions 0 assignees View on GitHub
A-Transform C-Feature C-Usability D-Complex S-Needs-Design-Doc X-Needs-SME
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?

Currently working with transforms in 2D space is a second-class experience, as the user is responsible for truncating Vec3s from Transforms, extending Vec2s to apply them to Transforms and dealing with quite a few calculations for the go-between of Z-Axis angle <-> Quaternion (ie. `x_axis.y.atan2(x_axis.x)` and `Quat::from_axis_angle(Vec2::Z, angle)`.

One particularly of irritation for 2D work is that you can't work directly with the struct values without manually extending/truncating each value.

This makes a lot of 2D code look messy, ultimately pushing the user to implement their own helper methods that:
1. Require them to have an decent understanding of the math behind 2D transformations, and how to extend them into 3D. Which is good to have, but could push newer users away by front-loading them.
2. Create accidental incompatibilities between 2D libraries that implement their helpers using different conventions.

## What solution would you like?

I would like Transform & Vec2 (and potentially Mat3 for completeness) to provide functions useful for clean, clear, optimal and concise transformations in 2D space and define the convention.

## What alternative(s) have you considered?

A Transform2D component would be more ideal, but that seems to go against the resolution of #229 / #374.

Provide a feature that converts Transform to a purely 2D representation (PosX, PosY, Layer, Angle, ScaleX, Scaley). This would be smaller and ideal for a purely 2D game, which is where I imagine these methods will have the most use. I've implemented this in the past and it required very few changes in the engine itself. Issue being that it complicates code that should work for both transform types and makes it so you can't have mixed-2D/3D applications without completely falling back to 3D.

## Related

Could be seen as related to #501, however that seems to be focused more general/3D QoL, such as Transforms with Transforms

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing Transform and Vec2 APIs and the related issues #229, #374, and #501. Clarify the supported 2D operations, the Vec2/Vec3 and angle/quaternion conventions, and whether Mat3 is included; the work is done when a settled, consistent API is specified and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.