Consider a world filled with rectangular 2D meshes, millions of triangles. We need to select with a mouse click the triangle that is closer to the screen. I want to know the triangle index and the parent mesh/actor.
I know the method:
AHUD::GetActorsInSelectionRectangle
But I see that it just iterates the (filtered) actors, and checks it’s bounds AABB. I know advanced selection algorithms use the vectorizer to solve this problem (and other engines use physics, but I don’t like enabling physics just for selection), because is fast and automatically considers clipping and sort order.
Now, I did a fast search on UE4 Source and noticed that there is a method used for mouse hover in Runtime code called:
HHitProxy* FViewport::GetHitProxy(int32 X,int32 Y)
And I think that it uses a custom render to texture, so I think is using the vectorizer. Now, since I don’t want to reinvent the wheel, is there any example of how to use this (or other method) to select triangles in-game?