Open ickshonpe opened 3 days ago
I like the feature and the API. I'd probably do a smallvec myself, but we should bench that and do it in follow-up.
Wondering if it's more or less confusing to call optional components non-required/unrequired instead 😕
I like the feature and the API. I'd probably do a smallvec myself, but we should bench that and do it in follow-up.
Yeah it seems to me in practical terms it's unusual to use a very large number of shadows and if you do it's most likely because you are are using multiple shadows in which case the smallvec would allocate on the heap anyway.
Objective
Add support for multiple box shadows on a single
Node
.Solution
BoxShadow
toShadowStyle
and remove itsComponent
derive.BoxShadow
component that newtypes aVec<ShadowStyle>
.new
constructor method toBoxShadow
for single shadows.extract_shadows
to iterate through a list of shadows per node.Render order is determined implicitly from the order of the shadows stored in the
BoxShadow
component, back-to-front. Might be more efficient to use aSmallVec<[ShadowStyle; 1]>
for the list of shadows but not sure if the extra friction is worth it.Testing
Added a node with four differently coloured shadows to the
box_shadow
example.Showcase
Migration Guide
Bevy UI now supports multiple shadows per node. A new struct
ShadowStyle
is used to set the style for each shadow. And theBoxShadow
component is changed to a tuple struct wrapping a vector containing a list ofShadowStyle
s. To spawn a node with a single shadow you can use thenew
constructor function: