fuselibs
fuselibs copied to clipboard
ClipToBounds on transformed, non-axis-aligned possible non-rectangular elements
A user encountered the problem that a rotated element with ClipToBounds=true will not clip to the actual bounds. This is because only do GL scissor clipping at the moment: there is no way to do non-axis-aligned, possibly non-rectangular bounds (we don't support rotation or shearing).
- 2D rotations produce non-axis aligned rectangular bounds (good to support)
- 2D skews produce non-rectangular bounds (less important)
- 3D rotation produces non-rectangular bounds (probably more value than skew)
We might need to look at getting this working now in some other fashion.
@kusma I think you're best suited to at least know what those other options would be.
This is not a bug, but a case of unreasonable expectations. ClipToBounds clips to the bounding rectangle of the element, which is what we mean when we say "bounds". We don't mean "convex hull" or any other potential interpretation of "bounds".
Bounds should mean bounds as in LocalBounds. There's no other useful defintiion for the user. Therefore ClipToBounds should actually clip to the LocalBounds -- theres' no useful defintiion of clipping other than this to the user.
Whether we see this as a defect or a feature request doesn't make a big difference.
There's a TODO in Elemenet.Drawing about transforms not wortking indicating that clippign to local bounds was always the intended meaning.
We've known about this a long time https://github.com/Outracks/RealtimeStudio/issues/1286 but I guess there isn't a simple solution (stencil buffers?)
You were talking about non-rectangular bounds. Did you mean non axis-aligned bounds? If so, yes, this is a known problem (and the one you linked to).
Stencil buffers is a bit easier said than done, because Uno doesn't really support it. Or at least it didn't until recently. @yupferris, did your stencil-buffer work land?
By non-rectangular I meant non-axis aligned rectangular bounds. I think we mean the same thing now (I'll update the first description).
That said, LocalBounds may not actually be rectangular in the output scene when using a 3D rotation or 2D skew. So the most general form of this feature actually needs to support true non-rectangular 2D bounds. I think however that just supporting 2D rotation would be a big enough improvement on its own.