-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Enhance 2D Transform/Vec2 Quality of Life #2548
Comments
One Possible List of MethodsI want to propose that
Additionally to assist with relative modifications without constructing full transforms and
Unsure if we require specialized 2D/3D functions for mul/div for Vecs and Scalars. In most cases scale mul/div can be applied directly, scaling z-scale doesn't affect 2D (But would for 2.5D games) and it would be fairly strange to multiply translation (though if you normalized it first, then scaled, I could see it being used to fix something to a circle?) but could cause issues with the z-axis being scaled and changing the layering. * 2D variants will extend the input to preserve the 3D value's extra data. For example ** We could also add variants for left, right, up, down, forward, back to match with the axis functions. *** 2D only requires angle_z, which could be called With Vec2 some helper functions to establish convention and provide common utility present in other engines, and would require the addition of:
These helper functions would establish ccw rotations on the xy-plane, +x being 0deg/rad, which I believe is the "industry-standard", right? If we're being greedy/complete, we could also add some helper methods to Mat3. Mostly for constructing/destructing TRS matrices. |
I'll chime in here, although my needs are more for 3d space. Personally, I'd like to have a way to construct a Transform with a shorthand method, where:
and maybe
|
I think |
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)
andQuat::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:
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
The text was updated successfully, but these errors were encountered: