Skip to content

Enhance 2D Transform/Vec2 Quality of Life #2548

Open
@notverymoe

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-TransformTranslations, rotations and scalesC-FeatureA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be mergedX-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions