toolchain icon indicating copy to clipboard operation
toolchain copied to clipboard

Missing Clipping Variant of gfx_RotatedTransparentSprite_NoClip

Open ElyassCreates opened this issue 10 months ago • 4 comments

There is no clipping variant for the function gfx_RotatedTransparentSprite_NoClip. I tried alternatives but they all failed, so maybe there could be a function like gfx_RotatedTransparentSprite, like how there is gfx_Rectangle for gfx_Rectangle_NoClip.

ElyassCreates avatar Apr 02 '25 16:04 ElyassCreates

This is really hard and would be really slow sadly enough. The main suggestion is to use gfx_RotateSprite and then use gfx_TransparentSprite to display the clipped version for now. We will consider this function, but not many people are writing optimized assembly these days.

mateoconlechuga avatar Apr 18 '25 22:04 mateoconlechuga

Image I have recently implemented a clipping version of gfx_Rotated(Transparent)Sprite_NoClip, which runs at the same speed as the un-clipped routine plus a constant overhead of ~100 clock cycles.

The main thing we are debating now is determining how to deal with the cut corners of the square sprite-texture. Currently, all the sprite rotations routines cut the corners. It would be possible to fix this so the entire square is rendered which would require the rendering area to be twice as large, meaning it would run at half the speed in the worst case.

ZERICO2005 avatar Jun 10 '25 21:06 ZERICO2005

Another consideration is that gfx_Rotated(Transparent)Sprite_NoClip would be required to cut corners by default for API compatibility reasons. Otherwise the additional uncut pixels could potentially be written off-screen in older programs.

ZERICO2005 avatar Jun 10 '25 21:06 ZERICO2005

For the return value, I suppose returning the unclipped size would be fine.

ZERICO2005 avatar Jun 10 '25 23:06 ZERICO2005

One way to prevent corners from being cutoff is to pass in a larger sprite with extra padding.

ZERICO2005 avatar Jul 19 '25 20:07 ZERICO2005