TransformUnderMouse with Alpha pixels check for quad-based Transforms

Hi, All ! Happy new year!
I want to make precise Mouse picking of quad based Transforms - like TCastleImageTransform, or TCastleScene with 2d sprite, in this case TransformUnderMouse performs hit-test over whole quad (geometry) and not taking into account transparent pixels of loaded textures. I found those similar topics : Convenient way to determine exact point under mouse - #4 by michalis and Get all geometry under raycast? - #5 by bugan11 where some ideas presented , but no complete solution so far. So here is my attempt (and a screenshot with wrong work), somewhat compilation of ideas from above topics.
The issues I have still - raycast is a bit buggy, not hitting properly the desired polygon, esp. if you move (zoom out) away from it, and this is not the case for standard TransformUnderMouse (for this I wrote my solution and tried also one from the code in Bugan11 topic, claimed to be working, but incomplete). And ofc. the pixel check is not working (the one I wrote in my method) as well.
Maybe somebody will have ideas, I also posted this in discord, but seems less people are checking it than the forum.
my-new-project.zip (25.1 KB)

1 Like

Hi, I’ll take a look and answer around the weekend.

I’m indeed offline on Discord from quite some time, sorry about it – I got busy lately working on a big new feature ( Web Target | Manual | Castle Game Engine ) and I kind of went offline for a long time :slight_smile: I will catch up with Discord eventually. And I will answer here when I have time to carefully read and investigate.

Happy 2025!

1 Like