bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Split UI/2D Transforms from 3D

Open james7132 opened this issue 2 years ago • 2 comments

What problem does this solve or what need does it fill?

A full 3D affine transform is a poor fit for UIs and often overkill for 2D uses. Transform and it's propagation system is a major bottleneck in PostUpdate, with a large number of potentially separable systems dependent on them.

What solution would you like?

Split out Transform2D and RectTransform from Transform, explicitly for their respective use cases.

Pros

  • Both can be smaller in memory than Transform and GlobalTransform.
  • Math on both will be simpler (and faster)
  • Would likely fix any oddities when dealing with Z-positions in both UI and 2D by strictly defining inheritance behavior of depth.
  • UI and 2D propagation and dependent systems parallelize more readily with 3D systems.
  • UI probably doesn't need a dedicated propagation or GlobalTransform equivalent, relying on the UI layouting algorithm instead.

Cons

  • Higher complexity. Recreating propagation outside of PostUpdate is now more involved.
  • Different components adds mental overhead to users.

What alternative(s) have you considered?

Leave it as is for now.

james7132 avatar Mar 02 '23 20:03 james7132

related to #1275

mockersf avatar Mar 03 '23 00:03 mockersf

UI probably doesn't need a dedicated propagation or GlobalTransform equivalent, relying on the UI layouting algorithm instead.

World space UI(#5476) is something to keep in mind.

tim-blackbird avatar Mar 13 '23 13:03 tim-blackbird