Closed as not planned
Description
The article on #596 miss interpreted and there is no compelling reason to use TRS for global transforms, here is what I found:
- Mat4 is need to apply any transformations, this means way more TRS to Mat4 conversions will be need than Mat4 to TRS. So keeping a Mat4 is faster and more convenient
- The article mentioned in the issue Moving transform data out of Mat4 #596 shows that matrices drifts when too many multiplications are made over it. But what the transform system actually do is to calculate the global matrices by multiplying the parent matrix with local TRS which then will be carried down to the next child. So the drift will be only carried away through the hierarchy chain, meaning that, according with the article, the 200 child will have a drift of 0.000001 and having such deep hierarchy isn't realistic in a game context
- Mat4 multiplication is ~1.9 times faster than TRS, this affects directly the
transform_propagation_system
- Mat4 point transform is ~5.3 times faster than TRS and that is a very common operation!
- Mat4 vector multiplication is ~2.4 times faster than TRS
- LocalToWorld translation is trivially accessible, it's just field like in TRS so nothing changes!
- LocalToWorld access to right, up, forward vectors is marginally cheaper than TRS so nothing changes!
- LocalToWorld shouldn't be modified directly, because the changes won't propagate
- Why name it LocalToWorld, because
GlobalTransfrom
confuses people into thinking they should modify it, the ecs approach doesnt allow fortransform.position = ...
like in traditional engines, because the transformations WONT propagate; Later on we want to add a WorldToLocal it can be useful in some situations. - We can have a LocalToWorld2D that 2D and 2.5D games will only pay for what they use, a mixed hierarchy using both types is sort of simple to understand (see a WIP in here)
- Mat4 can encode shear and other types of deformations
A few disadvantages
- TRS to Mat4 is ~4.5 times faster than Mat4 to TRS
- Mat4 inverse is not always possible
- TRS inverse is ~1.7 times faster than Mat4 inverse
- TRS any direction is ~1.2 times faster than Mat4 and that is a very common operation!
Sorry for wanting to break everyone else code