-
-
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
Adding QoL extensions to Transforms #501
Comments
There should definitely be both apply_before and apply_after. Also, I think rotation interpolation functions would be helpful such as |
Hey, I was looking to add some QoL methods to the Transform component too but then I saw your PR. I think it would be nice to have the following (taken from Unity):
|
@GrantMoyer Could you elaborate what would be the difference? |
@MarekLg Tranform composition is not commutative, so in generally A*B != B*A. For example, translating by 10, then scaling by 2 is not the same as scaling by 2, then translating by 10, since the scaling is always relative to the global origin. |
You're right, but that's not why I'm asking. pub fn apply(&mut self, other: &Transform) {
self.value = *other.value() * self.value;
} So I'm assuming pub fn apply(&mut self, other: &Transform) {
self.value = self.value * *other.value();
} If I got that right: what would be the use of |
Apply before could be used to, for instance, scale a model to half size before applying the current transform. Since these ops are in place, doing that with apply (apply_after) would require an extra copy. |
I understand, thanks for the clarification! I'll put in both of the |
Another question: should |
I'm gonna add my two cents because I just ran into the ordering issue with The naming of these applying methods seem to maximize the chance for misunderstandings. I would either remove the method when the multiply-left version is not allowed to exist or add an in-place multiply-left method.
The "correct" way of doing this really depends on the context of application. For most things, I would expect a sequence of Translate -> Rotate and Rotate -> Translate to have differing effects. But in the context of a transform component that e.g. controls the camera, I want to iteratively change rotation and translation independent of each other. The latter use case may be the typical one for this framework. It should just be clearly communicated. |
most of those methods now exist on |
I'd like Transforms to have some QoL methods (examples will follow), and would like to hear what the sentiment towards that would be (I know we want to be careful with implementing too many new features).
Here is my wishlist (much of these are influenced by Unity's
Transform
s:Transform::forward() -> Vec3
Get the normalized direction pointing towards in model-spaceTransform::look_at(&mut self, &Vec3)
Rotate the Transform, so that it looks at a certain positionQuat
, though.Transform::face_towards(&mut self, ..) -> Self
same asTransform::new(Mat4::face_towards(..))
but minimizes the amount ofMat4
s the average user has to deal withTransform::apply(&mut self, other: &Transform)
transform yourtransform
by anothertransform
;)The mutable methods would also only be implemented on
Transform
but not onGlobalTransform
(although refining the difference between Global- and Transform could be another Issue).If everyone's on board I'd like to use this issue to collect wanted features for
Transform
s and open a pull request to implement them.The text was updated successfully, but these errors were encountered: