Replies: 1 comment 3 replies
-
A matrix is a mixture of rotation and scaling, so rotating 180 degrees the naive way (interpolating each axis in the matrix) will shrink to nothing then expand to the final position. It's easy to visualize if you look at the columns as the XYZ vectors of the space being transformed. It's not wrong, it just isn't how things typically move. If you want something more like a rigid motion, you have to separate the matrix into rotation and scaling, which can be done with polar decomposition, e.g. using This operation is kind of expensive, so I use my own transform type that has translation ( Anyway, interpolation on this representation (using spherical interpolation for rotation) works as expected, minimizing stretching during interpolation. This is for 3D, so for 2D it would be a |
Beta Was this translation helpful? Give feedback.
-
I implemented some 2D animation using Bevy, which works (or rather, should work) by manipulating
Transforms
s inSpriteBundle
s. I was really surprised to find out (after some painful debugging, and finally usingbevy_prototype_lyon
to draw out all the bounding boxes for all mySprite
s) that all the bounding boxes are rectangular, instead of being sheared polyhedrons. It seems the current encoding ofTransform
andGlobalTransform
just silently drops the shearing duringTransform::from_matrix
or duringTransform
propagation...Is there any API I am currently missing which provides support for shearing (or is it actually supported and I have misused the API)? If not, is there currently any workaround for this problem, or will there be a solution in foreseeable future?
Thanks in advance.
P.S. I noticed #1755 and #4379, but I think it is better to ask here and get an "official" answer, rather than to draw some random conclusions from scattered information.
Edit: 2022-05-22
I managed to achieve what I want (sort of) by patching
bevy
locally with modified version of #4379 (merged into latest/0.7.0 and modifiedtransform_propagate_system
to allow using full-fledgedAffine3A
as local transforms). That said, my implementation is mostly a dirty hack, and hopefully in near future relevant PRs will land in Bevy official.P.S. What is the correct way to linear interpolate two
Affine3A
s? I don't see aAffine3A::lerp
method, and naive linear combination does not look quite right.Beta Was this translation helpful? Give feedback.
All reactions