-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add TransformBuilder API #266
Conversation
04ce5fb
to
ad2169f
Compare
/// with an identity transform. | ||
/// * The current transform can be applied after another transform using | ||
/// the `after_*()` methods. | ||
/// * The current transform can be applied before another transform usig |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
After sitting on this for a bit, I think maybe it's better to just add this functionality to each of the individual components. For example,
|
bacc589
to
5730976
Compare
Mind if we close this in favor of the current Transform rewrite (and potentially adding the ideas here: #501) |
Yeah, this is obsolete. |
I've seen a few people confused about how to implement rotation and other transforms in the bevy discord help channel. I think something like the TransformBuilder in this PR might make working with transformations easier for some.
There are a couple parts of this API that I'm not fully happy with. For one thing, It's possible to loose information using some of the
build_*()
methods. For examplebuild_rotation()
discards any translation component of the transform. But I'm not sure what can be done about this short of making a new builder for each possible type of transform, which I think would make the API a lot more confusing.For another thing, the builder isn't as computationally efficient as it could be. It converts all transformations to a Mat4 internally, then converts back to components during the build step.
For a third, this API doesn't do a whole lot to address people's trouble with quaternions. I think the API could be extended to help with some things, for example
then_look_at(point: &Vec3)
, but it's not clear if it could be extended to help with things like quaternion interpolation. Maybe it could use some methods likethen_rotate_toward(other: &Quat, percent: f32)
orthen_rotate_toward(other: &Quat, angle: f32)
.Finally, I'm not sure an API like this is necessary or wanted, but I'm creating this PR to get feedback.